aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-05-10 14:50:26 -0400
committerDavid Howells <dhowells@redhat.com>2013-06-19 09:16:47 -0400
commit493f7bc11457bc1f6fbf25a4b2bdf215ebaf050f (patch)
treea301ea64293effa2f31e5a1451ca740504f3f4e4 /fs
parent610be24ee434aa89197f06f30fef02be83c006a5 (diff)
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 07cbd447861e..01979a3f5121 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -130,7 +130,7 @@ found_dentry:
130 fscache_object_states[object->fscache.state], 130 fscache_object_states[object->fscache.state],
131 dentry); 131 dentry);
132 132
133 if (object->fscache.state < FSCACHE_OBJECT_DYING) { 133 if (fscache_object_is_live(&object->fscache)) {
134 printk(KERN_ERR "\n"); 134 printk(KERN_ERR "\n");
135 printk(KERN_ERR "CacheFiles: Error:" 135 printk(KERN_ERR "CacheFiles: Error:"
136 " Can't preemptively bury live object\n"); 136 " Can't preemptively bury live object\n");
@@ -192,7 +192,7 @@ try_again:
192 /* an old object from a previous incarnation is hogging the slot - we 192 /* an old object from a previous incarnation is hogging the slot - we
193 * need to wait for it to be destroyed */ 193 * need to wait for it to be destroyed */
194wait_for_old_object: 194wait_for_old_object:
195 if (xobject->fscache.state < FSCACHE_OBJECT_DYING) { 195 if (fscache_object_is_live(&object->fscache)) {
196 printk(KERN_ERR "\n"); 196 printk(KERN_ERR "\n");
197 printk(KERN_ERR "CacheFiles: Error:" 197 printk(KERN_ERR "CacheFiles: Error:"
198 " Unexpected object collision\n"); 198 " Unexpected object collision\n");
diff --git a/fs/fscache/cache.c b/fs/fscache/cache.c
index b52aed1dca97..129ea537f023 100644
--- a/fs/fscache/cache.c
+++ b/fs/fscache/cache.c
@@ -115,7 +115,7 @@ struct fscache_cache *fscache_select_cache_for_object(
115 struct fscache_object, cookie_link); 115 struct fscache_object, cookie_link);
116 116
117 cache = object->cache; 117 cache = object->cache;
118 if (object->state >= FSCACHE_OBJECT_DYING || 118 if (fscache_object_is_dying(object) ||
119 test_bit(FSCACHE_IOERROR, &cache->flags)) 119 test_bit(FSCACHE_IOERROR, &cache->flags))
120 cache = NULL; 120 cache = NULL;
121 121
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index e2cba1f60c21..a5f36c921e91 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -285,7 +285,7 @@ static int fscache_alloc_object(struct fscache_cache *cache,
285 285
286object_already_extant: 286object_already_extant:
287 ret = -ENOBUFS; 287 ret = -ENOBUFS;
288 if (object->state >= FSCACHE_OBJECT_DYING) { 288 if (fscache_object_is_dead(object)) {
289 spin_unlock(&cookie->lock); 289 spin_unlock(&cookie->lock);
290 goto error; 290 goto error;
291 } 291 }
@@ -321,7 +321,7 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
321 ret = -EEXIST; 321 ret = -EEXIST;
322 hlist_for_each_entry(p, &cookie->backing_objects, cookie_link) { 322 hlist_for_each_entry(p, &cookie->backing_objects, cookie_link) {
323 if (p->cache == object->cache) { 323 if (p->cache == object->cache) {
324 if (p->state >= FSCACHE_OBJECT_DYING) 324 if (fscache_object_is_dying(p))
325 ret = -ENOBUFS; 325 ret = -ENOBUFS;
326 goto cant_attach_object; 326 goto cant_attach_object;
327 } 327 }
@@ -332,7 +332,7 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
332 hlist_for_each_entry(p, &cookie->parent->backing_objects, 332 hlist_for_each_entry(p, &cookie->parent->backing_objects,
333 cookie_link) { 333 cookie_link) {
334 if (p->cache == object->cache) { 334 if (p->cache == object->cache) {
335 if (p->state >= FSCACHE_OBJECT_DYING) { 335 if (fscache_object_is_dying(p)) {
336 ret = -ENOBUFS; 336 ret = -ENOBUFS;
337 spin_unlock(&cookie->parent->lock); 337 spin_unlock(&cookie->parent->lock);
338 goto cant_attach_object; 338 goto cant_attach_object;
@@ -400,7 +400,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
400 object = hlist_entry(cookie->backing_objects.first, 400 object = hlist_entry(cookie->backing_objects.first,
401 struct fscache_object, 401 struct fscache_object,
402 cookie_link); 402 cookie_link);
403 if (object->state < FSCACHE_OBJECT_DYING) 403 if (fscache_object_is_live(object))
404 fscache_raise_event( 404 fscache_raise_event(
405 object, FSCACHE_OBJECT_EV_INVALIDATE); 405 object, FSCACHE_OBJECT_EV_INVALIDATE);
406 } 406 }
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 0133699f74ee..863f6873c0f0 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -457,10 +457,10 @@ static void fscache_initialise_object(struct fscache_object *object)
457 spin_lock_nested(&parent->lock, 1); 457 spin_lock_nested(&parent->lock, 1);
458 _debug("parent %s", fscache_object_states[parent->state]); 458 _debug("parent %s", fscache_object_states[parent->state]);
459 459
460 if (parent->state >= FSCACHE_OBJECT_DYING) { 460 if (fscache_object_is_dying(parent)) {
461 _debug("bad parent"); 461 _debug("bad parent");
462 set_bit(FSCACHE_OBJECT_EV_WITHDRAW, &object->events); 462 set_bit(FSCACHE_OBJECT_EV_WITHDRAW, &object->events);
463 } else if (parent->state < FSCACHE_OBJECT_AVAILABLE) { 463 } else if (!fscache_object_is_available(parent)) {
464 _debug("wait"); 464 _debug("wait");
465 465
466 /* we may get woken up in this state by child objects 466 /* we may get woken up in this state by child objects
@@ -517,9 +517,9 @@ static void fscache_lookup_object(struct fscache_object *object)
517 ASSERTCMP(parent->n_obj_ops, >, 0); 517 ASSERTCMP(parent->n_obj_ops, >, 0);
518 518
519 /* make sure the parent is still available */ 519 /* make sure the parent is still available */
520 ASSERTCMP(parent->state, >=, FSCACHE_OBJECT_AVAILABLE); 520 ASSERT(fscache_object_is_available(parent));
521 521
522 if (parent->state >= FSCACHE_OBJECT_DYING || 522 if (fscache_object_is_dying(parent) ||
523 test_bit(FSCACHE_IOERROR, &object->cache->flags)) { 523 test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
524 _debug("unavailable"); 524 _debug("unavailable");
525 set_bit(FSCACHE_OBJECT_EV_WITHDRAW, &object->events); 525 set_bit(FSCACHE_OBJECT_EV_WITHDRAW, &object->events);
diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
index 762a9ec4ffa4..ccf02194e7a6 100644
--- a/fs/fscache/operation.c
+++ b/fs/fscache/operation.c
@@ -35,7 +35,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
35 35
36 ASSERT(list_empty(&op->pend_link)); 36 ASSERT(list_empty(&op->pend_link));
37 ASSERT(op->processor != NULL); 37 ASSERT(op->processor != NULL);
38 ASSERTCMP(op->object->state, >=, FSCACHE_OBJECT_AVAILABLE); 38 ASSERT(fscache_object_is_available(op->object));
39 ASSERTCMP(atomic_read(&op->usage), >, 0); 39 ASSERTCMP(atomic_read(&op->usage), >, 0);
40 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS); 40 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
41 41