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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240515055719.32577-5-da.gomez@samsung.com>
Date: Wed, 15 May 2024 05:57:27 +0000
From: Daniel Gomez <da.gomez@...sung.com>
To: "hughd@...gle.com" <hughd@...gle.com>, "akpm@...ux-foundation.org"
	<akpm@...ux-foundation.org>, "willy@...radead.org" <willy@...radead.org>,
	"jack@...e.cz" <jack@...e.cz>, "mcgrof@...nel.org" <mcgrof@...nel.org>
CC: "linux-mm@...ck.org" <linux-mm@...ck.org>, "linux-xfs@...r.kernel.org"
	<linux-xfs@...r.kernel.org>, "djwong@...nel.org" <djwong@...nel.org>,
	"Pankaj Raghav" <p.raghav@...sung.com>, "dagmcr@...il.com"
	<dagmcr@...il.com>, "yosryahmed@...gle.com" <yosryahmed@...gle.com>,
	"baolin.wang@...ux.alibaba.com" <baolin.wang@...ux.alibaba.com>,
	"ritesh.list@...il.com" <ritesh.list@...il.com>,
	"lsf-pc@...ts.linux-foundation.org" <lsf-pc@...ts.linux-foundation.org>,
	"david@...hat.com" <david@...hat.com>, "chandan.babu@...cle.com"
	<chandan.babu@...cle.com>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "brauner@...nel.org" <brauner@...nel.org>,
	Daniel Gomez <da.gomez@...sung.com>
Subject: [PATCH 04/12] shmem: exit shmem_get_folio_gfp() if block is
 uptodate

When we get a folio from the page cache with filemap_get_entry() and
is uptodate we exit from shmem_get_folio_gfp(). Replicate the same
behaviour if the block is uptodate in the index we are operating on.

Signed-off-by: Daniel Gomez <da.gomez@...sung.com>
---
 mm/shmem.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 86ad539b6a0f..69f3b98fdf7c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -256,6 +256,16 @@ static inline bool shmem_is_any_uptodate(struct folio *folio)
 	return folio_test_uptodate(folio);
 }
 
+static inline bool shmem_is_block_uptodate(struct folio *folio,
+					   unsigned int block)
+{
+	struct shmem_folio_state *sfs = folio->private;
+
+	if (folio_test_large(folio) && sfs)
+		return sfs_is_block_uptodate(sfs, block);
+	return folio_test_uptodate(folio);
+}
+
 static void shmem_set_range_uptodate(struct folio *folio, size_t off,
 				     size_t len)
 {
@@ -2146,7 +2156,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
 		}
 		if (sgp == SGP_WRITE)
 			folio_mark_accessed(folio);
-		if (folio_test_uptodate(folio))
+		if (shmem_is_block_uptodate(folio, index - folio_index(folio)))
 			goto out;
 		/* fallocated folio */
 		if (sgp != SGP_READ)
-- 
2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ