Pass a flag to ->prepare_write() to indicate if there's definitely no
space allocated in the cache yet (for instance if we've already checked as
we were asked to do a read).

Signed-off-by: David Howells <dhowe...@redhat.com>
cc: linux-cachefs@redhat.com
---

 fs/cachefiles_old/io.c |    3 ++-
 fs/netfs/read_helper.c |    2 +-
 include/linux/netfs.h  |    3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/cachefiles_old/io.c b/fs/cachefiles_old/io.c
index 5ead97de4bb7..eab8641de994 100644
--- a/fs/cachefiles_old/io.c
+++ b/fs/cachefiles_old/io.c
@@ -341,7 +341,8 @@ static enum netfs_read_source 
cachefiles_prepare_read(struct netfs_read_subreque
  * Prepare for a write to occur.
  */
 static int cachefiles_prepare_write(struct netfs_cache_resources *cres,
-                                   loff_t *_start, size_t *_len, loff_t i_size)
+                                   loff_t *_start, size_t *_len, loff_t i_size,
+                                   bool no_space_allocated_yet)
 {
        loff_t start = *_start;
        size_t len = *_len, down;
diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
index dfc60c79a9f3..80f8e334371d 100644
--- a/fs/netfs/read_helper.c
+++ b/fs/netfs/read_helper.c
@@ -323,7 +323,7 @@ static void netfs_rreq_do_write_to_cache(struct 
netfs_read_request *rreq)
                }
 
                ret = cres->ops->prepare_write(cres, &subreq->start, 
&subreq->len,
-                                              rreq->i_size);
+                                              rreq->i_size, true);
                if (ret < 0) {
                        trace_netfs_failure(rreq, subreq, ret, 
netfs_fail_prepare_write);
                        trace_netfs_sreq(subreq, netfs_sreq_trace_write_skip);
diff --git a/include/linux/netfs.h b/include/linux/netfs.h
index 014fb502fd91..99137486d351 100644
--- a/include/linux/netfs.h
+++ b/include/linux/netfs.h
@@ -220,7 +220,8 @@ struct netfs_cache_ops {
         * actually do.
         */
        int (*prepare_write)(struct netfs_cache_resources *cres,
-                            loff_t *_start, size_t *_len, loff_t i_size);
+                            loff_t *_start, size_t *_len, loff_t i_size,
+                            bool no_space_allocated_yet);
 
        /* Prepare a write operation for the fallback fscache API, working out
         * whether we can cache a page or not.


--
Linux-cachefs mailing list
Linux-cachefs@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-cachefs

Reply via email to