[Devel] [PATCH 7/8] fuse: Protect fi->nlookup with fi->lock

Kirill Tkhai ktkhai at virtuozzo.com
Wed Apr 3 18:37:38 MSK 2019


ms commit c9d8f5f0692d

This continues previous patch and introduces the same protection for
nlookup field.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi at redhat.com>
---
 fs/fuse/dir.c   |    8 ++++----
 fs/fuse/inode.c |    5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0c1893bd68fd..e240edb33cc7 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -229,9 +229,9 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
 				fuse_queue_forget(fc, forget, outarg.nodeid, 1);
 				goto invalid;
 			}
-			spin_lock(&fc->lock);
+			spin_lock(&fi->lock);
 			fi->nlookup++;
-			spin_unlock(&fc->lock);
+			spin_unlock(&fi->lock);
 		}
 		kfree(forget);
 		if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT)
@@ -1342,9 +1342,9 @@ static int fuse_direntplus_link(struct file *file,
 		} else {
 			struct fuse_inode *fi;
 			fi = get_fuse_inode(inode);
-			spin_lock(&fc->lock);
+			spin_lock(&fi->lock);
 			fi->nlookup++;
-			spin_unlock(&fc->lock);
+			spin_unlock(&fi->lock);
 
 			fuse_change_attributes(inode, &o->attr,
 					       entry_attr_timeout(o),
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 3c09c0a03105..25f6e0ceac37 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -146,6 +146,7 @@ static void fuse_evict_inode(struct inode *inode)
 	if (inode->i_sb->s_flags & MS_ACTIVE) {
 		struct fuse_conn *fc = get_fuse_conn(inode);
 		struct fuse_inode *fi = get_fuse_inode(inode);
+
 		fuse_queue_forget(fc, fi->forget, fi->nodeid, fi->nlookup);
 		fi->forget = NULL;
 	}
@@ -341,9 +342,9 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
 	}
 
 	fi = get_fuse_inode(inode);
-	spin_lock(&fc->lock);
+	spin_lock(&fi->lock);
 	fi->nlookup++;
-	spin_unlock(&fc->lock);
+	spin_unlock(&fi->lock);
 	fuse_change_attributes(inode, attr, attr_valid, attr_version);
 
 	return inode;



More information about the Devel mailing list