fuse: don't WARN when nlink is zero
authorMiklos Szeredi <mszeredi@suse.cz>
Mon, 4 Feb 2013 14:57:42 +0000 (15:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Mar 2013 22:03:38 +0000 (06:03 +0800)
commit dfca7cebc2679f3d129f8e680a8f199a7ad16e38 upstream.

drop_nlink() warns if nlink is already zero.  This is triggerable by a buggy
userspace filesystem.  The cure, I think, is worse than the disease so disable
the warning.

Reported-by: Tero Roponen <tero.roponen@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/fuse/dir.c

index b7c09f9eb40cd7ac26f626a5bcadd26aeaf06ec5..315e1f80ce7b31e3c06868a160f93820750a1508 100644 (file)
@@ -682,7 +682,14 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry)
 
                spin_lock(&fc->lock);
                fi->attr_version = ++fc->attr_version;
-               drop_nlink(inode);
+               /*
+                * If i_nlink == 0 then unlink doesn't make sense, yet this can
+                * happen if userspace filesystem is careless.  It would be
+                * difficult to enforce correct nlink usage so just ignore this
+                * condition here
+                */
+               if (inode->i_nlink > 0)
+                       drop_nlink(inode);
                spin_unlock(&fc->lock);
                fuse_invalidate_attr(inode);
                fuse_invalidate_attr(dir);