lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250827192441.475831-1-max.kellermann@ionos.com>
Date: Wed, 27 Aug 2025 21:24:41 +0200
From: Max Kellermann <max.kellermann@...os.com>
To: Slava.Dubeyko@....com,
	xiubli@...hat.com,
	idryomov@...il.com,
	amarkuze@...hat.com,
	ceph-devel@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Max Kellermann <max.kellermann@...os.com>
Subject: [PATCH] fs/ceph/addr: remove redundant field `nr_folios`

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@...os.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ