Skip to contentSkip to conversation

netfs, cachefiles, 9p: Additional patches

PATCH In review David Howells 4 participants 15 messages Jan 3, 2024 – Jan 9, 2024

Subsystems (11)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

cover netfs, cachefiles, 9p: Additional patches

Hi Christian, Jeff, Gao, Dominique,

Here are some additional patches for my netfs-lib tree:

(1) Fix __cachefiles_prepare_write() to correctly validate against the DIO alignment.

(2) 9p: Fix initialisation of the netfs_inode so that i_size is set before netfs_inode_init() is called.

(3) 9p: Do a couple of cleanups (remove a couple of unused vars and turn a BUG_ON() into a warning).

(4) 9p: Always update remote_i_size, even if we're asked not to update i_size in stat2inode.

(5) 9p: Return the amount written in preference to an error if we wrote something.

David

The netfslib postings:

David Howells (5):
cachefiles: Fix __cachefiles_prepare_write()
9p: Fix initialisation of netfs_inode for 9p
9p: Do a couple of cleanups
9p: Always update remote_i_size in stat2inode
9p: Use length of data written to the server in preference to error

 fs/9p/v9fs_vfs.h       |  1 +
 fs/9p/vfs_addr.c       | 24 ++++++++++++------------
 fs/9p/vfs_inode.c      |  6 +++---
 fs/9p/vfs_inode_dotl.c |  7 ++++---
 fs/cachefiles/io.c     | 28 +++++++++++++++++-----------
 5 files changed, 37 insertions(+), 29 deletions(-)
author maintainer
#1 lore raw

PATCH 1/5 cachefiles: Fix __cachefiles_prepare_write()

Fix __cachefiles_prepare_write() to correctly determine whether the requested write will fit correctly with the DIO alignment.

---
 fs/cachefiles/io.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
fs/cachefiles/io.c +17 -11
index bffffedce4a9..7529b40bc95a 100644
@@ -522,16 +522,22 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 			       bool no_space_allocated_yet)
 {
 	struct cachefiles_cache *cache = object->volume->cache;
-	loff_t start = *_start, pos;
-	size_t len = *_len, down;
+	unsigned long long start = *_start, pos;
+	size_t len = *_len;
 	int ret;
 
 	/* Round to DIO size */
-	down = start - round_down(start, PAGE_SIZE);
-	*_start = start - down;
-	*_len = round_up(down + len, PAGE_SIZE);
-	if (down < start || *_len > upper_len)
+	start = round_down(*_start, PAGE_SIZE);
+	if (start != *_start) {
+		kleave(" = -ENOBUFS [down]");
+		return -ENOBUFS;
+	}
+	if (*_len > upper_len) {
+		kleave(" = -ENOBUFS [up]");
 		return -ENOBUFS;
+	}
+
+	*_len = round_up(len, PAGE_SIZE);
 
 	/* We need to work out whether there's sufficient disk space to perform
 	 * the write - but we can skip that check if we have space already
@@ -542,7 +548,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 
 	pos = cachefiles_inject_read_error();
 	if (pos == 0)
-		pos = vfs_llseek(file, *_start, SEEK_DATA);
+		pos = vfs_llseek(file, start, SEEK_DATA);
 	if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
 		if (pos == -ENXIO)
 			goto check_space; /* Unallocated tail */
@@ -550,7 +556,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 					  cachefiles_trace_seek_error);
 		return pos;
 	}
-	if ((u64)pos >= (u64)*_start + *_len)
+	if (pos >= start + *_len)
 		goto check_space; /* Unallocated region */
 
 	/* We have a block that's at least partially filled - if we're low on
@@ -563,13 +569,13 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 
 	pos = cachefiles_inject_read_error();
 	if (pos == 0)
-		pos = vfs_llseek(file, *_start, SEEK_HOLE);
+		pos = vfs_llseek(file, start, SEEK_HOLE);
 	if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
 		trace_cachefiles_io_error(object, file_inode(file), pos,
 					  cachefiles_trace_seek_error);
 		return pos;
 	}
-	if ((u64)pos >= (u64)*_start + *_len)
+	if (pos >= start + *_len)
 		return 0; /* Fully allocated */
 
 	/* Partially allocated, but insufficient space: cull. */
@@ -577,7 +583,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 	ret = cachefiles_inject_remove_error();
 	if (ret == 0)
 		ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
-				    *_start, *_len);
+				    start, *_len);
 	if (ret < 0) {
 		trace_cachefiles_io_error(object, file_inode(file), ret,
 					  cachefiles_trace_fallocate_error);
author maintainer
#5 lore raw

PATCH 2/5 9p: Fix initialisation of netfs_inode for 9p

In reply to David Howells

The 9p filesystem is calling netfs_inode_init() in v9fs_init_inode() - before the struct inode fields have been initialised from the obtained file stats (ie. after v9fs_stat2inode*() has been called), but netfslib wants to set a couple of its fields from i_size.

---
 fs/9p/v9fs_vfs.h       | 1 +
 fs/9p/vfs_inode.c      | 6 +++---
 fs/9p/vfs_inode_dotl.c | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)
fs/9p/v9fs_vfs.h +1 -0
index 731e3d14b67d..0e8418066a48 100644
@@ -42,6 +42,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb);
 void v9fs_free_inode(struct inode *inode);
 struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode,
 			     dev_t rdev);
+void v9fs_set_netfs_context(struct inode *inode);
 int v9fs_init_inode(struct v9fs_session_info *v9ses,
 		    struct inode *inode, umode_t mode, dev_t rdev);
 void v9fs_evict_inode(struct inode *inode);
fs/9p/vfs_inode.c +3 -3
index b66466e97459..32572982f72e 100644
@@ -246,7 +246,7 @@ void v9fs_free_inode(struct inode *inode)
 /*
  * Set parameters for the netfs library
  */
-static void v9fs_set_netfs_context(struct inode *inode)
+void v9fs_set_netfs_context(struct inode *inode)
 {
 	struct v9fs_inode *v9inode = V9FS_I(inode);
 	netfs_inode_init(&v9inode->netfs, &v9fs_req_ops, true);
@@ -326,8 +326,6 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
 		err = -EINVAL;
 		goto error;
 	}
-
-	v9fs_set_netfs_context(inode);
 error:
 	return err;
 
@@ -359,6 +357,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev)
 		iput(inode);
 		return ERR_PTR(err);
 	}
+	v9fs_set_netfs_context(inode);
 	return inode;
 }
 
@@ -461,6 +460,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
 		goto error;
 
 	v9fs_stat2inode(st, inode, sb, 0);
+	v9fs_set_netfs_context(inode);
 	v9fs_cache_inode_get_cookie(inode);
 	unlock_new_inode(inode);
 	return inode;
fs/9p/vfs_inode_dotl.c +1 -0
index e25fbc988f09..3505227e1704 100644
@@ -128,6 +128,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
 		goto error;
 
 	v9fs_stat2inode_dotl(st, inode, 0);
+	v9fs_set_netfs_context(inode);
 	v9fs_cache_inode_get_cookie(inode);
 	retval = v9fs_get_acl(inode, fid);
 	if (retval)
author maintainer
#6 lore raw

PATCH 3/5 9p: Do a couple of cleanups

In reply to David Howells

Do a couple of cleanups to 9p:

(1) Remove a couple of unused variables.

(2) Turn a BUG_ON() into a warning, consolidate with another warning and make the warning message include the inode number rather than whatever's in i_private (which will get hashed anyway).

---
 fs/9p/vfs_addr.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
fs/9p/vfs_addr.c +9 -8
index d8fb407189a0..f7f83eec3bcc 100644
@@ -28,8 +28,6 @@
 
 static void v9fs_upload_to_server(struct netfs_io_subrequest *subreq)
 {
-	struct inode *inode = subreq->rreq->inode;
-	struct v9fs_inode __maybe_unused *v9inode = V9FS_I(inode);
 	struct p9_fid *fid = subreq->rreq->netfs_priv;
 	int err;
 
@@ -98,15 +96,13 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
 
 	if (file) {
 		fid = file->private_data;
-		BUG_ON(!fid);
+		if (!fid)
+			goto no_fid;
 		p9_fid_get(fid);
 	} else {
 		fid = v9fs_fid_find_inode(rreq->inode, writing, INVALID_UID, true);
-		if (!fid) {
-			WARN_ONCE(1, "folio expected an open fid inode->i_private=%p\n",
-				  rreq->inode->i_private);
-			return -EINVAL;
-		}
+		if (!fid)
+			goto no_fid;
 	}
 
 	/* we might need to read from a fid that was opened write-only
@@ -115,6 +111,11 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
 	WARN_ON(rreq->origin == NETFS_READ_FOR_WRITE && !(fid->mode & P9_ORDWR));
 	rreq->netfs_priv = fid;
 	return 0;
+
+no_fid:
+	WARN_ONCE(1, "folio expected an open fid inode->i_ino=%lx\n",
+		  rreq->inode->i_ino);
+	return -EINVAL;
 }
 
 /**
author maintainer
#8 lore raw

PATCH 4/5 9p: Always update remote_i_size in stat2inode

In reply to David Howells

Always update remote_i_size in v9fs_stat2inode*() if the size is available, even if we are asked not to update i_isize

---
 fs/9p/vfs_inode_dotl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/9p/vfs_inode_dotl.c +3 -3
index 3505227e1704..aa3a77bb5e86 100644
@@ -684,10 +684,10 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
 			mode |= inode->i_mode & ~S_IALLUGO;
 			inode->i_mode = mode;
 		}
-		if (!(flags & V9FS_STAT2INODE_KEEP_ISIZE) &&
-		    stat->st_result_mask & P9_STATS_SIZE) {
+		if (stat->st_result_mask & P9_STATS_SIZE) {
 			v9inode->netfs.remote_i_size = stat->st_size;
-			v9fs_i_size_write(inode, stat->st_size);
+			if (!(flags & V9FS_STAT2INODE_KEEP_ISIZE))
+				v9fs_i_size_write(inode, stat->st_size);
 		}
 		if (stat->st_result_mask & P9_STATS_BLOCKS)
 			inode->i_blocks = stat->st_blocks;
author maintainer
#10 lore raw

PATCH 5/5 9p: Use length of data written to the server in preference to error

In reply to David Howells

In v9fs_upload_to_server(), we pass the error to netfslib to terminate the subreq rather than the amount of data written - even if we did actually write something.

Further, we assume that the write is always entirely done if successful - but it might have been partially complete - as returned by p9_client_write(), but we ignore that.

Fix this by indicating the amount written by preference and only returning the error if we didn't write anything.

(We might want to return both in future if both are available as this might be useful as to whether we retry or not.)

---
 fs/9p/vfs_addr.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
fs/9p/vfs_addr.c +3 -4
index f7f83eec3bcc..047855033d32 100644
@@ -29,12 +29,11 @@
 static void v9fs_upload_to_server(struct netfs_io_subrequest *subreq)
 {
 	struct p9_fid *fid = subreq->rreq->netfs_priv;
-	int err;
+	int err, len;
 
 	trace_netfs_sreq(subreq, netfs_sreq_trace_submit);
-	p9_client_write(fid, subreq->start, &subreq->io_iter, &err);
-	netfs_write_subrequest_terminated(subreq, err < 0 ? err : subreq->len,
-					  false);
+	len = p9_client_write(fid, subreq->start, &subreq->io_iter, &err);
+	netfs_write_subrequest_terminated(subreq, len ?: err, false);
 }
 
 static void v9fs_upload_to_server_worker(struct work_struct *work)
author maintainer
#12 lore raw

[PATCH 6/5] netfs: Rearrange netfs_io_subrequest to put request pointer first

In reply to David Howells

netfs: Rearrange netfs_io_subrequest to put request pointer first

Rearrange the netfs_io_subrequest struct to put the netfs_io_request pointer (rreq) first. This then allows netfs_io_subrequest to be put in a union with a pointer to a wrapper around netfs_io_request. This will be useful in the future for cifs and maybe ceph.

---
 include/linux/netfs.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/netfs.h +1 -1
index 852956aa3c4b..d3bac60fcd6f 100644
@@ -204,8 +204,8 @@ struct netfs_cache_resources {
  * the pages it points to can be relied on to exist for the duration.
  */
 struct netfs_io_subrequest {
-	struct work_struct	work;
 	struct netfs_io_request *rreq;		/* Supervising I/O request */
+	struct work_struct	work;
 	struct list_head	rreq_link;	/* Link in rreq->subrequests */
 	struct iov_iter		io_iter;	/* Iterator for this subrequest */
 	loff_t			start;		/* Where to start the I/O */
#9 lore raw

Re: [PATCH 4/5] 9p: Always update remote_i_size in stat2inode

In reply to David Howells

David Howells wrote on Wed, Jan 03, 2024 at 02:59:28PM +0000:

Quoted 2 lines

Always update remote_i_size in v9fs_stat2inode*() if the size is available, even if we are asked not to update i_isize

Sorry -- hold on for this patch, let's drop it for now and take it more slowly through next cycle.

I had mostly forgotten about V9FS_STAT2INODE_KEEP_ISIZE and not paying enough attention yesterday evening, but it's not innocent -- I assume netfs will do the right thing if we update the *remote* i_size when there is cached data, but the inode's i_size cannot be updated as easily.

It's hard to notice because the comment got split in 5e3cc1ee1405a7 ("9p: use inode->i_lock to protect i_size_write() under 32-bit"), but v9fs_refresh_inode* still have it:
/*
* We don't want to refresh inode->i_size,
* because we may have cached data
*/

I assume refreshing i_size at a bad time would act like a truncation of cached memory.

(To answer the other thread's comment that v9fs_i_size_write is useless; it's far from obvious enough but I'm afraid it is needed:
- include/linux/fs.h has a comment saying i_size_write does need locking around it for 32bit to avoid breaking i_size_seqcount; that's still true in today's tree.
- we could use any lock as long as it's coherent within the 9p subsystem, but we don't need a whole mutex so i_lock it is.)

Signature · 1 line
Dominique Martinet | Asmadeus
maintainer Acked-by on v1 3/5
#7 lore raw

Re: [PATCH 3/5] 9p: Do a couple of cleanups

In reply to David Howells

David Howells wrote on Wed, Jan 03, 2024 at 02:59:27PM +0000:

Quoted 9 lines

Do a couple of cleanups to 9p:

(1) Remove a couple of unused variables.

(2) Turn a BUG_ON() into a warning, consolidate with another warning and make the warning message include the inode number rather than whatever's in i_private (which will get hashed anyway).

Thanks,

Signature · 1 line
Dominique Martinet | Asmadeus
maintainer Acked-by on v1 5/5
#11 lore raw

Re: [PATCH 5/5] 9p: Use length of data written to the server in preference to error

In reply to David Howells

David Howells wrote on Wed, Jan 03, 2024 at 02:59:29PM +0000:

Quoted 8 lines

In v9fs_upload_to_server(), we pass the error to netfslib to terminate the subreq rather than the amount of data written - even if we did actually write something.

Further, we assume that the write is always entirely done if successful - but it might have been partially complete - as returned by p9_client_write(), but we ignore that.

Quoted 7 lines

Fix this by indicating the amount written by preference and only returning the error if we didn't write anything.

(We might want to return both in future if both are available as this might be useful as to whether we retry or not.)

Thanks,

Signature · 1 line
Dominique Martinet | Asmadeus
author maintainer
#13 lore raw

[PATCH 7/5] netfs: Fix proc/fs/fscache symlink to point to "netfs" not "../netfs"

In reply to David Howells

Fix the proc/fs/fscache symlink to point to "netfs" not "../netfs".

---
 fs/netfs/fscache_proc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/netfs/fscache_proc.c +1 -1
index ecd0d1edafaa..874d951bc390 100644
@@ -16,7 +16,7 @@
  */
 int __init fscache_proc_init(void)
 {
-	if (!proc_symlink("fs/fscache", NULL, "../netfs"))
+	if (!proc_symlink("fs/fscache", NULL, "netfs"))
 		goto error_sym;
 
 	if (!proc_create_seq("fs/netfs/caches", S_IFREG | 0444, NULL,
#14 lore raw
In reply to David Howells
Quoted 19 lines · David Howells

Hi Christian, Jeff, Gao, Dominique,

Here are some additional patches for my netfs-lib tree:

(1) Fix __cachefiles_prepare_write() to correctly validate against the DIO alignment.

(2) 9p: Fix initialisation of the netfs_inode so that i_size is set before netfs_inode_init() is called.

(3) 9p: Do a couple of cleanups (remove a couple of unused vars and turn a BUG_ON() into a warning).

(4) 9p: Always update remote_i_size, even if we're asked not to update i_size in stat2inode.

(5) 9p: Return the amount written in preference to an error if we wrote something.

Quoted 8 lines

David

The netfslib postings:

Pulled this into vfs.netfs. Thanks, David.

reviewer
#2 lore raw

Re: [PATCH 1/5] cachefiles: Fix __cachefiles_prepare_write()

In reply to David Howells
Quoted 50 lines · David Howells

Fix __cachefiles_prepare_write() to correctly determine whether the requested write will fit correctly with the DIO alignment.

---
 fs/cachefiles/io.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
fs/cachefiles/io.c +12 -6
index bffffedce4a9..7529b40bc95a 100644
@@ -522,16 +522,22 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 			       bool no_space_allocated_yet)
 {
 	struct cachefiles_cache *cache = object->volume->cache;
-	loff_t start = *_start, pos;
-	size_t len = *_len, down;
+	unsigned long long start = *_start, pos;
+	size_t len = *_len;
 	int ret;
 
 	/* Round to DIO size */
-	down = start - round_down(start, PAGE_SIZE);
-	*_start = start - down;
-	*_len = round_up(down + len, PAGE_SIZE);
-	if (down < start || *_len > upper_len)
+	start = round_down(*_start, PAGE_SIZE);
+	if (start != *_start) {
+		kleave(" = -ENOBUFS [down]");
+		return -ENOBUFS;
+	}
+	if (*_len > upper_len) {
+		kleave(" = -ENOBUFS [up]");
 		return -ENOBUFS;
+	}
+
+	*_len = round_up(len, PAGE_SIZE);
 
 	/* We need to work out whether there's sufficient disk space to perform
 	 * the write - but we can skip that check if we have space already

fs/cachefiles/io.c int __cachefiles_prepare_write(struct cachefiles_object *object, · line 552

Quoted 6 lines
fs/cachefiles/io.c +1 -1
@@ -542,7 +548,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 
 	pos = cachefiles_inject_read_error();
 	if (pos == 0)
-		pos = vfs_llseek(file, *_start, SEEK_DATA);
+		pos = vfs_llseek(file, start, SEEK_DATA);
 	if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {

Hi David,

I realise these patches have been accepted, but I have a minor nit:
pos is now unsigned, and so cannot be less than zero.

Flagged by Smatch and Coccinelle.

Quoted 12 lines
fs/cachefiles/io.c +1 -1
 		if (pos == -ENXIO)
 			goto check_space; /* Unallocated tail */
@@ -550,7 +556,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 					  cachefiles_trace_seek_error);
 		return pos;
 	}
-	if ((u64)pos >= (u64)*_start + *_len)
+	if (pos >= start + *_len)
 		goto check_space; /* Unallocated region */
 
 	/* We have a block that's at least partially filled - if we're low on

fs/cachefiles/io.c int __cachefiles_prepare_write(struct cachefiles_object *object, · line 573

Quoted 6 lines
fs/cachefiles/io.c +1 -1
@@ -563,13 +569,13 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 
 	pos = cachefiles_inject_read_error();
 	if (pos == 0)
-		pos = vfs_llseek(file, *_start, SEEK_HOLE);
+		pos = vfs_llseek(file, start, SEEK_HOLE);
 	if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {

Ditto.

Quoted 19 lines
fs/cachefiles/io.c +2 -2
 		trace_cachefiles_io_error(object, file_inode(file), pos,
 					  cachefiles_trace_seek_error);
 		return pos;
 	}
-	if ((u64)pos >= (u64)*_start + *_len)
+	if (pos >= start + *_len)
 		return 0; /* Fully allocated */
 
 	/* Partially allocated, but insufficient space: cull. */
@@ -577,7 +583,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 	ret = cachefiles_inject_remove_error();
 	if (ret == 0)
 		ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
-				    *_start, *_len);
+				    start, *_len);
 	if (ret < 0) {
 		trace_cachefiles_io_error(object, file_inode(file), ret,
 					  cachefiles_trace_fallocate_error);
author maintainer
#3 lore raw

Re: [PATCH 1/5] cachefiles: Fix __cachefiles_prepare_write()

Quoted 2 lines · Simon Horman

I realise these patches have been accepted, but I have a minor nit:
pos is now unsigned, and so cannot be less than zero.

Good point. How about the attached patch. Whilst I would prefer to use unsigned long long to avoid the casts, it might

David
---
cachefiles: Fix signed/unsigned mixup

In __cachefiles_prepare_write(), the start and pos variables were made unsigned 64-bit so that the casts in the checking could be got rid of - which should be fine since absolute file offsets can't be negative, except that an error code may be obtained from vfs_llseek(), which *would* be negative. This breaks the error check.

Fix this for now by reverting pos and start to be signed and putting back the casts. Unfortunately, the error value checks cannot be replaced with IS_ERR_VALUE() as long might be 32-bits.

---
 fs/cachefiles/io.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/cachefiles/io.c +3 -3
index 3eec26967437..9a2cb2868e90 100644
@@ -522,7 +522,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 			       bool no_space_allocated_yet)
 {
 	struct cachefiles_cache *cache = object->volume->cache;
-	unsigned long long start = *_start, pos;
+	loff_t start = *_start, pos;
 	size_t len = *_len;
 	int ret;
 
@@ -556,7 +556,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 					  cachefiles_trace_seek_error);
 		return pos;
 	}
-	if (pos >= start + *_len)
+	if ((u64)pos >= (u64)start + *_len)
 		goto check_space; /* Unallocated region */
 
 	/* We have a block that's at least partially filled - if we're low on
@@ -575,7 +575,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 					  cachefiles_trace_seek_error);
 		return pos;
 	}
-	if (pos >= start + *_len)
+	if ((u64)pos >= (u64)start + *_len)
 		return 0; /* Fully allocated */
 
 	/* Partially allocated, but insufficient space: cull. */
reviewer Reviewed-by
#4 lore raw

Re: [PATCH 1/5] cachefiles: Fix __cachefiles_prepare_write()

Quoted 7 lines · David Howells
Quoted 2 lines · Simon Horman

I realise these patches have been accepted, but I have a minor nit:
pos is now unsigned, and so cannot be less than zero.

Good point. How about the attached patch. Whilst I would prefer to use unsigned long long to avoid the casts, it might

Hi David,

I would also prefer to avoid casts, but I agree this is a good way forward. Thanks for the quick fix.