From: Johannes Thumshirn <jthumshirn@suse.de>
To: David Sterba <dsterba@suse.com>
Cc: Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>,
Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH] btrfs: simplify read_extent_buffer_pages a bit
Date: Thu, 11 Apr 2019 18:40:59 +0200 [thread overview]
Message-ID: <20190411164059.4981-1-jthumshirn@suse.de> (raw)
Currently read_extent_buffer_pages() uses a 4 pass algorithm to read an
extent buffer's pages from disk, all 4 stages looping over all pages of
the extent buffer.
1) Loop over all pages and lock them.
2) Loop over all pages and see if one is not marked as PageUptodate, so we
can break out of the function early.
3) Loop over all pages and if the page is !PageUptodate read the page,
otherwise unlock the page.
4) Loop over all pages and wait for stable pages.
Unify the 1st two for loops, we can count the number of uptodate pages
after we have locked them without the need for re-starting the loop.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
fs/btrfs/extent_io.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 828708f6510c..1d538bda4929 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5357,14 +5357,12 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
lock_page(page);
}
locked_pages++;
- }
- /*
- * We need to firstly lock all pages to make sure that
- * the uptodate bit of our pages won't be affected by
- * clear_extent_buffer_uptodate().
- */
- for (i = 0; i < num_pages; i++) {
- page = eb->pages[i];
+
+ /*
+ * We need to firstly lock all pages to make sure that
+ * the uptodate bit of our pages won't be affected by
+ * clear_extent_buffer_uptodate().
+ */
if (!PageUptodate(page)) {
num_reads++;
all_uptodate = 0;
--
2.16.4
next reply other threads:[~2019-04-11 16:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 16:40 Johannes Thumshirn [this message]
2019-04-11 16:59 ` [PATCH] btrfs: simplify read_extent_buffer_pages a bit David Sterba
2019-04-16 9:16 ` Johannes Thumshirn
2019-04-17 12:20 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190411164059.4981-1-jthumshirn@suse.de \
--to=jthumshirn@suse.de \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.