From: David Howells <milosz@adfin.com>
To: ceph-devel@vger.kernel.org
Cc: sage@inktank.com, zheng.z.yan@intel.com, dhowells@redhat.com,
jiayisuse@gmail.com, linux-cachefs@redhat.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/8] CacheFiles: Implement interface to check cache consistency
Date: Thu, 5 Sep 2013 18:21:24 -0400 [thread overview]
Message-ID: <d17d0271a4fc090bed7fea903187f02a35def6a3.1378418255.git.milosz@adfin.com> (raw)
In-Reply-To: <cover.1378418255.git.milosz@adfin.com>
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>
---
fs/cachefiles/interface.c | 26 ++++++++++++++++++++++++++
fs/cachefiles/internal.h | 1 +
fs/cachefiles/xattr.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index d4c1206..43eb559 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -378,6 +378,31 @@ static void cachefiles_sync_cache(struct fscache_cache *_cache)
}
/*
+ * check if the backing cache is updated to FS-Cache
+ * - called by FS-Cache when evaluates if need to invalidate the cache
+ */
+static bool cachefiles_check_consistency(struct fscache_operation *op)
+{
+ struct cachefiles_object *object;
+ struct cachefiles_cache *cache;
+ const struct cred *saved_cred;
+ int ret;
+
+ _enter("{OBJ%x}", op->object->debug_id);
+
+ object = container_of(op->object, struct cachefiles_object, fscache);
+ cache = container_of(object->fscache.cache,
+ struct cachefiles_cache, cache);
+
+ cachefiles_begin_secure(cache, &saved_cred);
+ ret = cachefiles_check_auxdata(object);
+ cachefiles_end_secure(cache, saved_cred);
+
+ _leave(" = %d", ret);
+ return ret;
+}
+
+/*
* notification the attributes on an object have changed
* - called with reads/writes excluded by FS-Cache
*/
@@ -522,4 +547,5 @@ const struct fscache_cache_ops cachefiles_cache_ops = {
.write_page = cachefiles_write_page,
.uncache_page = cachefiles_uncache_page,
.dissociate_pages = cachefiles_dissociate_pages,
+ .check_consistency = cachefiles_check_consistency,
};
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 4938251..5349473 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -235,6 +235,7 @@ extern int cachefiles_set_object_xattr(struct cachefiles_object *object,
struct cachefiles_xattr *auxdata);
extern int cachefiles_update_object_xattr(struct cachefiles_object *object,
struct cachefiles_xattr *auxdata);
+extern int cachefiles_check_auxdata(struct cachefiles_object *object);
extern int cachefiles_check_object_xattr(struct cachefiles_object *object,
struct cachefiles_xattr *auxdata);
extern int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c
index 2476e51..34c88b8 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
*/
--
1.7.9.5
next prev parent reply other threads:[~2013-09-05 22:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-05 22:20 [PATCH 0/8] ceph: fscache support & upstream changes Milosz Tanski
2013-09-05 22:21 ` [PATCH 1/8] FS-Cache: Add interface to check consistency of a cached object David Howells
2013-09-05 22:21 ` David Howells [this message]
2013-09-05 22:21 ` [PATCH 3/8] fscache: Netfs function for cleanup post readpages Milosz Tanski
2013-09-05 22:22 ` [PATCH 4/8] ceph: use fscache as a local presisent cache Milosz Tanski
2013-09-05 22:22 ` [PATCH 5/8] ceph: clean PgPrivate2 on returning from readpages Milosz Tanski
2013-09-05 22:22 ` [PATCH 6/8] ceph: ceph_readpage_to_fscache didn't check if marked Milosz Tanski
2013-09-05 22:23 ` [PATCH 7/8] ceph: page still marked private_2 Milosz Tanski
2013-09-05 22:23 ` [PATCH 8/8] ceph: Do not do invalidate if the filesystem is mounted nofsc Milosz Tanski
2013-09-05 23:00 ` [PATCH 0/8] ceph: fscache support & upstream changes Sage Weil
2013-09-06 4:41 ` Milosz Tanski
2013-09-06 15:59 ` David Howells
2013-09-06 19:02 ` Milosz Tanski
2013-09-06 20:03 ` Sage Weil
2013-09-08 3:07 ` Milosz Tanski
2013-09-08 21:21 ` Milosz Tanski
2013-09-09 10:18 ` David Howells
2013-09-09 14:53 ` Milosz Tanski
2013-09-09 17:44 ` Sage Weil
2013-09-09 18:28 ` [PATCH] fscache: check consistency does not decrement refcount Milosz Tanski
2013-09-09 18:54 ` Milosz Tanski
2013-09-10 12:34 ` David Howells
2013-09-10 16:45 ` Milosz Tanski
2013-09-10 16:48 ` Sage Weil
2013-09-09 10:17 ` [PATCH 0/8] ceph: fscache support & upstream changes David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d17d0271a4fc090bed7fea903187f02a35def6a3.1378418255.git.milosz@adfin.com \
--to=milosz@adfin.com \
--cc=ceph-devel@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=jiayisuse@gmail.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sage@inktank.com \
--cc=zheng.z.yan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®