cifs: Percolate error up to the caller during get/set acls [try #2]
Subsystems (2)
PATCH 1/1 cifs: Percolate error up to the caller during get/set acls [try #2]
From: Shirish Pargaonkar <[email protected]>
Modify get/set_cifs_acl* calls to reutrn error code and percolate the error code up to the caller.
--- fs/cifs/cifsacl.c | 44 ++++++++++++++++++++++++++------------------ fs/cifs/cifsproto.h | 2 +- fs/cifs/inode.c | 7 +++---- 3 files changed, 30 insertions(+), 23 deletions(-)
fs/cifs/cifsacl.c +26 -18
@@ -560,7 +560,7 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);if (IS_ERR (tlink)) -return NULL ; +ERR_CAST (tlink); xid =GetXid (); rc =CIFSSMBGetCIFSACL (xid,tlink_tcon (tlink), fid, &pntsd, pacllen);
@@ -568,7 +568,9 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,cifs_put_tlink (tlink); -cFYI (1 ,"GetCIFSACL rc = %d ACL len %d" , rc, *pacllen); +cFYI (1 ,"%s: rc = %d ACL len %d" , __func__, rc, *pacllen); +if (rc) +return ERR_PTR (rc);return pntsd; }
@@ -583,7 +585,7 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);if (IS_ERR (tlink)) -return NULL ; +ERR_CAST (tlink); tcon =tlink_tcon (tlink); xid =GetXid ();
@@ -591,18 +593,17 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, rc =CIFSSMBOpen (xid, tcon, path,FILE_OPEN ,READ_CONTROL ,0 , &fid, &oplock,NULL , cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ); -if (rc) { -cERROR (1 ,"Unable to open file to get ACL" ); - goto out; +if (!rc) { + rc =CIFSSMBGetCIFSACL (xid, tcon, fid, &pntsd, pacllen); +CIFSSMBClose (xid, tcon, fid); } - rc =CIFSSMBGetCIFSACL (xid, tcon, fid, &pntsd, pacllen); -cFYI (1 ,"GetCIFSACL rc = %d ACL len %d" , rc, *pacllen); - -CIFSSMBClose (xid, tcon, fid); - out:cifs_put_tlink (tlink);FreeXid (xid); + +cFYI (1 ,"%s: rc = %d ACL len %d" , __func__, rc, *pacllen); +if (rc) +return ERR_PTR (rc);return pntsd; }
@@ -695,7 +696,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, }/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ -void +int cifs_acl_to_fattr (struct cifs_sb_info *cifs_sb,struct cifs_fattr *fattr,struct inode *inode,const char *path,const __u16 *pfid) {
@@ -711,13 +712,17 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, pntsd =get_cifs_acl (cifs_sb, inode, path, &acllen);/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ -if (pntsd) +if (IS_ERR (pntsd)) { + rc =PTR_ERR (pntsd); +cERROR (1 ,"%s: error %d getting sec desc" , __func__, rc); + }else { rc =parse_sec_desc (pntsd, acllen, fattr); -if (rc) -cFYI (1 ,"parse sec desc failed rc = %d" , rc); +kfree (pntsd); +if (rc) +cERROR (1 ,"parse sec desc failed rc = %d" , rc); + } -kfree (pntsd); -return ; +return rc; }/* Convert mode bits to an ACL so we can update the ACL on the server */
@@ -736,7 +741,10 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)/* Add three ACEs for owner, group, everyone getting rid of other ACEs as chmod disables ACEs and set the security descriptor */ -if (pntsd) { +if (IS_ERR (pntsd)) { + rc =PTR_ERR (pntsd); +cERROR (1 ,"%s: error %d getting sec desc" , __func__, rc); + }else {/* allocate memory for the smb header, set security descriptor request security descriptor parameters, and secuirty descriptor itself */
fs/cifs/cifsproto.h +1 -1
@@ -130,7 +130,7 @@ extern int cifs_get_file_info_unix(struct file *filp);extern int cifs_get_inode_info_unix (struct inode **pinode,const unsigned char *search_path,struct super_block *sb,int xid); -extern void cifs_acl_to_fattr (struct cifs_sb_info *cifs_sb, +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 );
fs/cifs/inode.c +3 -4
@@ -688,10 +688,9 @@ 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); - } +if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) + rc =cifs_acl_to_fattr (cifs_sb, &fattr, *pinode, full_path, + pfid);#endif /* fill in remaining high mode bits e.g. SUID, VTX */
Signature · 1 line
1.6.0.2
A message that is not in the archive (sent off-list or not yet received): 1289330107-2273-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
fs/cifs/inode.c int cifs_get_inode_info(struct inode **pinode, · line 693
Quoted 13 lines · On Tue, 9 Nov 2010 13:15:07 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…
fs/cifs/inode.c +3
-4@@ -688,10 +688,9 @@ 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); - } +if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) + rc =cifs_acl_to_fattr (cifs_sb, &fattr, *pinode, full_path, + pfid);
Do you want to return an error from cifs_get_inode_info when fetching the ACL fails? I think you either need to goto cgii_exit if rc != 0, or keep ignoring the error code like you do today. If the function is going to return an error, then there's no real point in doing the later stuff (the iget, etc).
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20101109143542.72fa1f63-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org
Quoted 24 lines · Jeff Layton
fs/cifs/inode.c int cifs_get_inode_info(struct inode **pinode, · line 693
Quoted 13 lines · On Tue, 9 Nov 2010 13:15:07 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…
fs/cifs/inode.c +3
-4@@ -688,10 +688,9 @@ 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); - } + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) + rc = cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path, + pfid);Do you want to return an error from
cifs_get_inode_infowhen fetching the ACL fails? I think you either need to gotocgii_exitif rc != 0, or keep ignoring the error code like you do today. If the function is going to return an error, then there's no real point in doing the later stuff (the iget, etc).
Quoted 3 lines
--
Jeff Layton <[email protected]>
Jeff, I thought about that. I think we should handle the error in both cifs_get_inode_info and mode_to_acl. Both the functions are in experimental mode. And mode_to_acl does not log any error on rc, so I removed from cifs_get_inode_info also although cifs_acl_to_fattr does.
A message that is not in the archive (sent off-list or not yet received): AANLkTi=9N7H7MkBbx83TzG4s=X_oP=Pu_VknEgP=UPir-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 25 lines · Shirish Pargaonkar
Quoted 24 lines · Jeff Layton
fs/cifs/inode.c int cifs_get_inode_info(struct inode **pinode, · line 693
Quoted 13 lines · On Tue, 9 Nov 2010 13:15:07 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…
fs/cifs/inode.c +3
-4@@ -688,10 +688,9 @@ 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); - } + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) + rc = cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path, + pfid);Do you want to return an error from
cifs_get_inode_infowhen fetching the ACL fails? I think you either need to gotocgii_exitif rc != 0, or keep ignoring the error code like you do today. If the function is going to return an error, then there's no real point in doing the later stuff (the iget, etc).
Quoted 9 lines
Quoted 3 lines
--
Jeff Layton <[email protected]>Jeff, I thought about that. I think we should handle the error in both
cifs_get_inode_infoandmode_to_acl. Both the functions are in experimental mode. Andmode_to_acldoes not log any error on rc, so I removed fromcifs_get_inode_infoalso althoughcifs_acl_to_fattrdoes.
I do not think this patch has caused this condition but investigating.
cifstest6:/usr/src/cthon04 # mount/dev/sda2 on / type ext3 (rw,acl,user_xattr) /proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw) udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5) fusectl on /sys/fs/fuse/connections type fusectl (rw) securityfs on /sys/kernel/security type securityfs (rw)
cifstest6:/usr/src/cthon04 # rmmod cifs
ERROR: Module cifs is in use
cifstest6:/usr/src/cthon04 # dmesg
CIFS VFS: Unexpected SMB signature
CIFS VFS: Unexpected SMB signature
CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS: cifs_acl_to_fattr: error -26 getting sec desc
#define ETXTBSY 26 /* Text file busy */
A message that is not in the archive (sent off-list or not yet received): AANLkTin6YTaxaXP=8H19qYi6gg9sRj9Vf2CUEpqM3taW-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 68 lines · Shirish Pargaonkar
Quoted 25 lines · Shirish Pargaonkar
Quoted 24 lines · Jeff Layton
fs/cifs/inode.c int cifs_get_inode_info(struct inode **pinode, · line 693
Quoted 13 lines · On Tue, 9 Nov 2010 13:15:07 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…
fs/cifs/inode.c +3
-4@@ -688,10 +688,9 @@ 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); - } + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) + rc = cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path, + pfid);Do you want to return an error from
cifs_get_inode_infowhen fetching the ACL fails? I think you either need to gotocgii_exitif rc != 0, or keep ignoring the error code like you do today. If the function is going to return an error, then there's no real point in doing the later stuff (the iget, etc).Quoted 9 lines
Quoted 3 lines
--
Jeff Layton <[email protected]>Jeff, I thought about that. I think we should handle the error in both
cifs_get_inode_infoandmode_to_acl. Both the functions are in experimental mode. Andmode_to_acldoes not log any error on rc, so I removed fromcifs_get_inode_infoalso althoughcifs_acl_to_fattrdoes.I do not think this patch has caused this condition but investigating.
cifstest6:/usr/src/cthon04 # mount
/dev/sda2on / type ext3 (rw,acl,user_xattr) /proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on/sys/kernel/debugtype debugfs (rw) udev on /dev type tmpfs (rw)
devpts on/dev/ptstype devpts (rw,mode=0620,gid=5) fusectl on/sys/fs/fuse/connectionstype fusectl (rw) securityfs on/sys/kernel/securitytype securityfs (rw)cifstest6:/usr/src/cthon04 # rmmod cifs
ERROR: Module cifs is in usecifstest6:/usr/src/cthon04 # dmesg
CIFS VFS: Unexpected SMB signature
CIFS VFS: Unexpected SMB signature
CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc CIFS VFS:cifs_acl_to_fattr: error -26 getting sec desc
Quoted 2 lines
#define ETXTBSY 26 /* Text file busy */
yes, this happens even without the patch, with cifsacl mount option except that with this patch, exact error code (ETXTBSY) gets logged.