All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Kellermann <max.kellermann@ionos.com>
To: Slava.Dubeyko@ibm.com, xiubli@redhat.com, idryomov@gmail.com,
	amarkuze@redhat.com, ceph-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Max Kellermann <max.kellermann@ionos.com>
Subject: [PATCH] fs/ceph/addr: remove redundant field `nr_folios`
Date: Wed, 27 Aug 2025 21:24:41 +0200	[thread overview]
Message-ID: <20250827192441.475831-1-max.kellermann@ionos.com> (raw)

This variable was added by commit 590a2b5f0a9b ("ceph: convert
ceph_writepages_start() to use filemap_get_folios_tag()"), but it was
redundant and unnecessary right from the start, because it was just a
copy of `fbatch.nr`.

This patch just uses folio_batch_count(&ceph_wbc->fbatch) instead, but
keeps the filemap_get_folios_tag() return value in a new local
variable because calling folio_batch_count() would add unnecessary
overhead when we already have the return value of
filemap_get_folios_tag() in a register.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
 fs/ceph/addr.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 8b202d789e93..179141aeaa26 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -597,7 +597,6 @@ struct ceph_writeback_ctl
 
 	pgoff_t strip_unit_end;
 	unsigned int wsize;
-	unsigned int nr_folios;
 	unsigned int max_pages;
 	unsigned int locked_pages;
 
@@ -1033,7 +1032,6 @@ void ceph_init_writeback_ctl(struct address_space *mapping,
 	ceph_wbc->strip_unit_end = 0;
 	ceph_wbc->wsize = ceph_define_write_size(mapping);
 
-	ceph_wbc->nr_folios = 0;
 	ceph_wbc->max_pages = 0;
 	ceph_wbc->locked_pages = 0;
 
@@ -1129,7 +1127,7 @@ static inline
 bool can_next_page_be_processed(struct ceph_writeback_ctl *ceph_wbc,
 				unsigned index)
 {
-	return index < ceph_wbc->nr_folios &&
+	return index < folio_batch_count(&ceph_wbc->fbatch) &&
 		ceph_wbc->locked_pages < ceph_wbc->max_pages;
 }
 
@@ -1668,21 +1666,23 @@ static int ceph_writepages_start(struct address_space *mapping,
 		tag_pages_for_writeback(mapping, ceph_wbc.index, ceph_wbc.end);
 
 	while (!has_writeback_done(&ceph_wbc)) {
+		unsigned int nr_folios;
+
 		ceph_wbc.locked_pages = 0;
 		ceph_wbc.max_pages = ceph_wbc.wsize >> PAGE_SHIFT;
 
 get_more_pages:
 		ceph_folio_batch_reinit(&ceph_wbc);
 
-		ceph_wbc.nr_folios = filemap_get_folios_tag(mapping,
-							    &ceph_wbc.index,
-							    ceph_wbc.end,
-							    ceph_wbc.tag,
-							    &ceph_wbc.fbatch);
+		nr_folios = filemap_get_folios_tag(mapping,
+						   &ceph_wbc.index,
+						   ceph_wbc.end,
+						   ceph_wbc.tag,
+						   &ceph_wbc.fbatch);
 		doutc(cl, "pagevec_lookup_range_tag for tag %#x got %d\n",
-			ceph_wbc.tag, ceph_wbc.nr_folios);
+			ceph_wbc.tag, nr_folios);
 
-		if (!ceph_wbc.nr_folios && !ceph_wbc.locked_pages)
+		if (!nr_folios && !ceph_wbc.locked_pages)
 			break;
 
 process_folio_batch:
@@ -1712,8 +1712,6 @@ static int ceph_writepages_start(struct address_space *mapping,
 		ceph_wbc.strip_unit_end = 0;
 
 		if (folio_batch_count(&ceph_wbc.fbatch) > 0) {
-			ceph_wbc.nr_folios =
-				folio_batch_count(&ceph_wbc.fbatch);
 			goto process_folio_batch;
 		}
 
-- 
2.47.2


                 reply	other threads:[~2025-08-27 19:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250827192441.475831-1-max.kellermann@ionos.com \
    --to=max.kellermann@ionos.com \
    --cc=Slava.Dubeyko@ibm.com \
    --cc=amarkuze@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiubli@redhat.com \
    /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.