Skip to contentSkip to conversation

cifs: Misc. cleanup in cifsacl handling

PATCH In review [email protected] 2 participants 3 messages Nov 13, 2010 – Nov 17, 2010 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Misc. cleanup in cifsacl handling

From: Shirish Pargaonkar <[email protected]>

Change the name of function mode_to_acl to mode_to_cifs_acl.

Handle return code in functions mode_to_cifs_acl and cifs_acl_to_fattr.

Pass fid to inode helper function which passes it on to get inode info function so we do not end up opening the opened file again thus breaking oplocks.

---
 fs/cifs/cifsacl.c   |    2 +-
 fs/cifs/cifsproto.h |    2 +-
 fs/cifs/file.c      |    7 ++++---
 fs/cifs/inode.c     |   23 ++++++++++++++++-------
 4 files changed, 22 insertions(+), 12 deletions(-)
fs/cifs/cifsacl.c +1 -1
index b54fec0..c6ebea0 100644
@@ -726,7 +726,7 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
 }
 
 /* Convert mode bits to an ACL so we can update the ACL on the server */
-int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
+int mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode)
 {
 	int rc = 0;
 	__u32 secdesclen = 0;
fs/cifs/cifsproto.h +1 -1
index a47ffc2..db961dc 100644
@@ -133,7 +133,7 @@ extern int cifs_get_inode_info_unix(struct inode **pinode,
 extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
 			      struct cifs_fattr *fattr, struct inode *inode,
 			      const char *path, const __u16 *pfid);
-extern int mode_to_acl(struct inode *inode, const char *path, __u64);
+extern int mode_to_cifs_acl(struct inode *inode, const char *path, __u64);
 extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *,
 					const char *, u32 *);
 
fs/cifs/file.c +4 -3
index b857ce5..6e8477e 100644
@@ -106,7 +106,7 @@ static inline int cifs_get_disposition(unsigned int flags)
 
 static inline int cifs_open_inode_helper(struct inode *inode,
 	struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf,
-	char *full_path, int xid)
+	char *full_path, int xid, const __u16 *pfid)
 {
 	struct cifsInodeInfo *pCifsInode = CIFS_I(inode);
 	struct timespec temp;
@@ -144,7 +144,7 @@ client_can_cache:
 					      xid);
 	else
 		rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb,
-					 xid, NULL);
+					 xid, pfid);
 
 	cifs_set_oplock_level(pCifsInode, oplock);
 
@@ -448,7 +448,8 @@ int cifs_open(struct inode *inode, struct file *file)
 		goto out;
 	}
 
-	rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid);
+	rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid,
+					&netfid);
 	if (rc != 0)
 		goto out;
 
fs/cifs/inode.c +16 -7
index ff7d299..35014dc 100644
@@ -689,8 +689,13 @@ int cifs_get_inode_info(struct inode **pinode,
 #ifdef CONFIG_CIFS_EXPERIMENTAL
 	/* fill in 0777 bits from ACL */
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
-		cFYI(1, "Getting mode bits from ACL");
-		cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path, pfid);
+		rc = cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path,
+						pfid);
+		if (rc) {
+			cFYI(1, "%s: Getting ACL failed with error: %d",
+				__func__, rc);
+			goto cgii_exit;
+		}
 	}
 #endif
 
@@ -2047,7 +2052,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
 	struct cifsInodeInfo *cifsInode = CIFS_I(inode);
 	char *full_path = NULL;
-	int rc = -EACCES;
+	int rc;
 	__u32 dosattr = 0;
 	__u64 mode = NO_CHANGE_64;
 
@@ -2113,11 +2118,15 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 	}
 
 	if (attrs->ia_valid & ATTR_MODE) {
-		rc = 0;
 #ifdef CONFIG_CIFS_EXPERIMENTAL
-		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
-			rc = mode_to_acl(inode, full_path, mode);
-		else
+		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
+			rc = mode_to_cifs_acl(inode, full_path, mode);
+			if (rc) {
+				cFYI(1, "%s: Setting ACL failed with error: %d",
+					__func__, rc);
+				goto cifs_setattr_exit;
+			}
+		}
 #endif
 		if (((mode & S_IWUGO) == 0) &&
 		    (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {
Signature · 1 line
1.6.0.2

A message that is not in the archive (sent off-list or not yet received): 1289664138-16108-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 10 lines · On Sat, Nov 13, 2010 at 10:02 AM, <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pu…

From: Shirish Pargaonkar <[email protected]>

Change the name of function mode_to_acl to mode_to_cifs_acl.

Handle return code in functions mode_to_cifs_acl and cifs_acl_to_fattr.

Pass fid to inode helper function which passes it on to get inode info function so we do not end up opening the opened file again thus breaking oplocks.

<snip>

Quoted 18 lines
fs/cifs/inode.c +8 -4
@@ -2113,11 +2118,15 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
        }
 
        if (attrs->ia_valid & ATTR_MODE) {
-               rc = 0;
  #ifdef CONFIG_CIFS_EXPERIMENTAL
-               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
-                       rc = mode_to_acl(inode, full_path, mode);
-               else
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
+                       rc = mode_to_cifs_acl(inode, full_path, mode);
+                       if (rc) {
+                               cFYI(1, "%s: Setting ACL failed with error: %d",
+                                       __func__, rc);
+                               goto cifs_setattr_exit;
+                       }
+               }
  #endif
Quoted 2 lines

               if (((mode & S_IWUGO) == 0) && (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {

This changes behavior. When you mount with CIFS_ACL then you are
still falling through to set the mode bits too (it used to avoid setting the mode bits when we can use ACLs to more accurately represent the mode). You got rid of the else ... Did you mean to do that?
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTinRQPNFyeKkj1-FEhnJ2VoPYTzdP39v6UB5Yuet-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 32 lines · Steve French
Quoted 10 lines · On Sat, Nov 13, 2010 at 10:02 AM,  <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pu…

From: Shirish Pargaonkar <[email protected]>

Change the name of function mode_to_acl to mode_to_cifs_acl.

Handle return code in functions mode_to_cifs_acl and cifs_acl_to_fattr.

Pass fid to inode helper function which passes it on to get inode info function so we do not end up opening the opened file again thus breaking oplocks.

<snip>

Quoted 18 lines
fs/cifs/inode.c +8 -4
@@ -2113,11 +2118,15 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
        }
 
        if (attrs->ia_valid & ATTR_MODE) {
-               rc = 0;
  #ifdef CONFIG_CIFS_EXPERIMENTAL
-               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
-                       rc = mode_to_acl(inode, full_path, mode);
-               else
+               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
+                       rc = mode_to_cifs_acl(inode, full_path, mode);
+                       if (rc) {
+                               cFYI(1, "%s: Setting ACL failed with error: %d",
+                                       __func__, rc);
+                               goto cifs_setattr_exit;
+                       }
+               }
  #endif
Quoted 8 lines
Quoted 2 lines

               if (((mode & S_IWUGO) == 0) && (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {

This changes behavior.   When you mount with CIFS_ACL then you are still falling through to set the mode bits too (it used to avoid setting the mode bits when we can use ACLs to more accurately represent the mode).  You got rid of the else ... Did you mean to do that?

Steve, I was thinking dynperm (mode) should take precedence if it is chosen as a mount option. Would that be right thing to do?