[Devel] [PATCH RHEL7 COMMIT] ms/fuse: Protect fi->nlookup with fi->lock

Konstantin Khorenko khorenko at virtuozzo.com
Tue Apr 30 14:35:39 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.12.1.vz7.95.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.1.vz7.95.2
------>
commit 979ee76f34e556f16b7941bbef59b25d0fe19a48
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Apr 30 14:35:37 2019 +0300

    ms/fuse: Protect fi->nlookup with fi->lock
    
    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>
    
    =====================
    Patchset description:
    
    fuse: Backport of ms locking patches part 2
    
    Here is backport of locking patches: introducing of fc->bg_lock and fi->lock.
    
    This may need additional changes for kio and NOT verified for fast-path.
    
    Reviewed-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
    
    Kirill Tkhai (9):
          fuse: introduce fc->bg_lock
          fuse: Remove bogus list_del_init() from-fuse_request_send_background
          fuse: do not take fc->lock in fuse_request_send_background()
          fuse: Add fuse_inode argument to fuse_prepare_release()
          fuse: Convert fc->attr_version into atomic64_t
          fuse: Introduce fi->lock to protect write related fields
          fuse: Protect fi->nlookup with fi->lock
          fuse: Protect ff->reserved_req via corresponding fi->lock
          fuse: do not take fc->lock in fuse_request_send_background() - fixup
---
 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