]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/linux/fscache-cache.h
FS-Cache: Wrap checks on object state
[karo-tx-linux.git] / include / linux / fscache-cache.h
index 9b9c1de4a4601c11a64743fe27750bd287fa5b09..c5f92347cbf8ca165cf1d50b3445b777c86fb4f0 100644 (file)
@@ -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