diff mbox

[v3] cifs: map NT_STATUS_SHARING_VIOLATION to EBUSY instead of ETXTBSY

Message ID 1363697464-7564-1-git-send-email-sprabhu@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Prabhu March 19, 2013, 12:51 p.m. UTC
NT_SHARING_VIOLATION errors are mapped to ETXTBSY which is unexpected
for operations such as unlink where we can hit these errors.

The patch maps the error NT_SHARING_VIOLATION to EBUSY instead. The
patch also replaces all instances of ETXTBSY in
cifs_rename_pending_delete() with EBUSY.

The patch was a result of a user reporting a ETXTBSY error on performing
an unlink operation caused by the server returning a
NT_SHARING_VIOLATION.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
---
 fs/cifs/inode.c   | 10 ++++------
 fs/cifs/netmisc.c |  2 +-
 2 files changed, 5 insertions(+), 7 deletions(-)

Comments

Jeff Layton March 19, 2013, 1:32 p.m. UTC | #1
On Tue, 19 Mar 2013 12:51:04 +0000
Sachin Prabhu <sprabhu@redhat.com> wrote:

> NT_SHARING_VIOLATION errors are mapped to ETXTBSY which is unexpected
> for operations such as unlink where we can hit these errors.
> 
> The patch maps the error NT_SHARING_VIOLATION to EBUSY instead. The
> patch also replaces all instances of ETXTBSY in
> cifs_rename_pending_delete() with EBUSY.
> 
> The patch was a result of a user reporting a ETXTBSY error on performing
> an unlink operation caused by the server returning a
> NT_SHARING_VIOLATION.
> 
> Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
> ---
>  fs/cifs/inode.c   | 10 ++++------
>  fs/cifs/netmisc.c |  2 +-
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index fee2d40..b97ca5b 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -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;
> @@ -1160,15 +1160,13 @@ psx_del_no_retry:
>  			cifs_drop_nlink(inode);
>  	} else if (rc == -ENOENT) {
>  		d_drop(dentry);
> -	} else if (rc == -ETXTBSY) {
> +	} else if (rc == -EBUSY) {
>  		if (server->ops->rename_pending_delete) {
>  			rc = server->ops->rename_pending_delete(full_path,
>  								dentry, xid);
>  			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) {
> @@ -1509,7 +1507,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
>  	 * source. Note that cross directory moves do not work with
>  	 * rename by filehandle to various Windows servers.
>  	 */
> -	if (rc == 0 || rc != -ETXTBSY)
> +	if (rc == 0 || rc != -EBUSY)
>  		goto do_rename_exit;
>  
>  	/* open-file renames don't work across directories */
> diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
> index a82bc51..c0b25b2 100644
> --- a/fs/cifs/netmisc.c
> +++ b/fs/cifs/netmisc.c
> @@ -62,7 +62,7 @@ static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
>  	{ERRdiffdevice, -EXDEV},
>  	{ERRnofiles, -ENOENT},
>  	{ERRwriteprot, -EROFS},
> -	{ERRbadshare, -ETXTBSY},
> +	{ERRbadshare, -EBUSY},
>  	{ERRlock, -EACCES},
>  	{ERRunsup, -EINVAL},
>  	{ERRnosuchshare, -ENXIO},

Looks correct to me.

Reviewed-by: Jeff Layton <jlayton@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index fee2d40..b97ca5b 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -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;
@@ -1160,15 +1160,13 @@  psx_del_no_retry:
 			cifs_drop_nlink(inode);
 	} else if (rc == -ENOENT) {
 		d_drop(dentry);
-	} else if (rc == -ETXTBSY) {
+	} else if (rc == -EBUSY) {
 		if (server->ops->rename_pending_delete) {
 			rc = server->ops->rename_pending_delete(full_path,
 								dentry, xid);
 			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) {
@@ -1509,7 +1507,7 @@  cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
 	 * source. Note that cross directory moves do not work with
 	 * rename by filehandle to various Windows servers.
 	 */
-	if (rc == 0 || rc != -ETXTBSY)
+	if (rc == 0 || rc != -EBUSY)
 		goto do_rename_exit;
 
 	/* open-file renames don't work across directories */
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index a82bc51..c0b25b2 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -62,7 +62,7 @@  static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
 	{ERRdiffdevice, -EXDEV},
 	{ERRnofiles, -ENOENT},
 	{ERRwriteprot, -EROFS},
-	{ERRbadshare, -ETXTBSY},
+	{ERRbadshare, -EBUSY},
 	{ERRlock, -EACCES},
 	{ERRunsup, -EINVAL},
 	{ERRnosuchshare, -ENXIO},