mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 23:00:21 +00:00
f2fs: reduce competition among node page writes
We do not need to block on ->node_write among different node page writers e.g. fsync/flush, unless we have a node page writer from write_checkpoint. So it's better use rw_semaphore instead of mutex type for ->node_write to promote performance. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
65b85ccce0
commit
b3582c6892
@ -762,10 +762,10 @@ retry_flush_dents:
|
|||||||
* until finishing nat/sit flush.
|
* until finishing nat/sit flush.
|
||||||
*/
|
*/
|
||||||
retry_flush_nodes:
|
retry_flush_nodes:
|
||||||
mutex_lock(&sbi->node_write);
|
down_write(&sbi->node_write);
|
||||||
|
|
||||||
if (get_pages(sbi, F2FS_DIRTY_NODES)) {
|
if (get_pages(sbi, F2FS_DIRTY_NODES)) {
|
||||||
mutex_unlock(&sbi->node_write);
|
up_write(&sbi->node_write);
|
||||||
sync_node_pages(sbi, 0, &wbc);
|
sync_node_pages(sbi, 0, &wbc);
|
||||||
goto retry_flush_nodes;
|
goto retry_flush_nodes;
|
||||||
}
|
}
|
||||||
@ -774,7 +774,7 @@ retry_flush_nodes:
|
|||||||
|
|
||||||
static void unblock_operations(struct f2fs_sb_info *sbi)
|
static void unblock_operations(struct f2fs_sb_info *sbi)
|
||||||
{
|
{
|
||||||
mutex_unlock(&sbi->node_write);
|
up_write(&sbi->node_write);
|
||||||
f2fs_unlock_all(sbi);
|
f2fs_unlock_all(sbi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ struct f2fs_sb_info {
|
|||||||
struct inode *meta_inode; /* cache meta blocks */
|
struct inode *meta_inode; /* cache meta blocks */
|
||||||
struct mutex cp_mutex; /* checkpoint procedure lock */
|
struct mutex cp_mutex; /* checkpoint procedure lock */
|
||||||
struct rw_semaphore cp_rwsem; /* blocking FS operations */
|
struct rw_semaphore cp_rwsem; /* blocking FS operations */
|
||||||
struct mutex node_write; /* locking node writes */
|
struct rw_semaphore node_write; /* locking node writes */
|
||||||
struct mutex writepages; /* mutex for writepages() */
|
struct mutex writepages; /* mutex for writepages() */
|
||||||
bool por_doing; /* recovery is doing or not */
|
bool por_doing; /* recovery is doing or not */
|
||||||
wait_queue_head_t cp_wait;
|
wait_queue_head_t cp_wait;
|
||||||
|
@ -1231,12 +1231,12 @@ static int f2fs_write_node_page(struct page *page,
|
|||||||
if (wbc->for_reclaim)
|
if (wbc->for_reclaim)
|
||||||
goto redirty_out;
|
goto redirty_out;
|
||||||
|
|
||||||
mutex_lock(&sbi->node_write);
|
down_read(&sbi->node_write);
|
||||||
set_page_writeback(page);
|
set_page_writeback(page);
|
||||||
write_node_page(sbi, page, &fio, nid, ni.blk_addr, &new_addr);
|
write_node_page(sbi, page, &fio, nid, ni.blk_addr, &new_addr);
|
||||||
set_node_addr(sbi, &ni, new_addr, is_fsync_dnode(page));
|
set_node_addr(sbi, &ni, new_addr, is_fsync_dnode(page));
|
||||||
dec_page_count(sbi, F2FS_DIRTY_NODES);
|
dec_page_count(sbi, F2FS_DIRTY_NODES);
|
||||||
mutex_unlock(&sbi->node_write);
|
up_read(&sbi->node_write);
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -953,7 +953,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
|
|||||||
mutex_init(&sbi->gc_mutex);
|
mutex_init(&sbi->gc_mutex);
|
||||||
mutex_init(&sbi->writepages);
|
mutex_init(&sbi->writepages);
|
||||||
mutex_init(&sbi->cp_mutex);
|
mutex_init(&sbi->cp_mutex);
|
||||||
mutex_init(&sbi->node_write);
|
init_rwsem(&sbi->node_write);
|
||||||
sbi->por_doing = false;
|
sbi->por_doing = false;
|
||||||
spin_lock_init(&sbi->stat_lock);
|
spin_lock_init(&sbi->stat_lock);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user