提交 6300463b 编写于 作者: L Liu Bo 提交者: David Sterba

Btrfs: make plug in writing meta blocks really work

We have started plug in btrfs_write_and_wait_marked_extents() but the
generated IOs actually go to device's schedule IO list where the work
is doing in another task, thus the started plug doesn't make any
sense.

And since we wait for IOs immediately after writing meta blocks, it's
the same case as writing log tree, doing sync submit can merge more
IOs.
Signed-off-by: NLiu Bo <bo.li.liu@oracle.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 d8953d69
...@@ -1005,8 +1005,10 @@ static blk_status_t __btree_submit_bio_done(void *private_data, struct bio *bio, ...@@ -1005,8 +1005,10 @@ static blk_status_t __btree_submit_bio_done(void *private_data, struct bio *bio,
return ret; return ret;
} }
static int check_async_write(unsigned long bio_flags) static int check_async_write(struct btrfs_inode *bi, unsigned long bio_flags)
{ {
if (atomic_read(&bi->sync_writers))
return 0;
if (bio_flags & EXTENT_BIO_TREE_LOG) if (bio_flags & EXTENT_BIO_TREE_LOG)
return 0; return 0;
#ifdef CONFIG_X86 #ifdef CONFIG_X86
...@@ -1022,7 +1024,7 @@ static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio, ...@@ -1022,7 +1024,7 @@ static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio,
{ {
struct inode *inode = private_data; struct inode *inode = private_data;
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
int async = check_async_write(bio_flags); int async = check_async_write(BTRFS_I(inode), bio_flags);
blk_status_t ret; blk_status_t ret;
if (bio_op(bio) != REQ_OP_WRITE) { if (bio_op(bio) != REQ_OP_WRITE) {
......
...@@ -950,6 +950,7 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info, ...@@ -950,6 +950,7 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,
u64 start = 0; u64 start = 0;
u64 end; u64 end;
atomic_inc(&BTRFS_I(fs_info->btree_inode)->sync_writers);
while (!find_first_extent_bit(dirty_pages, start, &start, &end, while (!find_first_extent_bit(dirty_pages, start, &start, &end,
mark, &cached_state)) { mark, &cached_state)) {
bool wait_writeback = false; bool wait_writeback = false;
...@@ -985,6 +986,7 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info, ...@@ -985,6 +986,7 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,
cond_resched(); cond_resched();
start = end + 1; start = end + 1;
} }
atomic_dec(&BTRFS_I(fs_info->btree_inode)->sync_writers);
return werr; return werr;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册