cachefiles: set HAVE_DATA only after successful writes
Subsystems (2)
PATCH 1/1 cachefiles: set HAVE_DATA only after successful writes
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 <[email protected]>
--- fs/cachefiles/io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cachefiles/io.c +2 -1
@@ -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);
Signature · 1 line
2.51.0