Commit 87bc2376 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

smb3: add debug messages for closing unmatched open

Helps distinguish between an interrupted close and a truly
unmatched open.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 7b71843f
...@@ -1552,6 +1552,8 @@ struct close_cancelled_open { ...@@ -1552,6 +1552,8 @@ struct close_cancelled_open {
struct cifs_fid fid; struct cifs_fid fid;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct work_struct work; struct work_struct work;
__u64 mid;
__u16 cmd;
}; };
/* Make code in transport.c a little cleaner by moving /* Make code in transport.c a little cleaner by moving
......
...@@ -729,19 +729,35 @@ smb2_cancelled_close_fid(struct work_struct *work) ...@@ -729,19 +729,35 @@ smb2_cancelled_close_fid(struct work_struct *work)
{ {
struct close_cancelled_open *cancelled = container_of(work, struct close_cancelled_open *cancelled = container_of(work,
struct close_cancelled_open, work); struct close_cancelled_open, work);
struct cifs_tcon *tcon = cancelled->tcon;
int rc;
cifs_dbg(VFS, "Close unmatched open\n"); if (cancelled->mid)
cifs_tcon_dbg(VFS, "Close unmatched open for MID:%llx\n",
cancelled->mid);
else
cifs_tcon_dbg(VFS, "Close interrupted close\n");
SMB2_close(0, cancelled->tcon, cancelled->fid.persistent_fid, rc = SMB2_close(0, tcon, cancelled->fid.persistent_fid,
cancelled->fid.volatile_fid); cancelled->fid.volatile_fid);
cifs_put_tcon(cancelled->tcon); if (rc)
cifs_tcon_dbg(VFS, "Close cancelled mid failed rc:%d\n", rc);
cifs_put_tcon(tcon);
kfree(cancelled); kfree(cancelled);
} }
/* Caller should already has an extra reference to @tcon */ /*
* Caller should already has an extra reference to @tcon
* This function is used to queue work to close a handle to prevent leaks
* on the server.
* We handle two cases. If an open was interrupted after we sent the
* SMB2_CREATE to the server but before we processed the reply, and second
* if a close was interrupted before we sent the SMB2_CLOSE to the server.
*/
static int static int
__smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid,
__u64 volatile_fid) __u64 persistent_fid, __u64 volatile_fid)
{ {
struct close_cancelled_open *cancelled; struct close_cancelled_open *cancelled;
...@@ -752,6 +768,8 @@ __smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, ...@@ -752,6 +768,8 @@ __smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
cancelled->fid.persistent_fid = persistent_fid; cancelled->fid.persistent_fid = persistent_fid;
cancelled->fid.volatile_fid = volatile_fid; cancelled->fid.volatile_fid = volatile_fid;
cancelled->tcon = tcon; cancelled->tcon = tcon;
cancelled->cmd = cmd;
cancelled->mid = mid;
INIT_WORK(&cancelled->work, smb2_cancelled_close_fid); INIT_WORK(&cancelled->work, smb2_cancelled_close_fid);
WARN_ON(queue_work(cifsiod_wq, &cancelled->work) == false); WARN_ON(queue_work(cifsiod_wq, &cancelled->work) == false);
...@@ -769,7 +787,8 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, ...@@ -769,7 +787,8 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
tcon->tc_count++; tcon->tc_count++;
spin_unlock(&cifs_tcp_ses_lock); spin_unlock(&cifs_tcp_ses_lock);
rc = __smb2_handle_cancelled_close(tcon, persistent_fid, volatile_fid); rc = __smb2_handle_cancelled_cmd(tcon, SMB2_CLOSE_HE, 0,
persistent_fid, volatile_fid);
if (rc) if (rc)
cifs_put_tcon(tcon); cifs_put_tcon(tcon);
...@@ -793,7 +812,10 @@ smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server) ...@@ -793,7 +812,10 @@ smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server)
if (!tcon) if (!tcon)
return -ENOENT; return -ENOENT;
rc = __smb2_handle_cancelled_close(tcon, rsp->PersistentFileId, rc = __smb2_handle_cancelled_cmd(tcon,
le16_to_cpu(sync_hdr->Command),
le64_to_cpu(sync_hdr->MessageId),
rsp->PersistentFileId,
rsp->VolatileFileId); rsp->VolatileFileId);
if (rc) if (rc)
cifs_put_tcon(tcon); cifs_put_tcon(tcon);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment