linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 1/4] btrfs: Refactor loop in btrfs_release_extent_buffer_page
Date: Wed, 27 Jun 2018 16:38:22 +0300	[thread overview]
Message-ID: <1530106705-27186-2-git-send-email-nborisov@suse.com> (raw)
In-Reply-To: <1530106705-27186-1-git-send-email-nborisov@suse.com>

The purpose of the function is to free all the pages comprising an
extent buffer. This can be achieved with a simple for loop rather than
the slitghly more involved 'do {} while' construct. So rewrite the
loop using a 'for' construct. Additionally we can never have an
extent_buffer that is 0 pages so remove the check for index == 0. No
functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent_io.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index cce6087d6880..4180a3b7e725 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4641,19 +4641,14 @@ int extent_buffer_under_io(struct extent_buffer *eb)
  */
 static void btrfs_release_extent_buffer_page(struct extent_buffer *eb)
 {
-	unsigned long index;
-	struct page *page;
+	int i;
 	int mapped = !test_bit(EXTENT_BUFFER_DUMMY, &eb->bflags);
 
 	BUG_ON(extent_buffer_under_io(eb));
 
-	index = num_extent_pages(eb->start, eb->len);
-	if (index == 0)
-		return;
+	for (i = 0; i < num_extent_pages(eb->start, eb->len); i++) {
+		struct page *page = eb->pages[i];
 
-	do {
-		index--;
-		page = eb->pages[index];
 		if (!page)
 			continue;
 		if (mapped)
@@ -4685,7 +4680,7 @@ static void btrfs_release_extent_buffer_page(struct extent_buffer *eb)
 
 		/* One for when we allocated the page */
 		put_page(page);
-	} while (index != 0);
+	}
 }
 
 /*
-- 
2.7.4


  reply	other threads:[~2018-06-27 13:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27 13:38 [PATCH 0/4] Misc cleanups Nikolay Borisov
2018-06-27 13:38 ` Nikolay Borisov [this message]
2018-06-29 12:35   ` [PATCH 1/4] btrfs: Refactor loop in btrfs_release_extent_buffer_page David Sterba
2018-07-02 10:03     ` Nikolay Borisov
2018-07-19 15:19       ` David Sterba
2018-06-27 13:38 ` [PATCH 2/4] btrfs: Document locking require via lockdep_assert_held Nikolay Borisov
2018-06-27 13:38 ` [PATCH 3/4] btrfs: Rename EXTENT_BUFFER_DUMMY to EXTENT_BUFFER_PRIVATE Nikolay Borisov
2018-06-29 12:46   ` David Sterba
2018-06-29 13:07     ` Qu Wenruo
2018-06-29 13:42       ` Nikolay Borisov
2018-07-19 15:40         ` David Sterba
2018-06-29 13:53       ` David Sterba
2018-06-27 13:38 ` [PATCH 4/4] btrfs: Remove unnecessary locking code in qgroup_rescan_leaf Nikolay Borisov
2018-07-02 13:32   ` Nikolay Borisov

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=1530106705-27186-2-git-send-email-nborisov@suse.com \
    --to=nborisov@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 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).