smb3: fix unmount hang in open_shroot
An earlier patch "CIFS: fix deadlock in cached root handling"
did not completely address the deadlock in open_shroot. This
patch addresses the deadlock.
In testing the recent patch:
smb3: improve handling of share deleted (and share recreated)
we were able to reproduce the open_shroot deadlock to one
of the target servers in unmount in a delete share scenario.
Fixes: 7e5a70ad88
("CIFS: fix deadlock in cached root handling")
This is version 2 of this patch. An earlier version of this
patch "smb3: fix unmount hang in open_shroot" had a problem
found by Dan.
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Pavel Shilovsky <pshilov@microsoft.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
CC: Aurelien Aptel <aaptel@suse.com>
CC: Stable <stable@vger.kernel.org>
This commit is contained in:
parent
3e7a02d478
commit
96d9f7ed00
|
@ -658,6 +658,15 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We do not hold the lock for the open because in case
|
||||||
|
* SMB2_open needs to reconnect, it will end up calling
|
||||||
|
* cifs_mark_open_files_invalid() which takes the lock again
|
||||||
|
* thus causing a deadlock
|
||||||
|
*/
|
||||||
|
|
||||||
|
mutex_unlock(&tcon->crfid.fid_mutex);
|
||||||
|
|
||||||
if (smb3_encryption_required(tcon))
|
if (smb3_encryption_required(tcon))
|
||||||
flags |= CIFS_TRANSFORM_REQ;
|
flags |= CIFS_TRANSFORM_REQ;
|
||||||
|
|
||||||
|
@ -679,7 +688,7 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid)
|
||||||
|
|
||||||
rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, &utf16_path);
|
rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, &utf16_path);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto oshr_exit;
|
goto oshr_free;
|
||||||
smb2_set_next_command(tcon, &rqst[0]);
|
smb2_set_next_command(tcon, &rqst[0]);
|
||||||
|
|
||||||
memset(&qi_iov, 0, sizeof(qi_iov));
|
memset(&qi_iov, 0, sizeof(qi_iov));
|
||||||
|
@ -692,18 +701,10 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid)
|
||||||
sizeof(struct smb2_file_all_info) +
|
sizeof(struct smb2_file_all_info) +
|
||||||
PATH_MAX * 2, 0, NULL);
|
PATH_MAX * 2, 0, NULL);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto oshr_exit;
|
goto oshr_free;
|
||||||
|
|
||||||
smb2_set_related(&rqst[1]);
|
smb2_set_related(&rqst[1]);
|
||||||
|
|
||||||
/*
|
|
||||||
* We do not hold the lock for the open because in case
|
|
||||||
* SMB2_open needs to reconnect, it will end up calling
|
|
||||||
* cifs_mark_open_files_invalid() which takes the lock again
|
|
||||||
* thus causing a deadlock
|
|
||||||
*/
|
|
||||||
|
|
||||||
mutex_unlock(&tcon->crfid.fid_mutex);
|
|
||||||
rc = compound_send_recv(xid, ses, flags, 2, rqst,
|
rc = compound_send_recv(xid, ses, flags, 2, rqst,
|
||||||
resp_buftype, rsp_iov);
|
resp_buftype, rsp_iov);
|
||||||
mutex_lock(&tcon->crfid.fid_mutex);
|
mutex_lock(&tcon->crfid.fid_mutex);
|
||||||
|
|
Loading…
Reference in New Issue