Commit ee1235a9 authored by David Howells's avatar David Howells

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: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarAnna Schumaker <anna.schumaker@netapp.com>
Tested-by: default avatarSteve Dickson <steved@redhat.com>
parent 402cb8dd
...@@ -129,12 +129,10 @@ To define an object, a structure of the following type should be filled out: ...@@ -129,12 +129,10 @@ To define an object, a structure of the following type should be filled out:
const void *parent_netfs_data, const void *parent_netfs_data,
const void *cookie_netfs_data); const void *cookie_netfs_data);
void (*get_attr)(const void *cookie_netfs_data,
uint64_t *size);
enum fscache_checkaux (*check_aux)(void *cookie_netfs_data, enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
const void *data, const void *data,
uint16_t datalen); uint16_t datalen,
loff_t object_size);
void (*get_context)(void *cookie_netfs_data, void *context); void (*get_context)(void *cookie_netfs_data, void *context);
...@@ -179,16 +177,7 @@ This has the following fields: ...@@ -179,16 +177,7 @@ This has the following fields:
cache in the parent's list will be chosen, or failing that, the first cache in the parent's list will be chosen, or failing that, the first
cache in the master list. cache in the master list.
(4) A function to retrieve attribute data from the netfs [optional]. (4) A function to check the auxiliary data [optional].
This function will be called with the netfs data that was passed to the
cookie acquisition function. It should return the size of the file if
this is a data file. The size may be used to govern how much cache must
be reserved for this file in the cache.
If the function is absent, a file size of 0 is assumed.
(5) A function to check the auxiliary data [optional].
This function will be called to check that a match found in the cache for This function will be called to check that a match found in the cache for
this object is valid. For instance with AFS it could check the auxiliary this object is valid. For instance with AFS it could check the auxiliary
...@@ -198,6 +187,9 @@ This has the following fields: ...@@ -198,6 +187,9 @@ This has the following fields:
If this function is absent, it will be assumed that matching objects in a If this function is absent, it will be assumed that matching objects in a
cache are always valid. cache are always valid.
The function is also passed the cache's idea of the object size and may
use this to manage coherency also.
If present, the function should return one of the following values: If present, the function should return one of the following values:
(*) FSCACHE_CHECKAUX_OKAY - the entry is okay as is (*) FSCACHE_CHECKAUX_OKAY - the entry is okay as is
...@@ -207,7 +199,7 @@ This has the following fields: ...@@ -207,7 +199,7 @@ This has the following fields:
This function can also be used to extract data from the auxiliary data in This function can also be used to extract data from the auxiliary data in
the cache and copy it into the netfs's structures. the cache and copy it into the netfs's structures.
(6) A pair of functions to manage contexts for the completion callback (5) A pair of functions to manage contexts for the completion callback
[optional]. [optional].
The cache read/write functions are passed a context which is then passed The cache read/write functions are passed a context which is then passed
...@@ -221,7 +213,7 @@ This has the following fields: ...@@ -221,7 +213,7 @@ This has the following fields:
required for indices as indices may not contain data. These functions may required for indices as indices may not contain data. These functions may
be called in interrupt context and so may not sleep. be called in interrupt context and so may not sleep.
(7) A function to mark a page as retaining cache metadata [optional]. (6) A function to mark a page as retaining cache metadata [optional].
This is called by the cache to indicate that it is retaining in-memory This is called by the cache to indicate that it is retaining in-memory
information for this page and that the netfs should uncache the page when information for this page and that the netfs should uncache the page when
...@@ -233,7 +225,7 @@ This has the following fields: ...@@ -233,7 +225,7 @@ This has the following fields:
This function is not required for indices as they're not permitted data. This function is not required for indices as they're not permitted data.
(8) A function to unmark all the pages retaining cache metadata [mandatory]. (7) A function to unmark all the pages retaining cache metadata [mandatory].
This is called by FS-Cache to indicate that a backing store is being This is called by FS-Cache to indicate that a backing store is being
unbound from a cookie and that all the marks on the pages should be unbound from a cookie and that all the marks on the pages should be
...@@ -310,6 +302,7 @@ the path to the file: ...@@ -310,6 +302,7 @@ the path to the file:
const void *aux_data, const void *aux_data,
size_t aux_data_len, size_t aux_data_len,
void *netfs_data, void *netfs_data,
loff_t object_size,
bool enable); bool enable);
This function creates an index entry in the index represented by parent, This function creates an index entry in the index represented by parent,
...@@ -326,6 +319,10 @@ The netfs may pass an arbitrary value in netfs_data and this will be presented ...@@ -326,6 +319,10 @@ The netfs may pass an arbitrary value in netfs_data and this will be presented
to it in the event of any calling back. This may also be used in tracing or to it in the event of any calling back. This may also be used in tracing or
logging of messages. logging of messages.
The cache tracks the size of the data attached to an object and this set to be
object_size. For indices, this should be 0. This value will be passed to the
->check_aux() callback.
Note that this function never returns an error - all errors are handled Note that this function never returns an error - all errors are handled
internally. It may, however, return NULL to indicate no cookie. It is quite internally. It may, however, return NULL to indicate no cookie. It is quite
acceptable to pass this token back to this function as the parent to another acceptable to pass this token back to this function as the parent to another
...@@ -349,7 +346,7 @@ entry would have a dependent inode containing volume mappings within this cell: ...@@ -349,7 +346,7 @@ entry would have a dependent inode containing volume mappings within this cell:
&afs_cell_cache_index_def, &afs_cell_cache_index_def,
cell->name, strlen(cell->name), cell->name, strlen(cell->name),
NULL, 0, NULL, 0,
cell, true); cell, 0, true);
And then a particular volume could be added to that index by ID, creating And then a particular volume could be added to that index by ID, creating
another index for vnodes (AFS inode equivalents): another index for vnodes (AFS inode equivalents):
...@@ -359,7 +356,7 @@ another index for vnodes (AFS inode equivalents): ...@@ -359,7 +356,7 @@ another index for vnodes (AFS inode equivalents):
&afs_volume_cache_index_def, &afs_volume_cache_index_def,
&volume->vid, sizeof(volume->vid), &volume->vid, sizeof(volume->vid),
NULL, 0, NULL, 0,
volume, true); volume, 0, true);
====================== ======================
...@@ -375,7 +372,7 @@ the object definition should be something other than index type. ...@@ -375,7 +372,7 @@ the object definition should be something other than index type.
&afs_vnode_cache_object_def, &afs_vnode_cache_object_def,
&key, sizeof(key), &key, sizeof(key),
&aux, sizeof(aux), &aux, sizeof(aux),
vnode, true); vnode, vnode->status.size, true);
================================= =================================
...@@ -393,7 +390,7 @@ it would be some other type of object such as a data file. ...@@ -393,7 +390,7 @@ it would be some other type of object such as a data file.
&afs_xattr_cache_object_def, &afs_xattr_cache_object_def,
&xattr->name, strlen(xattr->name), &xattr->name, strlen(xattr->name),
NULL, 0, NULL, 0,
xattr, true); xattr, strlen(xattr->val), true);
Miscellaneous objects might be used to store extended attributes or directory Miscellaneous objects might be used to store extended attributes or directory
entries for example. entries for example.
...@@ -410,8 +407,7 @@ cache to adjust its metadata for data tracking appropriately: ...@@ -410,8 +407,7 @@ cache to adjust its metadata for data tracking appropriately:
int fscache_attr_changed(struct fscache_cookie *cookie); int fscache_attr_changed(struct fscache_cookie *cookie);
The cache will return -ENOBUFS if there is no backing cache or if there is no The cache will return -ENOBUFS if there is no backing cache or if there is no
space to allocate any extra metadata required in the cache. The attributes space to allocate any extra metadata required in the cache.
will be accessed with the get_attr() cookie definition operation.
Note that attempts to read or write data pages in the cache over this size may Note that attempts to read or write data pages in the cache over this size may
be rebuffed with -ENOBUFS. be rebuffed with -ENOBUFS.
...@@ -536,12 +532,13 @@ written back to the cache: ...@@ -536,12 +532,13 @@ written back to the cache:
int fscache_write_page(struct fscache_cookie *cookie, int fscache_write_page(struct fscache_cookie *cookie,
struct page *page, struct page *page,
loff_t object_size,
gfp_t gfp); gfp_t gfp);
The cookie argument must specify a data file cookie, the page specified should The cookie argument must specify a data file cookie, the page specified should
contain the data to be written (and is also used to specify the page number), contain the data to be written (and is also used to specify the page number),
and the gfp argument is used to control how any memory allocations made are object_size is the revised size of the object and the gfp argument is used to
satisfied. control how any memory allocations made are satisfied.
The page must have first been read or allocated successfully and must not have The page must have first been read or allocated successfully and must not have
been uncached before writing is performed. been uncached before writing is performed.
...@@ -753,6 +750,7 @@ Cookies can be enabled or reenabled with: ...@@ -753,6 +750,7 @@ Cookies can be enabled or reenabled with:
void fscache_enable_cookie(struct fscache_cookie *cookie, void fscache_enable_cookie(struct fscache_cookie *cookie,
const void *aux_data, const void *aux_data,
loff_t object_size,
bool (*can_enable)(void *data), bool (*can_enable)(void *data),
void *data) void *data)
...@@ -766,6 +764,9 @@ ruling as to whether or not enablement should actually be permitted to begin. ...@@ -766,6 +764,9 @@ ruling as to whether or not enablement should actually be permitted to begin.
All possible failures are handled internally. The cookie will only be marked All possible failures are handled internally. The cookie will only be marked
as enabled if provisional backing objects are allocated. as enabled if provisional backing objects are allocated.
The object's data size is updated from object_size and is passed to the
->check_aux() function.
In both cases, the cookie's auxiliary data buffer is updated from aux_data if In both cases, the cookie's auxiliary data buffer is updated from aux_data if
that is non-NULL inside the enablement lock before proceeding. that is non-NULL inside the enablement lock before proceeding.
......
...@@ -75,7 +75,7 @@ void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses) ...@@ -75,7 +75,7 @@ void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses)
v9ses->cachetag, v9ses->cachetag,
strlen(v9ses->cachetag), strlen(v9ses->cachetag),
NULL, 0, NULL, 0,
v9ses, true); v9ses, 0, true);
p9_debug(P9_DEBUG_FSC, "session %p get cookie %p\n", p9_debug(P9_DEBUG_FSC, "session %p get cookie %p\n",
v9ses, v9ses->fscache); v9ses, v9ses->fscache);
} }
...@@ -88,20 +88,11 @@ void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses) ...@@ -88,20 +88,11 @@ void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses)
v9ses->fscache = NULL; v9ses->fscache = NULL;
} }
static void v9fs_cache_inode_get_attr(const void *cookie_netfs_data,
uint64_t *size)
{
const struct v9fs_inode *v9inode = cookie_netfs_data;
*size = i_size_read(&v9inode->vfs_inode);
p9_debug(P9_DEBUG_FSC, "inode %p get attr %llu\n",
&v9inode->vfs_inode, *size);
}
static enum static enum
fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data, fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data,
const void *buffer, const void *buffer,
uint16_t buflen) uint16_t buflen,
loff_t object_size)
{ {
const struct v9fs_inode *v9inode = cookie_netfs_data; const struct v9fs_inode *v9inode = cookie_netfs_data;
...@@ -118,7 +109,6 @@ fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data, ...@@ -118,7 +109,6 @@ fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data,
const struct fscache_cookie_def v9fs_cache_inode_index_def = { const struct fscache_cookie_def v9fs_cache_inode_index_def = {
.name = "9p.inode", .name = "9p.inode",
.type = FSCACHE_COOKIE_TYPE_DATAFILE, .type = FSCACHE_COOKIE_TYPE_DATAFILE,
.get_attr = v9fs_cache_inode_get_attr,
.check_aux = v9fs_cache_inode_check_aux, .check_aux = v9fs_cache_inode_check_aux,
}; };
...@@ -141,7 +131,9 @@ void v9fs_cache_inode_get_cookie(struct inode *inode) ...@@ -141,7 +131,9 @@ void v9fs_cache_inode_get_cookie(struct inode *inode)
sizeof(v9inode->qid.path), sizeof(v9inode->qid.path),
&v9inode->qid.version, &v9inode->qid.version,
sizeof(v9inode->qid.version), sizeof(v9inode->qid.version),
v9inode, true); v9inode,
i_size_read(&v9inode->vfs_inode),
true);
p9_debug(P9_DEBUG_FSC, "inode %p get cookie %p\n", p9_debug(P9_DEBUG_FSC, "inode %p get cookie %p\n",
inode, v9inode->fscache); inode, v9inode->fscache);
...@@ -212,7 +204,9 @@ void v9fs_cache_inode_reset_cookie(struct inode *inode) ...@@ -212,7 +204,9 @@ void v9fs_cache_inode_reset_cookie(struct inode *inode)
sizeof(v9inode->qid.path), sizeof(v9inode->qid.path),
&v9inode->qid.version, &v9inode->qid.version,
sizeof(v9inode->qid.version), sizeof(v9inode->qid.version),
v9inode, true); v9inode,
i_size_read(&v9inode->vfs_inode),
true);
p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n", p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n",
inode, old, v9inode->fscache); inode, old, v9inode->fscache);
...@@ -338,7 +332,8 @@ void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page) ...@@ -338,7 +332,8 @@ void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page)
const struct v9fs_inode *v9inode = V9FS_I(inode); const struct v9fs_inode *v9inode = V9FS_I(inode);
p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page); p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page);
ret = fscache_write_page(v9inode->fscache, page, GFP_KERNEL); ret = fscache_write_page(v9inode->fscache, page,
i_size_read(&v9inode->vfs_inode), GFP_KERNEL);
p9_debug(P9_DEBUG_FSC, "ret = %d\n", ret); p9_debug(P9_DEBUG_FSC, "ret = %d\n", ret);
if (ret != 0) if (ret != 0)
v9fs_uncache_page(inode, page); v9fs_uncache_page(inode, page);
......
...@@ -12,11 +12,10 @@ ...@@ -12,11 +12,10 @@
#include <linux/sched.h> #include <linux/sched.h>
#include "internal.h" #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, static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
const void *buffer, const void *buffer,
uint16_t buflen); uint16_t buflen,
loff_t object_size);
struct fscache_netfs afs_cache_netfs = { struct fscache_netfs afs_cache_netfs = {
.name = "afs", .name = "afs",
...@@ -36,31 +35,16 @@ struct fscache_cookie_def afs_volume_cache_index_def = { ...@@ -36,31 +35,16 @@ struct fscache_cookie_def afs_volume_cache_index_def = {
struct fscache_cookie_def afs_vnode_cache_index_def = { struct fscache_cookie_def afs_vnode_cache_index_def = {
.name = "AFS.vnode", .name = "AFS.vnode",
.type = FSCACHE_COOKIE_TYPE_DATAFILE, .type = FSCACHE_COOKIE_TYPE_DATAFILE,
.get_attr = afs_vnode_cache_get_attr,
.check_aux = afs_vnode_cache_check_aux, .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 * 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, static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
const void *buffer, const void *buffer,
uint16_t buflen) uint16_t buflen,
loff_t object_size)
{ {
struct afs_vnode *vnode = cookie_netfs_data; struct afs_vnode *vnode = cookie_netfs_data;
struct afs_vnode_cache_aux aux; struct afs_vnode_cache_aux aux;
......
...@@ -524,7 +524,7 @@ static int afs_activate_cell(struct afs_net *net, struct afs_cell *cell) ...@@ -524,7 +524,7 @@ static int afs_activate_cell(struct afs_net *net, struct afs_cell *cell)
&afs_cell_cache_index_def, &afs_cell_cache_index_def,
cell->name, strlen(cell->name), cell->name, strlen(cell->name),
NULL, 0, NULL, 0,
cell, true); cell, 0, true);
#endif #endif
ret = afs_proc_cell_setup(net, cell); ret = afs_proc_cell_setup(net, cell);
if (ret < 0) if (ret < 0)
......
...@@ -339,7 +339,8 @@ int afs_page_filler(void *data, struct page *page) ...@@ -339,7 +339,8 @@ int afs_page_filler(void *data, struct page *page)
/* send the page to the cache */ /* send the page to the cache */
#ifdef CONFIG_AFS_FSCACHE #ifdef CONFIG_AFS_FSCACHE
if (PageFsCache(page) && 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); fscache_uncache_page(vnode->cache, page);
BUG_ON(PageFsCache(page)); BUG_ON(PageFsCache(page));
} }
...@@ -403,7 +404,8 @@ static void afs_readpages_page_done(struct afs_call *call, struct afs_read *req) ...@@ -403,7 +404,8 @@ static void afs_readpages_page_done(struct afs_call *call, struct afs_read *req)
/* send the page to the cache */ /* send the page to the cache */
#ifdef CONFIG_AFS_FSCACHE #ifdef CONFIG_AFS_FSCACHE
if (PageFsCache(page) && 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); fscache_uncache_page(vnode->cache, page);
BUG_ON(PageFsCache(page)); BUG_ON(PageFsCache(page));
} }
......
...@@ -265,7 +265,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode) ...@@ -265,7 +265,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode)
&afs_vnode_cache_index_def, &afs_vnode_cache_index_def,
&key, sizeof(key), &key, sizeof(key),
&aux, sizeof(aux), &aux, sizeof(aux),
vnode, true); vnode, vnode->status.size, true);
#endif #endif
} }
......
...@@ -227,7 +227,7 @@ void afs_activate_volume(struct afs_volume *volume) ...@@ -227,7 +227,7 @@ void afs_activate_volume(struct afs_volume *volume)
&afs_volume_cache_index_def, &afs_volume_cache_index_def,
&volume->vid, sizeof(volume->vid), &volume->vid, sizeof(volume->vid),
NULL, 0, NULL, 0,
volume, true); volume, 0, true);
#endif #endif
write_lock(&volume->cell->proc_lock); write_lock(&volume->cell->proc_lock);
......
...@@ -441,7 +441,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object) ...@@ -441,7 +441,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
loff_t oi_size; loff_t oi_size;
int ret; int ret;
_object->cookie->def->get_attr(_object->cookie->netfs_data, &ni_size); ni_size = _object->store_limit_l;
_enter("{OBJ%x},[%llu]", _enter("{OBJ%x},[%llu]",
_object->debug_id, (unsigned long long) ni_size); _object->debug_id, (unsigned long long) ni_size);
...@@ -513,8 +513,7 @@ static void cachefiles_invalidate_object(struct fscache_operation *op) ...@@ -513,8 +513,7 @@ static void cachefiles_invalidate_object(struct fscache_operation *op)
cache = container_of(object->fscache.cache, cache = container_of(object->fscache.cache,
struct cachefiles_cache, cache); struct cachefiles_cache, cache);
op->object->cookie->def->get_attr(op->object->cookie->netfs_data, ni_size = op->object->store_limit_l;
&ni_size);
_enter("{OBJ%x},[%llu]", _enter("{OBJ%x},[%llu]",
op->object->debug_id, (unsigned long long)ni_size); op->object->debug_id, (unsigned long long)ni_size);
......
...@@ -182,7 +182,8 @@ int cachefiles_check_auxdata(struct cachefiles_object *object) ...@@ -182,7 +182,8 @@ int cachefiles_check_auxdata(struct cachefiles_object *object)
goto error; goto error;
xlen--; xlen--;
validity = fscache_check_aux(&object->fscache, &auxbuf->data, xlen); validity = fscache_check_aux(&object->fscache, &auxbuf->data, xlen,
i_size_read(d_backing_inode(dentry)));
if (validity != FSCACHE_CHECKAUX_OKAY) if (validity != FSCACHE_CHECKAUX_OKAY)
goto error; goto error;
...@@ -251,7 +252,8 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object, ...@@ -251,7 +252,8 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object,
object->fscache.cookie->def->name, dlen); object->fscache.cookie->def->name, dlen);
result = fscache_check_aux(&object->fscache, result = fscache_check_aux(&object->fscache,
&auxbuf->data, dlen); &auxbuf->data, dlen,
i_size_read(d_backing_inode(dentry)));
switch (result) { switch (result) {
/* entry okay as is */ /* entry okay as is */
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
struct ceph_aux_inode { struct ceph_aux_inode {
u64 version; u64 version;
struct timespec mtime; struct timespec mtime;
loff_t size;
}; };
struct fscache_netfs ceph_cache_netfs = { struct fscache_netfs ceph_cache_netfs = {
...@@ -101,7 +100,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc) ...@@ -101,7 +100,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc)
&ceph_fscache_fsid_object_def, &ceph_fscache_fsid_object_def,
&ent->fsid, sizeof(ent->fsid) + uniq_len, &ent->fsid, sizeof(ent->fsid) + uniq_len,
NULL, 0, NULL, 0,
fsc, true); fsc, 0, true);
if (fsc->fscache) { if (fsc->fscache) {
ent->fscache = fsc->fscache; ent->fscache = fsc->fscache;
...@@ -117,27 +116,21 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc) ...@@ -117,27 +116,21 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc)
return err; return err;
} }
static void ceph_fscache_inode_get_attr(const void *cookie_netfs_data,
uint64_t *size)
{
const struct ceph_inode_info* ci = cookie_netfs_data;
*size = i_size_read(&ci->vfs_inode);
}
static enum fscache_checkaux ceph_fscache_inode_check_aux( static enum fscache_checkaux ceph_fscache_inode_check_aux(
void *cookie_netfs_data, const void *data, uint16_t dlen) void *cookie_netfs_data, const void *data, uint16_t dlen,
loff_t object_size)
{ {
struct ceph_aux_inode aux; struct ceph_aux_inode aux;
struct ceph_inode_info* ci = cookie_netfs_data; struct ceph_inode_info* ci = cookie_netfs_data;
struct inode* inode = &ci->vfs_inode; struct inode* inode = &ci->vfs_inode;
if (dlen != sizeof(aux)) if (dlen != sizeof(aux) ||
i_size_read(inode) != object_size)
return FSCACHE_CHECKAUX_OBSOLETE; return FSCACHE_CHECKAUX_OBSOLETE;
memset(&aux, 0, sizeof(aux)); memset(&aux, 0, sizeof(aux));
aux.version = ci->i_version; aux.version = ci->i_version;
aux.mtime = inode->i_mtime; aux.mtime = inode->i_mtime;
aux.size = i_size_read(inode);
if (memcmp(data, &aux, sizeof(aux)) != 0) if (memcmp(data, &aux, sizeof(aux)) != 0)
return FSCACHE_CHECKAUX_OBSOLETE; return FSCACHE_CHECKAUX_OBSOLETE;
...@@ -149,7 +142,6 @@ static enum fscache_checkaux ceph_fscache_inode_check_aux( ...@@ -149,7 +142,6 @@ static enum fscache_checkaux ceph_fscache_inode_check_aux(
static const struct fscache_cookie_def ceph_fscache_inode_object_def = { static const struct fscache_cookie_def ceph_fscache_inode_object_def = {
.name = "CEPH.inode", .name = "CEPH.inode",
.type = FSCACHE_COOKIE_TYPE_DATAFILE, .type = FSCACHE_COOKIE_TYPE_DATAFILE,
.get_attr = ceph_fscache_inode_get_attr,
.check_aux = ceph_fscache_inode_check_aux, .check_aux = ceph_fscache_inode_check_aux,
}; };
...@@ -172,12 +164,11 @@ void ceph_fscache_register_inode_cookie(struct inode *inode) ...@@ -172,12 +164,11 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)
memset(&aux, 0, sizeof(aux)); memset(&aux, 0, sizeof(aux));
aux.version = ci->i_version; aux.version = ci->i_version;
aux.mtime = inode->i_mtime; aux.mtime = inode->i_mtime;
aux.size = i_size_read(inode);
ci->fscache = fscache_acquire_cookie(fsc->fscache, ci->fscache = fscache_acquire_cookie(fsc->fscache,
&ceph_fscache_inode_object_def, &ceph_fscache_inode_object_def,
&ci->i_vino, sizeof(ci->i_vino), &ci->i_vino, sizeof(ci->i_vino),
&aux, sizeof(aux), &aux, sizeof(aux),
ci, false); ci, i_size_read(inode), false);
} }
inode_unlock(inode); inode_unlock(inode);
} }
...@@ -214,7 +205,7 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp) ...@@ -214,7 +205,7 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)
fscache_disable_cookie(ci->fscache, &ci->i_vino, false); fscache_disable_cookie(ci->fscache, &ci->i_vino, false);
fscache_uncache_all_inode_pages(ci->fscache, inode); fscache_uncache_all_inode_pages(ci->fscache, inode);
} else { } else {
fscache_enable_cookie(ci->fscache, &ci->i_vino, fscache_enable_cookie(ci->fscache, &ci->i_vino, i_size_read(inode),
ceph_fscache_can_enable, inode); ceph_fscache_can_enable, inode);
if (fscache_cookie_enabled(ci->fscache)) { if (fscache_cookie_enabled(ci->fscache)) {
dout("fscache_file_set_cookie %p %p enabling cache\n", dout("fscache_file_set_cookie %p %p enabling cache\n",
...@@ -308,7 +299,8 @@ void ceph_readpage_to_fscache(struct inode *inode, struct page *page) ...@@ -308,7 +299,8 @@ void ceph_readpage_to_fscache(struct inode *inode, struct page *page)
if (!cache_valid(ci)) if (!cache_valid(ci))
return; return;
ret = fscache_write_page(ci->fscache, page, GFP_KERNEL); ret = fscache_write_page(ci->fscache, page, i_size_read(inode),
GFP_KERNEL);
if (ret) if (ret)
fscache_uncache_page(ci->fscache, page); fscache_uncache_page(ci->fscache, page);
} }
......
...@@ -87,7 +87,8 @@ char *extract_sharename(const char *treename) ...@@ -87,7 +87,8 @@ char *extract_sharename(const char *treename)
static enum static enum
fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data, fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
const void *data, const void *data,
uint16_t datalen) uint16_t datalen,
loff_t object_size)
{ {
struct cifs_fscache_super_auxdata auxdata; struct cifs_fscache_super_auxdata auxdata;
const struct cifs_tcon *tcon = cookie_netfs_data; const struct cifs_tcon *tcon = cookie_netfs_data;
...@@ -113,18 +114,11 @@ const struct fscache_cookie_def cifs_fscache_super_index_def = { ...@@ -113,18 +114,11 @@ const struct fscache_cookie_def cifs_fscache_super_index_def = {
.check_aux = cifs_fscache_super_check_aux, .check_aux = cifs_fscache_super_check_aux,
}; };
static void
cifs_fscache_inode_get_attr(const void *cookie_netfs_data, uint64_t *size)
{
const struct cifsInodeInfo *cifsi = cookie_netfs_data;
*size = cifsi->vfs_inode.i_size;
}
static enum static enum
fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data, fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
const void *data, const void *data,
uint16_t datalen) uint16_t datalen,
loff_t object_size)
{ {
struct cifs_fscache_inode_auxdata auxdata; struct cifs_fscache_inode_auxdata auxdata;
struct cifsInodeInfo *cifsi = cookie_netfs_data; struct cifsInodeInfo *cifsi = cookie_netfs_data;
...@@ -146,6 +140,5 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data, ...@@ -146,6 +140,5 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
const struct fscache_cookie_def cifs_fscache_inode_object_def = { const struct fscache_cookie_def cifs_fscache_inode_object_def = {
.name = "CIFS.uniqueid", .name = "CIFS.uniqueid",
.type = FSCACHE_COOKIE_TYPE_DATAFILE, .type = FSCACHE_COOKIE_TYPE_DATAFILE,
.get_attr = cifs_fscache_inode_get_attr,
.check_aux = cifs_fscache_inode_check_aux, .check_aux = cifs_fscache_inode_check_aux,
}; };
...@@ -79,7 +79,7 @@ void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) ...@@ -79,7 +79,7 @@ void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
&cifs_fscache_server_index_def, &cifs_fscache_server_index_def,
&key, key_len, &key, key_len,
NULL, 0, NULL, 0,
server, true); server, 0, true);
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
__func__, server, server->fscache); __func__, server, server->fscache);
} }
...@@ -109,7 +109,7 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) ...@@ -109,7 +109,7 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
&cifs_fscache_super_index_def, &cifs_fscache_super_index_def,
sharename, strlen(sharename), sharename, strlen(sharename),
&tcon->resource_id, sizeof(tcon->resource_id), &tcon->resource_id, sizeof(tcon->resource_id),
tcon, true); tcon, 0, true);
kfree(sharename); kfree(sharename);
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
__func__, server->fscache, tcon->fscache); __func__, server->fscache, tcon->fscache);
...@@ -137,7 +137,7 @@ static void cifs_fscache_acquire_inode_cookie(struct cifsInodeInfo *cifsi, ...@@ -137,7 +137,7 @@ static void cifs_fscache_acquire_inode_cookie(struct cifsInodeInfo *cifsi,
&cifs_fscache_inode_object_def, &cifs_fscache_inode_object_def,
&cifsi->uniqueid, sizeof(cifsi->uniqueid), &cifsi->uniqueid, sizeof(cifsi->uniqueid),
&auxdata, sizeof(auxdata), &auxdata, sizeof(auxdata),
cifsi, true); cifsi, cifsi->vfs_inode.i_size, true);
} }
static void cifs_fscache_enable_inode_cookie(struct inode *inode) static void cifs_fscache_enable_inode_cookie(struct inode *inode)
...@@ -301,13 +301,15 @@ int __cifs_readpages_from_fscache(struct inode *inode, ...@@ -301,13 +301,15 @@ int __cifs_readpages_from_fscache(struct inode *inode,
void __cifs_readpage_to_fscache(struct inode *inode, struct page *page) void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
{ {
struct cifsInodeInfo *cifsi = CIFS_I(inode);
int ret; int ret;
cifs_dbg(FYI, "%s: (fsc: %p, p: %p, i: %p)\n", cifs_dbg(FYI, "%s: (fsc: %p, p: %p, i: %p)\n",
__func__, CIFS_I(inode)->fscache, page, inode); __func__, cifsi->fscache, page, inode);
ret = fscache_write_page(CIFS_I(inode)->fscache, page, GFP_KERNEL); ret = fscache_write_page(cifsi->fscache, page,
cifsi->vfs_inode.i_size, GFP_KERNEL);
if (ret != 0) if (ret != 0)
fscache_uncache_page(CIFS_I(inode)->fscache, page); fscache_uncache_page(cifsi->fscache, page);
} }
void __cifs_fscache_readpages_cancel(struct inode *inode, struct list_head *pages) void __cifs_fscache_readpages_cancel(struct inode *inode, struct list_head *pages)
......
...@@ -21,7 +21,8 @@ struct kmem_cache *fscache_cookie_jar; ...@@ -21,7 +21,8 @@ struct kmem_cache *fscache_cookie_jar;
static atomic_t fscache_object_debug_id = ATOMIC_INIT(0); static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie); static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie,
loff_t object_size);
static int fscache_alloc_object(struct fscache_cache *cache, static int fscache_alloc_object(struct fscache_cache *cache,
struct fscache_cookie *cookie); struct fscache_cookie *cookie);
static int fscache_attach_object(struct fscache_cookie *cookie, static int fscache_attach_object(struct fscache_cookie *cookie,
...@@ -61,6 +62,7 @@ struct fscache_cookie *__fscache_acquire_cookie( ...@@ -61,6 +62,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
const void *index_key, size_t index_key_len, const void *index_key, size_t index_key_len,
const void *aux_data, size_t aux_data_len, const void *aux_data, size_t aux_data_len,
void *netfs_data, void *netfs_data,
loff_t object_size,
bool enable) bool enable)
{ {
struct fscache_cookie *cookie; struct fscache_cookie *cookie;
...@@ -160,7 +162,7 @@ struct fscache_cookie *__fscache_acquire_cookie( ...@@ -160,7 +162,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
* - we create indices on disk when we need them as an index * - we create indices on disk when we need them as an index
* may exist in multiple caches */ * may exist in multiple caches */
if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX) { if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX) {
if (fscache_acquire_non_index_cookie(cookie) == 0) { if (fscache_acquire_non_index_cookie(cookie, object_size) == 0) {
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
} else { } else {
atomic_dec(&parent->n_children); atomic_dec(&parent->n_children);
...@@ -194,6 +196,7 @@ EXPORT_SYMBOL(__fscache_acquire_cookie); ...@@ -194,6 +196,7 @@ EXPORT_SYMBOL(__fscache_acquire_cookie);
*/ */
void __fscache_enable_cookie(struct fscache_cookie *cookie, void __fscache_enable_cookie(struct fscache_cookie *cookie,
const void *aux_data, const void *aux_data,
loff_t object_size,
bool (*can_enable)(void *data), bool (*can_enable)(void *data),
void *data) void *data)
{ {
...@@ -215,7 +218,7 @@ void __fscache_enable_cookie(struct fscache_cookie *cookie, ...@@ -215,7 +218,7 @@ void __fscache_enable_cookie(struct fscache_cookie *cookie,
/* Wait for outstanding disablement to complete */ /* Wait for outstanding disablement to complete */
__fscache_wait_on_invalidate(cookie); __fscache_wait_on_invalidate(cookie);
if (fscache_acquire_non_index_cookie(cookie) == 0) if (fscache_acquire_non_index_cookie(cookie, object_size) == 0)
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
} else { } else {
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
...@@ -232,11 +235,11 @@ EXPORT_SYMBOL(__fscache_enable_cookie); ...@@ -232,11 +235,11 @@ EXPORT_SYMBOL(__fscache_enable_cookie);
* - this must make sure the index chain is instantiated and instantiate the * - this must make sure the index chain is instantiated and instantiate the
* object representation too * object representation too
*/ */
static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie) static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie,
loff_t object_size)
{ {
struct fscache_object *object; struct fscache_object *object;
struct fscache_cache *cache; struct fscache_cache *cache;
uint64_t i_size;
int ret; int ret;
_enter(""); _enter("");
...@@ -275,9 +278,6 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie) ...@@ -275,9 +278,6 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
return ret; return ret;
} }
/* pass on how big the object we're caching is supposed to be */
cookie->def->get_attr(cookie->netfs_data, &i_size);
spin_lock(&cookie->lock); spin_lock(&cookie->lock);
if (hlist_empty(&cookie->backing_objects)) { if (hlist_empty(&cookie->backing_objects)) {
spin_unlock(&cookie->lock); spin_unlock(&cookie->lock);
...@@ -287,7 +287,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie) ...@@ -287,7 +287,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
object = hlist_entry(cookie->backing_objects.first, object = hlist_entry(cookie->backing_objects.first,
struct fscache_object, cookie_link); struct fscache_object, cookie_link);
fscache_set_store_limit(object, i_size); fscache_set_store_limit(object, object_size);
/* initiate the process of looking up all the objects in the chain /* initiate the process of looking up all the objects in the chain
* (done by fscache_initialise_object()) */ * (done by fscache_initialise_object()) */
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
static static
enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data, enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data,
const void *data, const void *data,
uint16_t datalen); uint16_t datalen,
loff_t object_size);
/* /*
* The root index is owned by FS-Cache itself. * The root index is owned by FS-Cache itself.
...@@ -76,7 +77,8 @@ struct fscache_cookie_def fscache_fsdef_netfs_def = { ...@@ -76,7 +77,8 @@ struct fscache_cookie_def fscache_fsdef_netfs_def = {
static enum fscache_checkaux fscache_fsdef_netfs_check_aux( static enum fscache_checkaux fscache_fsdef_netfs_check_aux(
void *cookie_netfs_data, void *cookie_netfs_data,
const void *data, const void *data,
uint16_t datalen) uint16_t datalen,
loff_t object_size)
{ {
struct fscache_netfs *netfs = cookie_netfs_data; struct fscache_netfs *netfs = cookie_netfs_data;
uint32_t version; uint32_t version;
......
...@@ -922,7 +922,8 @@ static void fscache_dequeue_object(struct fscache_object *object) ...@@ -922,7 +922,8 @@ static void fscache_dequeue_object(struct fscache_object *object)
* and creation). * and creation).
*/ */
enum fscache_checkaux fscache_check_aux(struct fscache_object *object, enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
const void *data, uint16_t datalen) const void *data, uint16_t datalen,
loff_t object_size)
{ {
enum fscache_checkaux result; enum fscache_checkaux result;
...@@ -932,7 +933,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object, ...@@ -932,7 +933,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
} }
result = object->cookie->def->check_aux(object->cookie->netfs_data, result = object->cookie->def->check_aux(object->cookie->netfs_data,
data, datalen); data, datalen, object_size);
switch (result) { switch (result) {
/* entry okay as is */ /* entry okay as is */
case FSCACHE_CHECKAUX_OKAY: case FSCACHE_CHECKAUX_OKAY:
......
...@@ -963,6 +963,7 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie) ...@@ -963,6 +963,7 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
*/ */
int __fscache_write_page(struct fscache_cookie *cookie, int __fscache_write_page(struct fscache_cookie *cookie,
struct page *page, struct page *page,
loff_t object_size,
gfp_t gfp) gfp_t gfp)
{ {
struct fscache_storage *op; struct fscache_storage *op;
...@@ -1014,6 +1015,10 @@ int __fscache_write_page(struct fscache_cookie *cookie, ...@@ -1014,6 +1015,10 @@ int __fscache_write_page(struct fscache_cookie *cookie,
/* add the page to the pending-storage radix tree on the backing /* add the page to the pending-storage radix tree on the backing
* object */ * object */
spin_lock(&object->lock); spin_lock(&object->lock);
if (object->store_limit_l != object_size)
fscache_set_store_limit(object, object_size);
spin_lock(&cookie->stores_lock); spin_lock(&cookie->stores_lock);
_debug("store limit %llx", (unsigned long long) object->store_limit); _debug("store limit %llx", (unsigned long long) object->store_limit);
......
...@@ -69,20 +69,6 @@ const struct fscache_cookie_def nfs_fscache_super_index_def = { ...@@ -69,20 +69,6 @@ const struct fscache_cookie_def nfs_fscache_super_index_def = {
.type = FSCACHE_COOKIE_TYPE_INDEX, .type = FSCACHE_COOKIE_TYPE_INDEX,
}; };
/*
* Get certain file attributes from the netfs data
* - This function can be absent for an index
* - Not permitted to return an error
* - The netfs data from the cookie being used as the source is presented
*/
static void nfs_fscache_inode_get_attr(const void *cookie_netfs_data,
uint64_t *size)
{
const struct nfs_inode *nfsi = cookie_netfs_data;
*size = nfsi->vfs_inode.i_size;
}
/* /*
* Consult the netfs about the state of an object * Consult the netfs about the state of an object
* - This function can be absent if the index carries no state data * - This function can be absent if the index carries no state data
...@@ -92,7 +78,8 @@ static void nfs_fscache_inode_get_attr(const void *cookie_netfs_data, ...@@ -92,7 +78,8 @@ static void nfs_fscache_inode_get_attr(const void *cookie_netfs_data,
static static
enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data, enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
const void *data, const void *data,
uint16_t datalen) uint16_t datalen,
loff_t object_size)
{ {
struct nfs_fscache_inode_auxdata auxdata; struct nfs_fscache_inode_auxdata auxdata;
struct nfs_inode *nfsi = cookie_netfs_data; struct nfs_inode *nfsi = cookie_netfs_data;
...@@ -101,7 +88,6 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data, ...@@ -101,7 +88,6 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
return FSCACHE_CHECKAUX_OBSOLETE; return FSCACHE_CHECKAUX_OBSOLETE;
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.size = nfsi->vfs_inode.i_size;
auxdata.mtime = nfsi->vfs_inode.i_mtime; auxdata.mtime = nfsi->vfs_inode.i_mtime;
auxdata.ctime = nfsi->vfs_inode.i_ctime; auxdata.ctime = nfsi->vfs_inode.i_ctime;
...@@ -150,7 +136,6 @@ static void nfs_fh_put_context(void *cookie_netfs_data, void *context) ...@@ -150,7 +136,6 @@ static void nfs_fh_put_context(void *cookie_netfs_data, void *context)
const struct fscache_cookie_def nfs_fscache_inode_object_def = { const struct fscache_cookie_def nfs_fscache_inode_object_def = {
.name = "NFS.fh", .name = "NFS.fh",
.type = FSCACHE_COOKIE_TYPE_DATAFILE, .type = FSCACHE_COOKIE_TYPE_DATAFILE,
.get_attr = nfs_fscache_inode_get_attr,
.check_aux = nfs_fscache_inode_check_aux, .check_aux = nfs_fscache_inode_check_aux,
.get_context = nfs_fh_get_context, .get_context = nfs_fh_get_context,
.put_context = nfs_fh_put_context, .put_context = nfs_fh_put_context,
......
...@@ -86,7 +86,7 @@ void nfs_fscache_get_client_cookie(struct nfs_client *clp) ...@@ -86,7 +86,7 @@ void nfs_fscache_get_client_cookie(struct nfs_client *clp)
&nfs_fscache_server_index_def, &nfs_fscache_server_index_def,
&key, len, &key, len,
NULL, 0, NULL, 0,
clp, true); clp, 0, true);
dfprintk(FSCACHE, "NFS: get client cookie (0x%p/0x%p)\n", dfprintk(FSCACHE, "NFS: get client cookie (0x%p/0x%p)\n",
clp, clp->fscache); clp, clp->fscache);
} }
...@@ -188,7 +188,7 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, int ...@@ -188,7 +188,7 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, int
&nfs_fscache_super_index_def, &nfs_fscache_super_index_def,
key, sizeof(*key) + ulen, key, sizeof(*key) + ulen,
NULL, 0, NULL, 0,
nfss, true); nfss, 0, true);
dfprintk(FSCACHE, "NFS: get superblock cookie (0x%p/0x%p)\n", dfprintk(FSCACHE, "NFS: get superblock cookie (0x%p/0x%p)\n",
nfss, nfss->fscache); nfss, nfss->fscache);
return; return;
...@@ -237,7 +237,6 @@ void nfs_fscache_init_inode(struct inode *inode) ...@@ -237,7 +237,6 @@ void nfs_fscache_init_inode(struct inode *inode)
return; return;
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.size = nfsi->vfs_inode.i_size;
auxdata.mtime = nfsi->vfs_inode.i_mtime; auxdata.mtime = nfsi->vfs_inode.i_mtime;
auxdata.ctime = nfsi->vfs_inode.i_ctime; auxdata.ctime = nfsi->vfs_inode.i_ctime;
...@@ -248,7 +247,7 @@ void nfs_fscache_init_inode(struct inode *inode) ...@@ -248,7 +247,7 @@ void nfs_fscache_init_inode(struct inode *inode)
&nfs_fscache_inode_object_def, &nfs_fscache_inode_object_def,
nfsi->fh.data, nfsi->fh.size, nfsi->fh.data, nfsi->fh.size,
&auxdata, sizeof(auxdata), &auxdata, sizeof(auxdata),
nfsi, false); nfsi, nfsi->vfs_inode.i_size, false);
} }
/* /*
...@@ -263,7 +262,6 @@ void nfs_fscache_clear_inode(struct inode *inode) ...@@ -263,7 +262,6 @@ void nfs_fscache_clear_inode(struct inode *inode)
dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie); dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.size = nfsi->vfs_inode.i_size;
auxdata.mtime = nfsi->vfs_inode.i_mtime; auxdata.mtime = nfsi->vfs_inode.i_mtime;
auxdata.ctime = nfsi->vfs_inode.i_ctime; auxdata.ctime = nfsi->vfs_inode.i_ctime;
fscache_relinquish_cookie(cookie, &auxdata, false); fscache_relinquish_cookie(cookie, &auxdata, false);
...@@ -306,7 +304,6 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp) ...@@ -306,7 +304,6 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)
return; return;
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.size = nfsi->vfs_inode.i_size;
auxdata.mtime = nfsi->vfs_inode.i_mtime; auxdata.mtime = nfsi->vfs_inode.i_mtime;
auxdata.ctime = nfsi->vfs_inode.i_ctime; auxdata.ctime = nfsi->vfs_inode.i_ctime;
...@@ -317,7 +314,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp) ...@@ -317,7 +314,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)
fscache_uncache_all_inode_pages(cookie, inode); fscache_uncache_all_inode_pages(cookie, inode);
} else { } else {
dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi); dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi);
fscache_enable_cookie(cookie, &auxdata, fscache_enable_cookie(cookie, &auxdata, nfsi->vfs_inode.i_size,
nfs_fscache_can_enable, inode); nfs_fscache_can_enable, inode);
if (fscache_cookie_enabled(cookie)) if (fscache_cookie_enabled(cookie))
set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags); set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags);
...@@ -495,7 +492,8 @@ void __nfs_readpage_to_fscache(struct inode *inode, struct page *page, int sync) ...@@ -495,7 +492,8 @@ void __nfs_readpage_to_fscache(struct inode *inode, struct page *page, int sync)
"NFS: readpage_to_fscache(fsc:%p/p:%p(i:%lx f:%lx)/%d)\n", "NFS: readpage_to_fscache(fsc:%p/p:%p(i:%lx f:%lx)/%d)\n",
nfs_i_fscache(inode), page, page->index, page->flags, sync); nfs_i_fscache(inode), page, page->index, page->flags, sync);
ret = fscache_write_page(nfs_i_fscache(inode), page, GFP_KERNEL); ret = fscache_write_page(nfs_i_fscache(inode), page,
inode->i_size, GFP_KERNEL);
dfprintk(FSCACHE, dfprintk(FSCACHE,
"NFS: readpage_to_fscache: p:%p(i:%lu f:%lx) ret %d\n", "NFS: readpage_to_fscache: p:%p(i:%lu f:%lx) ret %d\n",
page, page->index, page->flags, ret); page, page->index, page->flags, ret);
......
...@@ -68,7 +68,6 @@ struct nfs_fscache_key { ...@@ -68,7 +68,6 @@ struct nfs_fscache_key {
struct nfs_fscache_inode_auxdata { struct nfs_fscache_inode_auxdata {
struct timespec mtime; struct timespec mtime;
struct timespec ctime; struct timespec ctime;
loff_t size;
u64 change_attr; u64 change_attr;
}; };
......
...@@ -553,7 +553,8 @@ extern bool fscache_object_sleep_till_congested(signed long *timeoutp); ...@@ -553,7 +553,8 @@ extern bool fscache_object_sleep_till_congested(signed long *timeoutp);
extern enum fscache_checkaux fscache_check_aux(struct fscache_object *object, extern enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
const void *data, const void *data,
uint16_t datalen); uint16_t datalen,
loff_t object_size);
extern void fscache_object_retrying_stale(struct fscache_object *object); extern void fscache_object_retrying_stale(struct fscache_object *object);
......
...@@ -83,22 +83,15 @@ struct fscache_cookie_def { ...@@ -83,22 +83,15 @@ struct fscache_cookie_def {
const void *parent_netfs_data, const void *parent_netfs_data,
const void *cookie_netfs_data); const void *cookie_netfs_data);
/* get certain file attributes from the netfs data
* - this function can be absent for an index
* - not permitted to return an error
* - the netfs data from the cookie being used as the source is
* presented
*/
void (*get_attr)(const void *cookie_netfs_data, uint64_t *size);
/* consult the netfs about the state of an object /* consult the netfs about the state of an object
* - this function can be absent if the index carries no state data * - this function can be absent if the index carries no state data
* - the netfs data from the cookie being used as the target is * - the netfs data from the cookie being used as the target is
* presented, as is the auxiliary data * presented, as is the auxiliary data and the object size
*/ */
enum fscache_checkaux (*check_aux)(void *cookie_netfs_data, enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
const void *data, const void *data,
uint16_t datalen); uint16_t datalen,
loff_t object_size);
/* get an extra reference on a read context /* get an extra reference on a read context
* - this function can be absent if the completion function doesn't * - this function can be absent if the completion function doesn't
...@@ -200,7 +193,7 @@ extern struct fscache_cookie *__fscache_acquire_cookie( ...@@ -200,7 +193,7 @@ extern struct fscache_cookie *__fscache_acquire_cookie(
const struct fscache_cookie_def *, const struct fscache_cookie_def *,
const void *, size_t, const void *, size_t,
const void *, size_t, const void *, size_t,
void *, bool); void *, loff_t, bool);
extern void __fscache_relinquish_cookie(struct fscache_cookie *, const void *, bool); extern void __fscache_relinquish_cookie(struct fscache_cookie *, const void *, bool);
extern int __fscache_check_consistency(struct fscache_cookie *, const void *); extern int __fscache_check_consistency(struct fscache_cookie *, const void *);
extern void __fscache_update_cookie(struct fscache_cookie *, const void *); extern void __fscache_update_cookie(struct fscache_cookie *, const void *);
...@@ -220,7 +213,7 @@ extern int __fscache_read_or_alloc_pages(struct fscache_cookie *, ...@@ -220,7 +213,7 @@ extern int __fscache_read_or_alloc_pages(struct fscache_cookie *,
void *, void *,
gfp_t); gfp_t);
extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t); extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t);
extern int __fscache_write_page(struct fscache_cookie *, struct page *, gfp_t); extern int __fscache_write_page(struct fscache_cookie *, struct page *, loff_t, gfp_t);
extern void __fscache_uncache_page(struct fscache_cookie *, struct page *); extern void __fscache_uncache_page(struct fscache_cookie *, struct page *);
extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *); extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *); extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
...@@ -231,7 +224,7 @@ extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *, ...@@ -231,7 +224,7 @@ extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *,
extern void __fscache_readpages_cancel(struct fscache_cookie *cookie, extern void __fscache_readpages_cancel(struct fscache_cookie *cookie,
struct list_head *pages); struct list_head *pages);
extern void __fscache_disable_cookie(struct fscache_cookie *, const void *, bool); extern void __fscache_disable_cookie(struct fscache_cookie *, const void *, bool);
extern void __fscache_enable_cookie(struct fscache_cookie *, const void *, extern void __fscache_enable_cookie(struct fscache_cookie *, const void *, loff_t,
bool (*)(void *), void *); bool (*)(void *), void *);
/** /**
...@@ -315,6 +308,7 @@ void fscache_release_cache_tag(struct fscache_cache_tag *tag) ...@@ -315,6 +308,7 @@ void fscache_release_cache_tag(struct fscache_cache_tag *tag)
* @aux_data_len: Size of the auxiliary data buffer * @aux_data_len: Size of the auxiliary data buffer
* @netfs_data: An arbitrary piece of data to be kept in the cookie to * @netfs_data: An arbitrary piece of data to be kept in the cookie to
* represent the cache object to the netfs * represent the cache object to the netfs
* @object_size: The initial size of object
* @enable: Whether or not to enable a data cookie immediately * @enable: Whether or not to enable a data cookie immediately
* *
* This function is used to inform FS-Cache about part of an index hierarchy * This function is used to inform FS-Cache about part of an index hierarchy
...@@ -333,13 +327,14 @@ struct fscache_cookie *fscache_acquire_cookie( ...@@ -333,13 +327,14 @@ struct fscache_cookie *fscache_acquire_cookie(
const void *aux_data, const void *aux_data,
size_t aux_data_len, size_t aux_data_len,
void *netfs_data, void *netfs_data,
loff_t object_size,
bool enable) bool enable)
{ {
if (fscache_cookie_valid(parent) && fscache_cookie_enabled(parent)) if (fscache_cookie_valid(parent) && fscache_cookie_enabled(parent))
return __fscache_acquire_cookie(parent, def, return __fscache_acquire_cookie(parent, def,
index_key, index_key_len, index_key, index_key_len,
aux_data, aux_data_len, aux_data, aux_data_len,
netfs_data, enable); netfs_data, object_size, enable);
else else
return NULL; return NULL;
} }
...@@ -660,6 +655,7 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie, ...@@ -660,6 +655,7 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie,
* fscache_write_page - Request storage of a page in the cache * fscache_write_page - Request storage of a page in the cache
* @cookie: The cookie representing the cache object * @cookie: The cookie representing the cache object
* @page: The netfs page to store * @page: The netfs page to store
* @object_size: Updated size of object
* @gfp: The conditions under which memory allocation should be made * @gfp: The conditions under which memory allocation should be made
* *
* Request the contents of the netfs page be written into the cache. This * Request the contents of the netfs page be written into the cache. This
...@@ -677,10 +673,11 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie, ...@@ -677,10 +673,11 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie,
static inline static inline
int fscache_write_page(struct fscache_cookie *cookie, int fscache_write_page(struct fscache_cookie *cookie,
struct page *page, struct page *page,
loff_t object_size,
gfp_t gfp) gfp_t gfp)
{ {
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie)) if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
return __fscache_write_page(cookie, page, gfp); return __fscache_write_page(cookie, page, object_size, gfp);
else else
return -ENOBUFS; return -ENOBUFS;
} }
...@@ -819,6 +816,7 @@ void fscache_disable_cookie(struct fscache_cookie *cookie, ...@@ -819,6 +816,7 @@ void fscache_disable_cookie(struct fscache_cookie *cookie,
* fscache_enable_cookie - Reenable a cookie * fscache_enable_cookie - Reenable a cookie
* @cookie: The cookie representing the cache object * @cookie: The cookie representing the cache object
* @aux_data: The updated auxiliary data for the cookie (may be NULL) * @aux_data: The updated auxiliary data for the cookie (may be NULL)
* @object_size: Current size of object
* @can_enable: A function to permit enablement once lock is held * @can_enable: A function to permit enablement once lock is held
* @data: Data for can_enable() * @data: Data for can_enable()
* *
...@@ -833,11 +831,13 @@ void fscache_disable_cookie(struct fscache_cookie *cookie, ...@@ -833,11 +831,13 @@ void fscache_disable_cookie(struct fscache_cookie *cookie,
static inline static inline
void fscache_enable_cookie(struct fscache_cookie *cookie, void fscache_enable_cookie(struct fscache_cookie *cookie,
const void *aux_data, const void *aux_data,
loff_t object_size,
bool (*can_enable)(void *data), bool (*can_enable)(void *data),
void *data) void *data)
{ {
if (fscache_cookie_valid(cookie) && !fscache_cookie_enabled(cookie)) if (fscache_cookie_valid(cookie) && !fscache_cookie_enabled(cookie))
__fscache_enable_cookie(cookie, aux_data, can_enable, data); __fscache_enable_cookie(cookie, aux_data, object_size,
can_enable, data);
} }
#endif /* _LINUX_FSCACHE_H */ #endif /* _LINUX_FSCACHE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment