Re: [PATCH v5 33/40] netfs, cachefiles: Pass upper bound length to allow expansion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi David,

On 2023/12/21 21:23, David Howells wrote:
Make netfslib pass the maximum length to the ->prepare_write() op to tell
the cache how much it can expand the length of a write to.  This allows a
write to the server at the end of a file to be limited to a few bytes
whilst writing an entire block to the cache (something required by direct
I/O).

Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>
cc: linux-cachefs@xxxxxxxxxx
cc: linux-fsdevel@xxxxxxxxxxxxxxx
cc: linux-mm@xxxxxxxxx
---
  fs/cachefiles/internal.h |  2 +-
  fs/cachefiles/io.c       | 10 ++++++----
  fs/cachefiles/ondemand.c |  2 +-
  fs/netfs/fscache_io.c    |  2 +-
  fs/netfs/io.c            |  2 +-
  fs/netfs/objects.c       |  1 +
  fs/netfs/output.c        | 25 ++++++++++---------------
  fs/smb/client/fscache.c  |  2 +-
  include/linux/netfs.h    |  5 +++--
  9 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 2ad58c465208..1af48d576a34 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -233,7 +233,7 @@ extern bool cachefiles_begin_operation(struct netfs_cache_resources *cres,
  				       enum fscache_want_state want_state);
  extern int __cachefiles_prepare_write(struct cachefiles_object *object,
  				      struct file *file,
-				      loff_t *_start, size_t *_len,
+				      loff_t *_start, size_t *_len, size_t upper_len,
  				      bool no_space_allocated_yet);
  extern int __cachefiles_write(struct cachefiles_object *object,
  			      struct file *file,
diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c
index 009d23cd435b..bffffedce4a9 100644
--- a/fs/cachefiles/io.c
+++ b/fs/cachefiles/io.c
@@ -518,7 +518,7 @@ cachefiles_prepare_ondemand_read(struct netfs_cache_resources *cres,
   */
  int __cachefiles_prepare_write(struct cachefiles_object *object,
  			       struct file *file,
-			       loff_t *_start, size_t *_len,
+			       loff_t *_start, size_t *_len, size_t upper_len,
  			       bool no_space_allocated_yet)
  {
  	struct cachefiles_cache *cache = object->volume->cache;
@@ -530,6 +530,8 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
  	down = start - round_down(start, PAGE_SIZE);
  	*_start = start - down;
  	*_len = round_up(down + len, PAGE_SIZE);
+	if (down < start || *_len > upper_len)
+		return -ENOBUFS;

Sorry for bothering. We just found some strange when testing
today-next EROFS over fscache.

I'm not sure the meaning of
    if (down < start

For example, if start is page-aligned, down == 0.

so as long as start > 0 and page-aligned, it will return
-ENOBUFS.  Does it an intended behavior?

Thanks,
Gao Xiang

--
You received this message because you are subscribed to the Google Groups "linux-cachefs@xxxxxxxxxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-cachefs+unsubscribe@xxxxxxxxxx.




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]
  Powered by Linux