Re: [V9fs-developer] [PATCH 1/3] fs/9p: Update TLCREATE to allow create without open

Previous thread: [PATCH 3/3] fs/9p: Use generic_file_open with lookup_instantiate_filp by Aneesh Kumar K.V on Tuesday, October 5, 2010 - 10:01 am. (2 messages)

Next thread: Email Notification** by Super Enalotto International** on Saturday, October 2, 2010 - 2:46 pm. (1 message)
From: Aneesh Kumar K.V
Date: Tuesday, October 5, 2010 - 10:01 am

We need this so that we can support regular file creation
with mknod

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/9p/v9fs.h            |    2 ++
 fs/9p/vfs_inode.c       |   13 +++++++------
 include/net/9p/client.h |    2 +-
 net/9p/client.c         |    6 +++---
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 8bb7792..6209a29 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -126,6 +126,8 @@ void v9fs_session_begin_cancel(struct v9fs_session_info *v9ses);
 #define V9FS_DEFUID	(-2)
 #define V9FS_DEFGID	(-2)
 
+#define P9_LOOKUP_OPEN 0x1
+
 static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)
 {
 	return (inode->i_sb->s_fs_info);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 2f904a8..1ec9075 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -668,8 +668,9 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
 	int err = 0;
 	char *name = NULL;
 	gid_t gid;
-	int flags;
+	int flags = 0;
 	mode_t mode;
+	int lookup_flags = 0;
 	struct v9fs_session_info *v9ses;
 	struct p9_fid *fid = NULL;
 	struct p9_fid *dfid, *ofid;
@@ -679,11 +680,10 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
 	struct posix_acl *pacl = NULL, *dacl = NULL;
 
 	v9ses = v9fs_inode2v9ses(dir);
-	if (nd && nd->flags & LOOKUP_OPEN)
+	if (nd && nd->flags & LOOKUP_OPEN) {
 		flags = nd->intent.open.flags - 1;
-	else
-		flags = O_RDWR;
-
+		lookup_flags = P9_LOOKUP_OPEN;
+	}
 	name = (char *) dentry->d_name.name;
 	P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x "
 			"mode:0x%x\n", name, flags, omode);
@@ -713,7 +713,8 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
 			   "Failed to get acl values in creat %d\n", err);
 		goto error;
 	}
-	err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid);
+	err = p9_client_create_dotl(ofid, name, flags, mode,
+				    ...
From: Eric Van Hensbergen
Date: Tuesday, October 5, 2010 - 10:15 am

Ouch.  Protocol change.

Also - not sure I understand what's going on here.  Why does mknod go
through TLCREATE, shouldn't we have our
own protocol messages for mknod?//

Why add an additional flag field instead of just using the existing
flags field since we are only talking about a bit?

    -eric


On Tue, Oct 5, 2010 at 1:01 PM, Aneesh Kumar K.V
--

From: Venkateswararao Jujjuri (JV)
Date: Tuesday, October 5, 2010 - 11:19 am

I think we decided to send -1 with the flags instead of doing protocol change here.

Thanks,


--

From: Aneesh Kumar K. V
Date: Tuesday, October 5, 2010 - 11:18 pm

This is needed for the below mknod usage


TLCREATE is 

  size[4] Tlcreate tag[2] fid[4] name[s] flags[4] mode[4] gid[4]
    
  size[4] Rlcreate tag[2] qid[13] iounit[4]
    

The flags argument represent Linux access mode flags with which the caller
is requesting to open the file with. Protocol allows all the Linux
access

Having a -1 with the flag would indicate all the access mode flags are
set. So i found that to be ugly. And value 0 indicate O_RDONLY. So was
not sure whether -1 in flags or having a separate lookup flags is the
right thing to do.

-aneesh
--

From: Venkateswararao Jujjuri (JV)
Date: Wednesday, October 6, 2010 - 7:18 am

Yep. This sounds much better. :)



--

From: Eric Van Hensbergen
Date: Wednesday, October 6, 2010 - 7:59 am

On Wed, Oct 6, 2010 at 7:03 AM, Aneesh Kumar K. V

Yes, I think that's the better path.  :)

--

From: Aneesh Kumar K. V
Date: Wednesday, October 6, 2010 - 4:03 am

May be a better fix is to make sure we use TLMKNOD instead of TLCREATE
in case we get a create without LOOKUP_OPEN flags set. So how about

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 2f904a8..e89754f 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -55,6 +55,10 @@ static const struct inode_operations v9fs_file_inode_operations_dotl;
 static const struct inode_operations v9fs_symlink_inode_operations;
 static const struct inode_operations v9fs_symlink_inode_operations_dotl;
 
+static int
+v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
+		    dev_t rdev);
+
 /**
  * unixmode2p9mode - convert unix mode bits to plan 9
  * @v9ses: v9fs session information
@@ -681,8 +685,14 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
 	v9ses = v9fs_inode2v9ses(dir);
 	if (nd && nd->flags & LOOKUP_OPEN)
 		flags = nd->intent.open.flags - 1;
-	else
-		flags = O_RDWR;
+	else {
+		/*
+		 * create call without LOOKUP_OPEN is due
+		 * to mknod of regular files. So use mknod
+		 * operation.
+		 */
+		return v9fs_vfs_mknod_dotl(dir, dentry, omode, 0);
+	}
 
 	name = (char *) dentry->d_name.name;
 	P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x "
--

Previous thread: [PATCH 3/3] fs/9p: Use generic_file_open with lookup_instantiate_filp by Aneesh Kumar K.V on Tuesday, October 5, 2010 - 10:01 am. (2 messages)

Next thread: Email Notification** by Super Enalotto International** on Saturday, October 2, 2010 - 2:46 pm. (1 message)