[Devel] [PATCH 1/2] fuse kio: Do not try to populate fuse_inode::private on second open

Kirill Tkhai ktkhai at virtuozzo.com
Thu Oct 11 18:00:01 MSK 2018


Introduce flag to mark files served by userspace.
It helps kio to understand it's not needed to send
a request to userspace, when private is NULL.
Introducing some special value to encode inodes,
served in userspace, (for example ~0UL), does not
look better, since it makes !fi->private checks
more difficult (also we have a lot free bits
in inode flags).

Synchronization is "caller owns inode->i_mutex".

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/fuse/fuse_i.h                   |    3 +++
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 69dfd0c318fe..d7dd571c08f6 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -147,6 +147,9 @@ enum {
 	FUSE_I_SIZE_UNSTABLE,
 	/** i_mtime has been updated locally; a flush to userspace needed */
 	FUSE_I_MTIME_UPDATED,
+
+	/** kdirect open try has already made */
+	FUSE_I_KIO_OPEN_TRY_MADE,
 };
 
 struct fuse_conn;
diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index 14bed318d139..f221001519c3 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -359,7 +359,7 @@ int kpcs_file_open(struct fuse_conn *fc, struct file *file, struct inode *inode)
 	struct fuse_inode *fi = get_fuse_inode(inode);
 	struct pcs_dentry_info *di = fi->private;
 	struct pcs_mds_fileinfo info;
-	int ret;
+	int ret = 0;
 
 	if (!S_ISREG(inode->i_mode))
 		return 0;
@@ -378,7 +378,14 @@ int kpcs_file_open(struct fuse_conn *fc, struct file *file, struct inode *inode)
 		spin_unlock(&di->lock);
 		return 0;
 	}
-	return kpcs_do_file_open(fc, file, inode);
+
+	if (!test_bit(FUSE_I_KIO_OPEN_TRY_MADE, &fi->state)) {
+		ret = kpcs_do_file_open(fc, file, inode);
+		if (!ret)
+			set_bit(FUSE_I_KIO_OPEN_TRY_MADE, &fi->state);
+	}
+
+	return ret;
 }
 
 void kpcs_inode_release(struct fuse_inode *fi)



More information about the Devel mailing list