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-next>] [day] [month] [year] [list]
Date: Mon, 13 May 2024 21:23:39 +0800
From: Liu Wei <liuwei09@...tc.cn>
To: willy@...radead.org
Cc: akpm@...ux-foundation.org,
	linux-kernel@...r.kernel.org,
	liuwei09@...tc.cn
Subject: [PATCH] mm/filemap: invalidating pages is still necessary when io with IOCB_NOWAIT

After commit (6be96d3ad3 fs: return if direct I/O will trigger writeback),
when we issuing AIO with direct I/O and IOCB_NOWAIT on a block device, the
process context will not be blocked.

However, if the device already has page cache in memory, EAGAIN will be
returned. And even when trying to reissue the AIO with direct I/O and
IOCB_NOWAIT again, we consistently receive EAGAIN.

Maybe a better way to deal with it: filemap_fdatawrite_range dirty pages
with WB_SYNC_NONE flag, and invalidate_mapping_pages unmapped pages at
the same time.

Signed-off-by: Liu Wei <liuwei09@...tc.cn>
---
 mm/filemap.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 30de18c4fd28..1852a00caf31 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2697,8 +2697,15 @@ int kiocb_invalidate_pages(struct kiocb *iocb, size_t count)
 
 	if (iocb->ki_flags & IOCB_NOWAIT) {
 		/* we could block if there are any pages in the range */
-		if (filemap_range_has_page(mapping, pos, end))
+		if (filemap_range_has_page(mapping, pos, end)) {
+			if (mapping_needs_writeback(mapping)) {
+				__filemap_fdatawrite_range(mapping,
+						pos, end, WB_SYNC_NONE);
+			}
+			invalidate_mapping_pages(mapping,
+					pos >> PAGE_SHIFT, end >> PAGE_SHIFT);
 			return -EAGAIN;
+		}
 	} else {
 		ret = filemap_write_and_wait_range(mapping, pos, end);
 		if (ret)
-- 
2.42.1




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ