lkml.org 
[lkml]   [2020]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC PATCH 46/61] cachefiles: Shape write requests
From
Date
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@redhat.com>
---

fs/cachefiles/content-map.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/fs/cachefiles/content-map.c b/fs/cachefiles/content-map.c
index 13632c097248..2c45092465b6 100644
--- a/fs/cachefiles/content-map.c
+++ b/fs/cachefiles/content-map.c
@@ -71,7 +71,8 @@ static unsigned int cachefiles_shape_single(struct fscache_object *obj,

extent->dio_block_size = CACHEFILES_DIO_BLOCK_SIZE;

- if (object->content_info == CACHEFILES_CONTENT_SINGLE) {
+ if (!for_write &&
+ object->content_info == CACHEFILES_CONTENT_SINGLE) {
ret = FSCACHE_READ_FROM_CACHE;
} else {
eof = (i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -128,13 +129,20 @@ unsigned int cachefiles_shape_extent(struct fscache_object *obj,

granule = start / CACHEFILES_GRAN_PAGES;

- /* If the content map didn't get expanded for some reason - simply
- * ignore this granule.
- */
- if (granule / 8 >= object->content_map_size)
- return 0;
+ if (granule / 8 >= object->content_map_size) {
+ cachefiles_expand_content_map(object, i_size);
+ if (granule / 8 >= object->content_map_size)
+ return 0;
+ }

- if (cachefiles_granule_is_present(object, granule)) {
+ if (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.
+ */
+ bend = end;
+ ret = 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.

\
 
 \ /
  Last update: 2020-05-04 19:14    [W:0.822 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site