mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yichong Chen <chenyichong@uniontech.com>
To: dhowells@redhat.com
Cc: jlayton@kernel.org, netfs@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	Yichong Chen <chenyichong@uniontech.com>
Subject: [PATCH] cachefiles: set HAVE_DATA only after successful writes
Date: Fri, 28 Aug 2026 10:34:29 +0800	[thread overview]
Message-ID: <20260828023429.2461803-1-chenyichong@uniontech.com> (raw)

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


                 reply	other threads:[~2026-08-28  2:35 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=20260828023429.2461803-1-chenyichong@uniontech.com \
    --to=chenyichong@uniontech.com \
    --cc=dhowells@redhat.com \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfs@lists.linux.dev \
    /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 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®