Improvements to cifs_rename_pending_delete()
Subsystems (2)
cover Improvements to cifs_rename_pending_delete()
The patch series consists of a bug fix and a couple of enhancements to cifs_rename_pending_delete()
Sachin Prabhu (3):
cifs: Fix bug when checking error condition in
cifs_rename_pending_delete()
cifs: Check server capability before attempting silly rename
cifs: Return EBUSY instead of ETXTBSY in cifs_rename_pending_delete()
fs/cifs/inode.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.11.7
A message that is not in the archive (sent off-list or not yet received): 1362511557-22607-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH 1/3 cifs: Fix bug when checking error condition in cifs_rename_pending_delete()
Fix check for error condition after setting attributes with CIFSSMBSetFileInfo().
--- fs/cifs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/inode.c +1 -1
@@ -1014,7 +1014,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, current->tgid);/* although we would like to mark the file hidden if that fails we will still try to rename it */ -if (rc !=0 ) +if (!rc) cifsInode->cifsAttrs = dosattr;else dosattr = origattr;/* since not able to change them */
Signature · 1 line
1.7.11.7
A message that is not in the archive (sent off-list or not yet received): 1362511557-22607-2-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Jeff Layton
Reviewed-byRe: [PATCH 1/3] cifs: Fix bug when checking error condition in cifs_rename_pending_delete()
Quoted 13 lines · On Tue, 5 Mar 2013 19:25:55 +0000 Sachin Prabhu…
Fix check for error condition after setting attributes with
CIFSSMBSetFileInfo().Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/inode.c +0
-0
fs/cifs/inode.c cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, · line 1020
Quoted 8 lines
fs/cifs/inode.c +1
-1@@ -1014,7 +1014,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, current->tgid);/* although we would like to mark the file hidden if that fails we will still try to rename it */ -if (rc !=0 ) +if (!rc) cifsInode->cifsAttrs = dosattr;else dosattr = origattr;/* since not able to change them */
Nice catch
A message that is not in the archive (sent off-list or not yet received): 20130306073515.0015029b-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Pavel Shilovsky
Reviewed-byRe: [PATCH 1/3] cifs: Fix bug when checking error condition in cifs_rename_pending_delete()
2013/3/6 Jeff Layton <[email protected]>:
Quoted 27 lines
Quoted 13 lines · On Tue, 5 Mar 2013 19:25:55 +0000 Sachin Prabhu…
Fix check for error condition after setting attributes with
CIFSSMBSetFileInfo().Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/inode.c +0
-0fs/cifs/inode.c cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, · line 1020
Quoted 8 lines
fs/cifs/inode.c +1
-1@@ -1014,7 +1014,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, current->tgid);/* although we would like to mark the file hidden if that fails we will still try to rename it */ -if (rc !=0 ) +if (!rc) cifsInode->cifsAttrs = dosattr;else dosattr = origattr;/* since not able to change them */ Nice catch
Quoted 5 lines
Reviewed-by Jeff Layton <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards, Pavel Shilovsky.
PATCH 2/3 cifs: Check server capability before attempting silly rename
In reply to a message not in the archivecifs_rename_pending_delete() attempts to silly rename file using CIFSSMBRenameOpenFile(). This uses the SET_FILE_INFORMATION TRANS2 command with information level set to the passthru info-level SMB_SET_FILE_RENAME_INFORMATION.
We need to check to make sure that the server support passthru info-levels before attempting the silly rename or else we will fail to rename the file.
--- fs/cifs/inode.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/cifs/inode.c +9 -0
@@ -986,6 +986,15 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,return PTR_ERR (tlink); tcon =tlink_tcon (tlink); +/* +* We cannot rename the file if the server doesn't support +* CAP_INFOLEVEL_PASSTHRU +*/ +if (!(tcon->ses->capabilities &CAP_INFOLEVEL_PASSTHRU )) { + rc = -EBUSY ; + goto out; + } + rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR, &netfid, &oplock, NULL, cifs_sb->local_nls,
Signature · 1 line
1.7.11.7
A message that is not in the archive (sent off-list or not yet received): 1362511557-22607-3-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Jeff Layton
Reviewed-byRe: [PATCH 2/3] cifs: Check server capability before attempting silly rename
Quoted 24 lines · On Tue, 5 Mar 2013 19:25:56 +0000 Sachin Prabhu…
cifs_rename_pending_delete()attempts to silly rename file usingCIFSSMBRenameOpenFile(). This uses theSET_FILE_INFORMATIONTRANS2 command with information level set to the passthru info-levelSMB_SET_FILE_RENAME_INFORMATION.We need to check to make sure that the server support passthru info-levels before attempting the silly rename or else we will fail to rename the file.
Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/inode.c | 9 +++++++++ 1 file changed, 9 insertions(+)fs/cifs/inode.c +2
-0@@ -986,6 +986,15 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,return PTR_ERR (tlink); tcon =tlink_tcon (tlink); +/* +* We cannot rename the file if the server doesn't support
fs/cifs/inode.c cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, · line 1000
Quoted 10 lines
fs/cifs/inode.c +7
-0+* CAP_INFOLEVEL_PASSTHRU +*/ +if (!(tcon->ses->capabilities &CAP_INFOLEVEL_PASSTHRU )) { + rc = -EBUSY ; + goto out; + } + rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR, &netfid, &oplock, NULL, cifs_sb->local_nls,
We almost certainly need to do the same in other places too. The cifs code does too much "try and fall back" when it should first check for capabilities. Keep your eyes open for others!
PATCH 3/3 cifs: Return EBUSY instead of ETXTBSY in cifs_rename_pending_delete()
In reply to a message not in the archiveInstead of remapping ETXTBSY errors to EBUSY in cifs_unlink, replace all cases of ETXTBSY in cifs_rename_pending_delete() with EBUSY.
--- fs/cifs/inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/cifs/inode.c +2 -4
@@ -1034,7 +1034,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_setattr; }
@@ -1053,7 +1053,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,if (rc == -ENOENT ) rc =0 ;else if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_rename; } cifsInode->delete_pending = true;
@@ -1167,8 +1167,6 @@ psx_del_no_retry:if (rc ==0 )cifs_drop_nlink (inode); } -if (rc == -ETXTBSY ) - rc = -EBUSY ; }else if ((rc == -EACCES ) && (dosattr ==0 ) && inode) { attrs =kzalloc (sizeof (*attrs),GFP_KERNEL );if (attrs ==NULL ) {
Signature · 1 line
1.7.11.7
A message that is not in the archive (sent off-list or not yet received): 1362511557-22607-4-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 3/3] cifs: Return EBUSY instead of ETXTBSY in cifs_rename_pending_delete()
Quoted 31 lines · On Tue, 5 Mar 2013 19:25:57 +0000 Sachin Prabhu…
Instead of remapping ETXTBSY errors to EBUSY in
cifs_unlink, replace all cases of ETXTBSY incifs_rename_pending_delete()with EBUSY.Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/cifs/inode.c +2
-2@@ -1034,7 +1034,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_setattr; }@@ -1053,7 +1053,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,if (rc == -ENOENT ) rc =0 ;else if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_rename; } cifsInode->delete_pending = true;
fs/cifs/inode.c psx_del_no_retry: · line 1171
Quoted 5 lines
fs/cifs/inode.c +0
-2@@ -1167,8 +1167,6 @@ psx_del_no_retry:if (rc ==0 )cifs_drop_nlink (inode); } -if (rc == -ETXTBSY ) - rc = -EBUSY ;
This doesn't look quite right. If ->rename_pending_delete isn't set, then rc will still stay -ETXTBSY. I think this is a good cleanup, but we need to consider changing the mapping for NT_STATUS_SHARING_VIOLATION to -EBUSY as well, and fix all of the places that look for -ETXTBSY in the cifs code.
Quoted 3 lines
fs/cifs/inode.c +0
-0}else if ((rc == -EACCES ) && (dosattr ==0 ) && inode) { attrs =kzalloc (sizeof (*attrs),GFP_KERNEL );if (attrs ==NULL ) {
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20130306073902.729a62cd-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Re: [PATCH 3/3] cifs: Return EBUSY instead of ETXTBSY in cifs_rename_pending_delete()
Does someone have a good explanation of the difference between text file busy and device busy? almost seems like we should be returning EXTBUSY more based on the description
Quoted 60 lines · Jeff Layton
Quoted 31 lines · On Tue, 5 Mar 2013 19:25:57 +0000 Sachin Prabhu…
Instead of remapping ETXTBSY errors to EBUSY in
cifs_unlink, replace all cases of ETXTBSY incifs_rename_pending_delete()with EBUSY.Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/cifs/inode.c +2
-2@@ -1034,7 +1034,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_setattr; }@@ -1053,7 +1053,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,if (rc == -ENOENT ) rc =0 ;else if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_rename; } cifsInode->delete_pending = true;fs/cifs/inode.c psx_del_no_retry: · line 1171
Quoted 5 lines
fs/cifs/inode.c +0
-2@@ -1167,8 +1167,6 @@ psx_del_no_retry:if (rc ==0 )cifs_drop_nlink (inode); } -if (rc == -ETXTBSY ) - rc = -EBUSY ;This doesn't look quite right. If ->rename_pending_delete isn't set, then rc will still stay
-ETXTBSY. I think this is a good cleanup, but we need to consider changing the mapping forNT_STATUS_SHARING_VIOLATIONto-EBUSYas well, and fix all of the places that look for-ETXTBSYin the cifs code.fs/cifs/inode.c psx_del_no_retry: · line 1172
Quoted 3 lines
fs/cifs/inode.c +0
-0}else if ((rc == -EACCES ) && (dosattr ==0 ) && inode) { attrs =kzalloc (sizeof (*attrs),GFP_KERNEL );if (attrs ==NULL ) {--
Jeff Layton <[email protected]> --
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): CAH2r5muN23HcNAwSkgFHg9rWfLw4mV=TaVUiKG71bsH_-M22yA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/3] cifs: Return EBUSY instead of ETXTBSY in cifs_rename_pending_delete()
Quoted 4 lines · On Wed, 6 Mar 2013 18:32:46 -0600 Steve French…
Does someone have a good explanation of the difference between text file busy and device busy? almost seems like we should be returning EXTBUSY more based on the description
ETXTBSY has a more specific meaning on Linux. Mostly, it's used when you try to alter a binary that's being executed (though there are other uses -- see mmap(2) for instance).
EBUSY is more general: "Device or Resource busy". That error seems more appropriate to me in this case. It's also listed as a well-recognized error in the unlink(2) manpage and here:
http://pubs.opengroup.org/onlinepubs/009604599/functions/unlink.html
The latter page also lists ETXTBSY as a valid return code, but it has a somewhat more obscure meaning there.
Quoted 64 lines · Jeff Layton
Quoted 60 lines
Quoted 31 lines · On Tue, 5 Mar 2013 19:25:57 +0000 Sachin Prabhu…
Instead of remapping ETXTBSY errors to EBUSY in
cifs_unlink, replace all cases of ETXTBSY incifs_rename_pending_delete()with EBUSY.Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/cifs/inode.c +2
-2@@ -1034,7 +1034,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_setattr; }@@ -1053,7 +1053,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,if (rc == -ENOENT ) rc =0 ;else if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_rename; } cifsInode->delete_pending = true;fs/cifs/inode.c psx_del_no_retry: · line 1171
Quoted 5 lines
fs/cifs/inode.c +0
-2@@ -1167,8 +1167,6 @@ psx_del_no_retry:if (rc ==0 )cifs_drop_nlink (inode); } -if (rc == -ETXTBSY ) - rc = -EBUSY ;This doesn't look quite right. If ->rename_pending_delete isn't set, then rc will still stay
-ETXTBSY. I think this is a good cleanup, but we need to consider changing the mapping forNT_STATUS_SHARING_VIOLATIONto-EBUSYas well, and fix all of the places that look for-ETXTBSYin the cifs code.fs/cifs/inode.c psx_del_no_retry: · line 1172
Quoted 3 lines
fs/cifs/inode.c +0
-0}else if ((rc == -EACCES ) && (dosattr ==0 ) && inode) { attrs =kzalloc (sizeof (*attrs),GFP_KERNEL );if (attrs ==NULL ) {--
Jeff Layton <[email protected]> --
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 3/3] cifs: Return EBUSY instead of ETXTBSY in cifs_rename_pending_delete()
In reply to a message not in the archiveQuoted 42 lines · Jeff Layton
Quoted 31 lines · On Tue, 5 Mar 2013 19:25:57 +0000 Sachin Prabhu…
Instead of remapping ETXTBSY errors to EBUSY in
cifs_unlink, replace all cases of ETXTBSY incifs_rename_pending_delete()with EBUSY.Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/cifs/inode.c +2
-2@@ -1034,7 +1034,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_setattr; }@@ -1053,7 +1053,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,if (rc == -ENOENT ) rc =0 ;else if (rc !=0 ) { - rc = -ETXTBSY ; + rc = -EBUSY ; goto undo_rename; } cifsInode->delete_pending = true;fs/cifs/inode.c psx_del_no_retry: · line 1171
Quoted 5 lines
fs/cifs/inode.c +0
-2@@ -1167,8 +1167,6 @@ psx_del_no_retry:if (rc ==0 )cifs_drop_nlink (inode); } -if (rc == -ETXTBSY ) - rc = -EBUSY ;
Quoted 5 lines
This doesn't look quite right. If ->rename_pending_delete isn't set, then rc will still stay
-ETXTBSY. I think this is a good cleanup, but we need to consider changing the mapping forNT_STATUS_SHARING_VIOLATIONto-EBUSYas well, and fix all of the places that look for-ETXTBSYin the cifs code.
Hello Jeff,
NT_STATUS_SHARING_VIOLATION for smb2 is already set to return -EBUSY in smb2_error_map_table.
I looked into changing NT_STATUS_SHARING_VIOLATION for smb1 to use -EBUSY instead. A quick check shows that NT_STATUS_SHARING_VIOLATION is the only error condition linked to ETXTBSY which in turn is only checked for in cifs_unlink() and in cifs_do_rename().
I then checked all possible error messages returned for smb1 and checked for EBUSY mapped to these error messages. None of those appear to be mapped to EBUSY either.
So making this change should be easy. I'll post the new patch soon.
Sachin Prabhu