linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Move btrfs_lock_and_flush_ordered_range call in btrfs_do_readpage
@ 2020-09-16  8:14 Nikolay Borisov
  2020-09-16  8:54 ` Johannes Thumshirn
  0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2020-09-16  8:14 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

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(-)

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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Move btrfs_lock_and_flush_ordered_range call in btrfs_do_readpage
  2020-09-16  8:14 [PATCH] btrfs: Move btrfs_lock_and_flush_ordered_range call in btrfs_do_readpage Nikolay Borisov
@ 2020-09-16  8:54 ` Johannes Thumshirn
  2020-09-17  6:15   ` Nikolay Borisov
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Thumshirn @ 2020-09-16  8:54 UTC (permalink / raw)
  To: Nikolay Borisov, linux-btrfs

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Move btrfs_lock_and_flush_ordered_range call in btrfs_do_readpage
  2020-09-16  8:54 ` Johannes Thumshirn
@ 2020-09-17  6:15   ` Nikolay Borisov
  2020-09-17  6:38     ` Johannes Thumshirn
  0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2020-09-17  6:15 UTC (permalink / raw)
  To: Johannes Thumshirn, linux-btrfs



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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Move btrfs_lock_and_flush_ordered_range call in btrfs_do_readpage
  2020-09-17  6:15   ` Nikolay Borisov
@ 2020-09-17  6:38     ` Johannes Thumshirn
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2020-09-17  6:38 UTC (permalink / raw)
  To: Nikolay Borisov, linux-btrfs

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-17  6:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16  8:14 [PATCH] btrfs: Move btrfs_lock_and_flush_ordered_range call in btrfs_do_readpage Nikolay Borisov
2020-09-16  8:54 ` Johannes Thumshirn
2020-09-17  6:15   ` Nikolay Borisov
2020-09-17  6:38     ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).