summaryrefslogtreecommitdiffstats
path: root/fs/cachefiles/xattr.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-08-21 23:29:21 +0200
committerDavid Howells <dhowells@redhat.com>2013-09-06 10:17:30 +0200
commit5002d7bef81c9646bbb06fb57db4a100aa5a57c5 (patch)
tree7894e28d5f50756b655acf46dbed6cdd41deccec /fs/cachefiles/xattr.c
parentFS-Cache: Add interface to check consistency of a cached object (diff)
downloadlinux-5002d7bef81c9646bbb06fb57db4a100aa5a57c5.tar.xz
linux-5002d7bef81c9646bbb06fb57db4a100aa5a57c5.zip
CacheFiles: Implement interface to check cache consistency
Implement the FS-Cache interface to check the consistency of a cache object in CacheFiles. Original-author: Hongyi Jia <jiayisuse@gmail.com> Signed-off-by: David Howells <dhowells@redhat.com> cc: Hongyi Jia <jiayisuse@gmail.com> cc: Milosz Tanski <milosz@adfin.com>
Diffstat (limited to 'fs/cachefiles/xattr.c')
-rw-r--r--fs/cachefiles/xattr.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c
index 2476e5162609..34c88b83e39f 100644
--- a/fs/cachefiles/xattr.c
+++ b/fs/cachefiles/xattr.c
@@ -157,6 +157,42 @@ int cachefiles_update_object_xattr(struct cachefiles_object *object,
}
/*
+ * check the consistency between the backing cache and the FS-Cache cookie
+ */
+int cachefiles_check_auxdata(struct cachefiles_object *object)
+{
+ struct cachefiles_xattr *auxbuf;
+ struct dentry *dentry = object->dentry;
+ unsigned int dlen;
+ int ret;
+
+ ASSERT(dentry);
+ ASSERT(dentry->d_inode);
+ ASSERT(object->fscache.cookie->def->check_aux);
+
+ auxbuf = kmalloc(sizeof(struct cachefiles_xattr) + 512, GFP_KERNEL);
+ if (!auxbuf)
+ return -ENOMEM;
+
+ auxbuf->len = vfs_getxattr(dentry, cachefiles_xattr_cache,
+ &auxbuf->type, 512 + 1);
+ if (auxbuf->len < 1)
+ return -ESTALE;
+
+ if (auxbuf->type != object->fscache.cookie->def->type)
+ return -ESTALE;
+
+ dlen = auxbuf->len - 1;
+ ret = fscache_check_aux(&object->fscache, &auxbuf->data, dlen);
+
+ kfree(auxbuf);
+ if (ret != FSCACHE_CHECKAUX_OKAY)
+ return -ESTALE;
+
+ return 0;
+}
+
+/*
* check the state xattr on a cache file
* - return -ESTALE if the object should be deleted
*/