diff mbox

[2/3] cifs: Check server capability before attempting silly rename

Message ID 1362511557-22607-3-git-send-email-sprabhu@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Prabhu March 5, 2013, 7:25 p.m. UTC
cifs_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.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
---
 fs/cifs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jeff Layton March 6, 2013, 12:36 p.m. UTC | #1
On Tue,  5 Mar 2013 19:25:56 +0000
Sachin Prabhu <sprabhu@redhat.com> wrote:

> cifs_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.
> 
> Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
> ---
>  fs/cifs/inode.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index a183b9d..fee2d40 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -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,

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!

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 a183b9d..fee2d40 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -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,