[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <159465820921.1376674.16898427212445252830.stgit@warthog.procyon.org.uk>
Date: Mon, 13 Jul 2020 17:36:49 +0100
From: David Howells <dhowells@...hat.com>
To: Trond Myklebust <trondmy@...merspace.com>,
Anna Schumaker <anna.schumaker@...app.com>,
Steve French <sfrench@...ba.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Matthew Wilcox <willy@...radead.org>
Cc: Jeff Layton <jlayton@...hat.com>,
Dave Wysochanski <dwysocha@...hat.com>, dhowells@...hat.com,
linux-cachefs@...hat.com, 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: [PATCH 32/32] cachefiles: Shape write requests
In cachefiles_shape_extent(), shape a write request to always write to the
cache. The assumption is made that the caller has read the entire cache
granule beforehand if necessary.
Possibly this should be amended so that writes will only take place to
granules that are marked present and granules that lie beyond the EOF.
Signed-off-by: David Howells <dhowells@...hat.com>
---
fs/cachefiles/content-map.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/fs/cachefiles/content-map.c b/fs/cachefiles/content-map.c
index 3e310fd58497..592fc426500b 100644
--- a/fs/cachefiles/content-map.c
+++ b/fs/cachefiles/content-map.c
@@ -69,7 +69,8 @@ static void cachefiles_shape_single(struct fscache_object *obj,
shape->dio_block_size = CACHEFILES_DIO_BLOCK_SIZE;
- if (object->content_info == CACHEFILES_CONTENT_SINGLE) {
+ if (!shape->for_write &&
+ object->content_info == CACHEFILES_CONTENT_SINGLE) {
shape->to_be_done = FSCACHE_READ_FROM_CACHE;
} else {
eof = (shape->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -127,14 +128,20 @@ void cachefiles_shape_request(struct fscache_object *obj,
if (end - start > max_pages)
end = start + max_pages;
- /* If the content map didn't get expanded for some reason - simply
- * ignore this granule.
- */
granule = start / CACHEFILES_GRAN_PAGES;
- if (granule / 8 >= object->content_map_size)
- return;
+ if (granule / 8 >= object->content_map_size) {
+ cachefiles_expand_content_map(object, shape->i_size);
+ if (granule / 8 >= object->content_map_size)
+ return;
+ }
- if (cachefiles_granule_is_present(object, granule)) {
+ if (shape->for_write) {
+ /* Assume that the preparation to write involved preloading any
+ * bits of the cache that weren't to be written and filling any
+ * gaps that didn't end up being written.
+ */
+ shape->to_be_done = FSCACHE_WRITE_TO_CACHE;
+ } else if (cachefiles_granule_is_present(object, granule)) {
/* The start of the requested extent is present in the cache -
* restrict the returned extent to the maximum length of what's
* available.
Powered by blists - more mailing lists