]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/ubifs/xattr.c
ubifs: Correctly evict xattr inodes
[karo-tx-linux.git] / fs / ubifs / xattr.c
index 6c9e62c2ef559b2d6b3d3383436775795e927375..98f11257d66c09cc9311192d247c23c19b2f07c4 100644 (file)
@@ -513,6 +513,28 @@ out_cancel:
        return err;
 }
 
+/**
+ * ubifs_evict_xattr_inode - Evict an xattr inode.
+ * @c: UBIFS file-system description object
+ * @xattr_inum: xattr inode number
+ *
+ * When an inode that hosts xattrs is being removed we have to make sure
+ * that cached inodes of the xattrs also get removed from the inode cache
+ * otherwise we'd waste memory. This function looks up an inode from the
+ * inode cache and clears the link counter such that iput() will evict
+ * the inode.
+ */
+void ubifs_evict_xattr_inode(struct ubifs_info *c, ino_t xattr_inum)
+{
+       struct inode *inode;
+
+       inode = ilookup(c->vfs_sb, xattr_inum);
+       if (inode) {
+               clear_nlink(inode);
+               iput(inode);
+       }
+}
+
 static int ubifs_xattr_remove(struct inode *host, const char *name)
 {
        struct inode *inode;