summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-05-10 19:50:26 +0100
committerDavid Howells <dhowells@redhat.com>2013-06-19 14:16:47 +0100
commit493f7bc11457bc1f6fbf25a4b2bdf215ebaf050f (patch)
treea301ea64293effa2f31e5a1451ca740504f3f4e4 /fs
parent610be24ee434aa89197f06f30fef02be83c006a5 (diff)
downloadop-kernel-dev-493f7bc11457bc1f6fbf25a4b2bdf215ebaf050f.zip
op-kernel-dev-493f7bc11457bc1f6fbf25a4b2bdf215ebaf050f.tar.gz
FS-Cache: Wrap checks on object state
Wrap checks on object state (mostly outside of fs/fscache/object.c) with inline functions so that the mechanism can be replaced. Some of the state checks within object.c are left as-is as they will be replaced. Signed-off-by: David Howells <dhowells@redhat.com> Tested-By: Milosz Tanski <milosz@adfin.com> Acked-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cachefiles/namei.c4
-rw-r--r--fs/fscache/cache.c2
-rw-r--r--fs/fscache/cookie.c8
-rw-r--r--fs/fscache/object.c8
-rw-r--r--fs/fscache/operation.c2
5 files changed, 12 insertions, 12 deletions
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 07cbd44..01979a3 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -130,7 +130,7 @@ found_dentry:
fscache_object_states[object->fscache.state],
dentry);
- if (object->fscache.state < FSCACHE_OBJECT_DYING) {
+ if (fscache_object_is_live(&object->fscache)) {
printk(KERN_ERR "\n");
printk(KERN_ERR "CacheFiles: Error:"
" Can't preemptively bury live object\n");
@@ -192,7 +192,7 @@ try_again:
/* an old object from a previous incarnation is hogging the slot - we
* need to wait for it to be destroyed */
wait_for_old_object:
- if (xobject->fscache.state < FSCACHE_OBJECT_DYING) {
+ if (fscache_object_is_live(&object->fscache)) {
printk(KERN_ERR "\n");
printk(KERN_ERR "CacheFiles: Error:"
" Unexpected object collision\n");
diff --git a/fs/fscache/cache.c b/fs/fscache/cache.c
index b52aed1..129ea53 100644
--- a/fs/fscache/cache.c
+++ b/fs/fscache/cache.c
@@ -115,7 +115,7 @@ struct fscache_cache *fscache_select_cache_for_object(
struct fscache_object, cookie_link);
cache = object->cache;
- if (object->state >= FSCACHE_OBJECT_DYING ||
+ if (fscache_object_is_dying(object) ||
test_bit(FSCACHE_IOERROR, &cache->flags))
cache = NULL;
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index e2cba1f..a5f36c9 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -285,7 +285,7 @@ static int fscache_alloc_object(struct fscache_cache *cache,
object_already_extant:
ret = -ENOBUFS;
- if (object->state >= FSCACHE_OBJECT_DYING) {
+ if (fscache_object_is_dead(object)) {
spin_unlock(&cookie->lock);
goto error;
}
@@ -321,7 +321,7 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
ret = -EEXIST;
hlist_for_each_entry(p, &cookie->backing_objects, cookie_link) {
if (p->cache == object->cache) {
- if (p->state >= FSCACHE_OBJECT_DYING)
+ if (fscache_object_is_dying(p))
ret = -ENOBUFS;
goto cant_attach_object;
}
@@ -332,7 +332,7 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
hlist_for_each_entry(p, &cookie->parent->backing_objects,
cookie_link) {
if (p->cache == object->cache) {
- if (p->state >= FSCACHE_OBJECT_DYING) {
+ if (fscache_object_is_dying(p)) {
ret = -ENOBUFS;
spin_unlock(&cookie->parent->lock);
goto cant_attach_object;
@@ -400,7 +400,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
object = hlist_entry(cookie->backing_objects.first,
struct fscache_object,
cookie_link);
- if (object->state < FSCACHE_OBJECT_DYING)
+ if (fscache_object_is_live(object))
fscache_raise_event(
object, FSCACHE_OBJECT_EV_INVALIDATE);
}
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 0133699..863f687 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -457,10 +457,10 @@ static void fscache_initialise_object(struct fscache_object *object)
spin_lock_nested(&parent->lock, 1);
_debug("parent %s", fscache_object_states[parent->state]);
- if (parent->state >= FSCACHE_OBJECT_DYING) {
+ if (fscache_object_is_dying(parent)) {
_debug("bad parent");
set_bit(FSCACHE_OBJECT_EV_WITHDRAW, &object->events);
- } else if (parent->state < FSCACHE_OBJECT_AVAILABLE) {
+ } else if (!fscache_object_is_available(parent)) {
_debug("wait");
/* we may get woken up in this state by child objects
@@ -517,9 +517,9 @@ static void fscache_lookup_object(struct fscache_object *object)
ASSERTCMP(parent->n_obj_ops, >, 0);
/* make sure the parent is still available */
- ASSERTCMP(parent->state, >=, FSCACHE_OBJECT_AVAILABLE);
+ ASSERT(fscache_object_is_available(parent));
- if (parent->state >= FSCACHE_OBJECT_DYING ||
+ if (fscache_object_is_dying(parent) ||
test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
_debug("unavailable");
set_bit(FSCACHE_OBJECT_EV_WITHDRAW, &object->events);
diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
index 762a9ec..ccf0219 100644
--- a/fs/fscache/operation.c
+++ b/fs/fscache/operation.c
@@ -35,7 +35,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
ASSERT(list_empty(&op->pend_link));
ASSERT(op->processor != NULL);
- ASSERTCMP(op->object->state, >=, FSCACHE_OBJECT_AVAILABLE);
+ ASSERT(fscache_object_is_available(op->object));
ASSERTCMP(atomic_read(&op->usage), >, 0);
ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
OpenPOWER on IntegriCloud