summaryrefslogtreecommitdiff
path: root/include/linux/fscache-cache.h
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 /include/linux/fscache-cache.h
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 'include/linux/fscache-cache.h')
-rw-r--r--include/linux/fscache-cache.h37
1 files changed, 28 insertions, 9 deletions
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index 9b9c1de4a460..c5f92347cbf8 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -417,15 +417,6 @@ struct fscache_object {
extern const char *fscache_object_states[];
-#define fscache_object_is_active(obj) \
- (!test_bit(FSCACHE_IOERROR, &(obj)->cache->flags) && \
- (obj)->state >= FSCACHE_OBJECT_AVAILABLE && \
- (obj)->state < FSCACHE_OBJECT_DYING)
-
-#define fscache_object_is_dead(obj) \
- (test_bit(FSCACHE_IOERROR, &(obj)->cache->flags) && \
- (obj)->state >= FSCACHE_OBJECT_DYING)
-
extern void fscache_object_init(struct fscache_object *, struct fscache_cookie *,
struct fscache_cache *);
@@ -438,6 +429,34 @@ extern void fscache_object_destroy(struct fscache_object *object);
#define fscache_object_destroy(object) do {} while(0)
#endif
+static inline bool fscache_object_is_live(struct fscache_object *object)
+{
+ return object->state < FSCACHE_OBJECT_DYING;
+}
+
+static inline bool fscache_object_is_dying(struct fscache_object *object)
+{
+ return !fscache_object_is_live(object);
+}
+
+static inline bool fscache_object_is_available(struct fscache_object *object)
+{
+ return object->state >= FSCACHE_OBJECT_AVAILABLE;
+}
+
+static inline bool fscache_object_is_active(struct fscache_object *object)
+{
+ return fscache_object_is_available(object) &&
+ fscache_object_is_live(object) &&
+ !test_bit(FSCACHE_IOERROR, &object->cache->flags);
+}
+
+static inline bool fscache_object_is_dead(struct fscache_object *object)
+{
+ return fscache_object_is_dying(object) &&
+ test_bit(FSCACHE_IOERROR, &object->cache->flags);
+}
+
/**
* fscache_object_destroyed - Note destruction of an object in a cache
* @cache: The cache from which the object came