[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <158861236514.340223.3729118853361763383.stgit@warthog.procyon.org.uk>
Date: Mon, 04 May 2020 18:12:45 +0100
From: David Howells <dhowells@...hat.com>
To: Trond Myklebust <trondmy@...merspace.com>,
Anna Schumaker <anna.schumaker@...app.com>,
Steve French <sfrench@...ba.org>,
Jeff Layton <jlayton@...hat.com>
Cc: dhowells@...hat.com, Matthew Wilcox <willy@...radead.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-afs@...ts.infradead.org, linux-nfs@...r.kernel.org,
linux-cifs@...r.kernel.org, ceph-devel@...r.kernel.org,
v9fs-developer@...ts.sourceforge.net,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [RFC PATCH 35/61] cachefiles: Round the cachefile size up to DIO
block size
Round the size of a cachefile up to DIO block size so that we can always
read back the last partial page of a file using direct I/O.
Signed-off-by: David Howells <dhowells@...hat.com>
---
fs/cachefiles/interface.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index d820051a9960..aa063857272a 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -184,6 +184,17 @@ static void cachefiles_update_object(struct fscache_object *_object)
cachefiles_remove_object_xattr(cache, object->dentry);
goto out;
}
+
+ object_size = round_up(object_size, CACHEFILES_DIO_BLOCK_SIZE);
+ _debug("trunc %llx -> %llx", i_size_read(d_inode(object->dentry)), object_size);
+ if (i_size_read(d_inode(object->dentry)) < object_size) {
+ ret = vfs_truncate(&path, object_size);
+ if (ret < 0) {
+ cachefiles_io_error_obj(object, "Trunc-to-dio-size failed");
+ cachefiles_remove_object_xattr(cache, object->dentry);
+ goto out;
+ }
+ }
}
cachefiles_set_object_xattr(object, XATTR_REPLACE);
@@ -358,6 +369,7 @@ static int cachefiles_attr_changed(struct cachefiles_object *object)
int ret;
ni_size = object->fscache.cookie->object_size;
+ ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE);
_enter("{OBJ%x},[%llu]",
object->fscache.debug_id, (unsigned long long) ni_size);
@@ -426,6 +438,7 @@ static void cachefiles_invalidate_object(struct fscache_object *_object)
struct cachefiles_cache, cache);
ni_size = object->fscache.cookie->object_size;
+ ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE);
_enter("{OBJ%x},[%llu]",
object->fscache.debug_id, (unsigned long long)ni_size);
Powered by blists - more mailing lists