* [PATCH] cachefiles: set HAVE_DATA only after successful writes
@ 2026-08-28 2:34 Yichong Chen
0 siblings, 0 replies; only message in thread
From: Yichong Chen @ 2026-08-28 2:34 UTC (permalink / raw)
To: dhowells; +Cc: jlayton, netfs, linux-kernel, Yichong Chen
FSCACHE_COOKIE_HAVE_DATA means that the backend stored data for the cookie.
cachefiles_write_complete() currently sets it unconditionally. This also
happens when the cache write failed.
A failed cache write should not make fscache_note_page_release() believe
that there is data to read from the cache. Set the flag only when the
write completion reports that some data was written.
Fixes: 047487c947e8 ("cachefiles: Implement the I/O routines")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
fs/cachefiles/io.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c
index 9540ec25b3cb..0f94ec2aa5c8 100644
--- a/fs/cachefiles/io.c
+++ b/fs/cachefiles/io.c
@@ -269,7 +269,8 @@ static void cachefiles_write_complete(struct kiocb *iocb, long ret)
cachefiles_trace_write_error);
atomic_long_sub(ki->b_writing, &object->volume->cache->b_writing);
- set_bit(FSCACHE_COOKIE_HAVE_DATA, &object->cookie->flags);
+ if (ret > 0)
+ set_bit(FSCACHE_COOKIE_HAVE_DATA, &object->cookie->flags);
if (ki->term_func)
ki->term_func(ki->term_func_priv, ret);
cachefiles_put_kiocb(ki);
--
2.51.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-28 2:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28 2:34 [PATCH] cachefiles: set HAVE_DATA only after successful writes Yichong Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®