Message ID | 20200916081401.31668-1-nborisov@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: Move btrfs_lock_and_flush_ordered_range call in btrfs_do_readpage | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On 16.09.20 г. 11:54 ч., Johannes Thumshirn wrote: > Looks good, > Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > Actually no, this conflicts with btrfs_do_readpage call from contiguous_readpages which results in double lock.
On 17/09/2020 08:15, Nikolay Borisov wrote: > Actually no, this conflicts with btrfs_do_readpage call from > contiguous_readpages which results in double lock. > Right didn't see it :( But why can't we remove the btrfs_lock_and_flush_ordered_range call in contigous_readpages?
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index afac70ef0cc5..00e552055315 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3163,6 +3163,8 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, unsigned long this_bio_flag = 0; struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; + btrfs_lock_and_flush_ordered_range(BTRFS_I(inode), start, end, NULL); + set_page_extent_mapped(page); if (!PageUptodate(page)) { diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index cb3fdd0798c6..ae396d799aa5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8023,15 +8023,10 @@ static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, int btrfs_readpage(struct file *file, struct page *page) { - struct btrfs_inode *inode = BTRFS_I(page->mapping->host); - u64 start = page_offset(page); - u64 end = start + PAGE_SIZE - 1; unsigned long bio_flags = 0; struct bio *bio = NULL; int ret; - btrfs_lock_and_flush_ordered_range(inode, start, end, NULL); - ret = btrfs_do_readpage(page, NULL, &bio, &bio_flags, 0, NULL); if (bio) ret = submit_one_bio(bio, 0, bio_flags);
btrfs_lock_and_flush_ordered_range returns with the extent range locked. Subsequently this lock is being dropped in btrfs_do_readpage. Given this it makes more sense to move the call to the locking function inside btrfs_do_readpage making btrfs_do_readpage self-contained as it calls unlock_extent a couple of times. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- fs/btrfs/extent_io.c | 2 ++ fs/btrfs/inode.c | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-)