cachefiles: Mark a backing file in use with an inode flag
[linux-2.6-microblaze.git] / fs / cachefiles / namei.c
index 11a3320..db60a67 100644 (file)
@@ -31,6 +31,18 @@ static bool __cachefiles_mark_inode_in_use(struct cachefiles_object *object,
        return can_use;
 }
 
+static bool cachefiles_mark_inode_in_use(struct cachefiles_object *object,
+                                        struct dentry *dentry)
+{
+       struct inode *inode = d_backing_inode(dentry);
+       bool can_use;
+
+       inode_lock(inode);
+       can_use = __cachefiles_mark_inode_in_use(object, dentry);
+       inode_unlock(inode);
+       return can_use;
+}
+
 /*
  * Unmark a backing inode.  The caller must hold the inode lock.
  */
@@ -43,6 +55,29 @@ static void __cachefiles_unmark_inode_in_use(struct cachefiles_object *object,
        trace_cachefiles_mark_inactive(object, inode);
 }
 
+/*
+ * Unmark a backing inode and tell cachefilesd that there's something that can
+ * be culled.
+ */
+void cachefiles_unmark_inode_in_use(struct cachefiles_object *object,
+                                   struct file *file)
+{
+       struct cachefiles_cache *cache = object->volume->cache;
+       struct inode *inode = file_inode(file);
+
+       if (inode) {
+               inode_lock(inode);
+               __cachefiles_unmark_inode_in_use(object, file->f_path.dentry);
+               inode_unlock(inode);
+
+               if (!test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags)) {
+                       atomic_long_add(inode->i_blocks, &cache->b_released);
+                       if (atomic_inc_return(&cache->f_released))
+                               cachefiles_state_changed(cache);
+               }
+       }
+}
+
 /*
  * get a subdirectory
  */