From ee1235a9a06813429c201bf186397a6feeea07bf Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 4 Apr 2018 13:41:28 +0100 Subject: fscache: Pass object size in rather than calling back for it Pass the object size in to fscache_acquire_cookie() and fscache_write_page() rather than the netfs providing a callback by which it can be received. This makes it easier to update the size of the object when a new page is written that extends the object. The current object size is also passed by fscache to the check_aux function, obviating the need to store it in the aux data. Signed-off-by: David Howells Acked-by: Anna Schumaker Tested-by: Steve Dickson --- fs/afs/cache.c | 24 ++++-------------------- fs/afs/cell.c | 2 +- fs/afs/file.c | 6 ++++-- fs/afs/inode.c | 2 +- fs/afs/volume.c | 2 +- 5 files changed, 11 insertions(+), 25 deletions(-) (limited to 'fs/afs') diff --git a/fs/afs/cache.c b/fs/afs/cache.c index a16f1e024cf3..b1c31ec4523a 100644 --- a/fs/afs/cache.c +++ b/fs/afs/cache.c @@ -12,11 +12,10 @@ #include #include "internal.h" -static void afs_vnode_cache_get_attr(const void *cookie_netfs_data, - uint64_t *size); static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data, const void *buffer, - uint16_t buflen); + uint16_t buflen, + loff_t object_size); struct fscache_netfs afs_cache_netfs = { .name = "afs", @@ -36,31 +35,16 @@ struct fscache_cookie_def afs_volume_cache_index_def = { struct fscache_cookie_def afs_vnode_cache_index_def = { .name = "AFS.vnode", .type = FSCACHE_COOKIE_TYPE_DATAFILE, - .get_attr = afs_vnode_cache_get_attr, .check_aux = afs_vnode_cache_check_aux, }; -/* - * provide updated file attributes - */ -static void afs_vnode_cache_get_attr(const void *cookie_netfs_data, - uint64_t *size) -{ - const struct afs_vnode *vnode = cookie_netfs_data; - - _enter("{%x,%x,%llx},", - vnode->fid.vnode, vnode->fid.unique, - vnode->status.data_version); - - *size = vnode->status.size; -} - /* * check that the auxiliary data indicates that the entry is still valid */ static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data, const void *buffer, - uint16_t buflen) + uint16_t buflen, + loff_t object_size) { struct afs_vnode *vnode = cookie_netfs_data; struct afs_vnode_cache_aux aux; diff --git a/fs/afs/cell.c b/fs/afs/cell.c index 0747460221cb..4235a05afc76 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -524,7 +524,7 @@ static int afs_activate_cell(struct afs_net *net, struct afs_cell *cell) &afs_cell_cache_index_def, cell->name, strlen(cell->name), NULL, 0, - cell, true); + cell, 0, true); #endif ret = afs_proc_cell_setup(net, cell); if (ret < 0) diff --git a/fs/afs/file.c b/fs/afs/file.c index a39192ced99e..79e665a35fea 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -339,7 +339,8 @@ int afs_page_filler(void *data, struct page *page) /* send the page to the cache */ #ifdef CONFIG_AFS_FSCACHE if (PageFsCache(page) && - fscache_write_page(vnode->cache, page, GFP_KERNEL) != 0) { + fscache_write_page(vnode->cache, page, vnode->status.size, + GFP_KERNEL) != 0) { fscache_uncache_page(vnode->cache, page); BUG_ON(PageFsCache(page)); } @@ -403,7 +404,8 @@ static void afs_readpages_page_done(struct afs_call *call, struct afs_read *req) /* send the page to the cache */ #ifdef CONFIG_AFS_FSCACHE if (PageFsCache(page) && - fscache_write_page(vnode->cache, page, GFP_KERNEL) != 0) { + fscache_write_page(vnode->cache, page, vnode->status.size, + GFP_KERNEL) != 0) { fscache_uncache_page(vnode->cache, page); BUG_ON(PageFsCache(page)); } diff --git a/fs/afs/inode.c b/fs/afs/inode.c index e499713efd2e..65c5b1edd338 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -265,7 +265,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode) &afs_vnode_cache_index_def, &key, sizeof(key), &aux, sizeof(aux), - vnode, true); + vnode, vnode->status.size, true); #endif } diff --git a/fs/afs/volume.c b/fs/afs/volume.c index 345cb2d675d2..3037bd01f617 100644 --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -227,7 +227,7 @@ void afs_activate_volume(struct afs_volume *volume) &afs_volume_cache_index_def, &volume->vid, sizeof(volume->vid), NULL, 0, - volume, true); + volume, 0, true); #endif write_lock(&volume->cell->proc_lock); -- cgit v1.2.3-59-g8ed1b