aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2019-05-05 20:00:02 -0400
committerSteve French <stfrench@microsoft.com>2019-05-08 00:24:55 -0400
commit392e1c5dc9cc93a8fffbd6230c12c9f38693e634 (patch)
tree2fb6728475227c50711880f1a95107a4f91e0384
parentd69cb728e70c40268762182a62f5d5d6fa51c5b2 (diff)
cifs: rename and clarify CIFS_ASYNC_OP and CIFS_NO_RESP
The flags were named confusingly. CIFS_ASYNC_OP now just means that we will not block waiting for credits to become available so we thus rename this to be CIFS_NON_BLOCKING. Change CIFS_NO_RESP to CIFS_NO_RSP_BUF to clarify that we will actually get a response from the server but we will not get/do not want a response buffer. Delete CIFSSMBNotify. This is an SMB1 function that is not used. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
-rw-r--r--fs/cifs/cifsglob.h4
-rw-r--r--fs/cifs/cifssmb.c98
-rw-r--r--fs/cifs/smb2pdu.c10
-rw-r--r--fs/cifs/transport.c9
4 files changed, 14 insertions, 107 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 65faad3aa69a..c22ab330238c 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1689,11 +1689,11 @@ static inline bool is_retryable_error(int error)
1689 1689
1690/* Type of Request to SendReceive2 */ 1690/* Type of Request to SendReceive2 */
1691#define CIFS_BLOCKING_OP 1 /* operation can block */ 1691#define CIFS_BLOCKING_OP 1 /* operation can block */
1692#define CIFS_ASYNC_OP 2 /* do not wait for response */ 1692#define CIFS_NON_BLOCKING 2 /* do not block waiting for credits */
1693#define CIFS_TIMEOUT_MASK 0x003 /* only one of above set in req */ 1693#define CIFS_TIMEOUT_MASK 0x003 /* only one of above set in req */
1694#define CIFS_LOG_ERROR 0x010 /* log NT STATUS if non-zero */ 1694#define CIFS_LOG_ERROR 0x010 /* log NT STATUS if non-zero */
1695#define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */ 1695#define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */
1696#define CIFS_NO_RESP 0x040 /* no response buffer required */ 1696#define CIFS_NO_RSP_BUF 0x040 /* no response buffer required */
1697 1697
1698/* Type of request operation */ 1698/* Type of request operation */
1699#define CIFS_ECHO_OP 0x080 /* echo request */ 1699#define CIFS_ECHO_OP 0x080 /* echo request */
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 6050851edcb8..1fbd92843a73 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -860,7 +860,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
860 iov[1].iov_base = (char *)smb + 4; 860 iov[1].iov_base = (char *)smb + 4;
861 861
862 rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL, 862 rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
863 server, CIFS_ASYNC_OP | CIFS_ECHO_OP, NULL); 863 server, CIFS_NON_BLOCKING | CIFS_ECHO_OP, NULL);
864 if (rc) 864 if (rc)
865 cifs_dbg(FYI, "Echo request failed: %d\n", rc); 865 cifs_dbg(FYI, "Echo request failed: %d\n", rc);
866 866
@@ -2508,8 +2508,8 @@ int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
2508 iov[1].iov_len = (num_unlock + num_lock) * sizeof(LOCKING_ANDX_RANGE); 2508 iov[1].iov_len = (num_unlock + num_lock) * sizeof(LOCKING_ANDX_RANGE);
2509 2509
2510 cifs_stats_inc(&tcon->stats.cifs_stats.num_locks); 2510 cifs_stats_inc(&tcon->stats.cifs_stats.num_locks);
2511 rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type, CIFS_NO_RESP, 2511 rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type,
2512 &rsp_iov); 2512 CIFS_NO_RSP_BUF, &rsp_iov);
2513 cifs_small_buf_release(pSMB); 2513 cifs_small_buf_release(pSMB);
2514 if (rc) 2514 if (rc)
2515 cifs_dbg(FYI, "Send error in cifs_lockv = %d\n", rc); 2515 cifs_dbg(FYI, "Send error in cifs_lockv = %d\n", rc);
@@ -2540,7 +2540,7 @@ CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
2540 2540
2541 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) { 2541 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
2542 /* no response expected */ 2542 /* no response expected */
2543 flags = CIFS_NO_SRV_RSP | CIFS_ASYNC_OP | CIFS_OBREAK_OP; 2543 flags = CIFS_NO_SRV_RSP | CIFS_NON_BLOCKING | CIFS_OBREAK_OP;
2544 pSMB->Timeout = 0; 2544 pSMB->Timeout = 0;
2545 } else if (waitFlag) { 2545 } else if (waitFlag) {
2546 flags = CIFS_BLOCKING_OP; /* blocking operation, no timeout */ 2546 flags = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
@@ -6567,93 +6567,3 @@ SetEARetry:
6567 return rc; 6567 return rc;
6568} 6568}
6569#endif 6569#endif
6570
6571#ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* BB unused temporarily */
6572/*
6573 * Years ago the kernel added a "dnotify" function for Samba server,
6574 * to allow network clients (such as Windows) to display updated
6575 * lists of files in directory listings automatically when
6576 * files are added by one user when another user has the
6577 * same directory open on their desktop. The Linux cifs kernel
6578 * client hooked into the kernel side of this interface for
6579 * the same reason, but ironically when the VFS moved from
6580 * "dnotify" to "inotify" it became harder to plug in Linux
6581 * network file system clients (the most obvious use case
6582 * for notify interfaces is when multiple users can update
6583 * the contents of the same directory - exactly what network
6584 * file systems can do) although the server (Samba) could
6585 * still use it. For the short term we leave the worker
6586 * function ifdeffed out (below) until inotify is fixed
6587 * in the VFS to make it easier to plug in network file
6588 * system clients. If inotify turns out to be permanently
6589 * incompatible for network fs clients, we could instead simply
6590 * expose this config flag by adding a future cifs (and smb2) notify ioctl.
6591 */
6592int CIFSSMBNotify(const unsigned int xid, struct cifs_tcon *tcon,
6593 const int notify_subdirs, const __u16 netfid,
6594 __u32 filter, struct file *pfile, int multishot,
6595 const struct nls_table *nls_codepage)
6596{
6597 int rc = 0;
6598 struct smb_com_transaction_change_notify_req *pSMB = NULL;
6599 struct smb_com_ntransaction_change_notify_rsp *pSMBr = NULL;
6600 struct dir_notify_req *dnotify_req;
6601 int bytes_returned;
6602
6603 cifs_dbg(FYI, "In CIFSSMBNotify for file handle %d\n", (int)netfid);
6604 rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB,
6605 (void **) &pSMBr);
6606 if (rc)
6607 return rc;
6608
6609 pSMB->TotalParameterCount = 0 ;
6610 pSMB->TotalDataCount = 0;
6611 pSMB->MaxParameterCount = cpu_to_le32(2);
6612 pSMB->MaxDataCount = cpu_to_le32(CIFSMaxBufSize & 0xFFFFFF00);
6613 pSMB->MaxSetupCount = 4;
6614 pSMB->Reserved = 0;
6615 pSMB->ParameterOffset = 0;
6616 pSMB->DataCount = 0;
6617 pSMB->DataOffset = 0;
6618 pSMB->SetupCount = 4; /* single byte does not need le conversion */
6619 pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE);
6620 pSMB->ParameterCount = pSMB->TotalParameterCount;
6621 if (notify_subdirs)
6622 pSMB->WatchTree = 1; /* one byte - no le conversion needed */
6623 pSMB->Reserved2 = 0;
6624 pSMB->CompletionFilter = cpu_to_le32(filter);
6625 pSMB->Fid = netfid; /* file handle always le */
6626 pSMB->ByteCount = 0;
6627
6628 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
6629 (struct smb_hdr *)pSMBr, &bytes_returned,
6630 CIFS_ASYNC_OP);
6631 if (rc) {
6632 cifs_dbg(FYI, "Error in Notify = %d\n", rc);
6633 } else {
6634 /* Add file to outstanding requests */
6635 /* BB change to kmem cache alloc */
6636 dnotify_req = kmalloc(
6637 sizeof(struct dir_notify_req),
6638 GFP_KERNEL);
6639 if (dnotify_req) {
6640 dnotify_req->Pid = pSMB->hdr.Pid;
6641 dnotify_req->PidHigh = pSMB->hdr.PidHigh;
6642 dnotify_req->Mid = pSMB->hdr.Mid;
6643 dnotify_req->Tid = pSMB->hdr.Tid;
6644 dnotify_req->Uid = pSMB->hdr.Uid;
6645 dnotify_req->netfid = netfid;
6646 dnotify_req->pfile = pfile;
6647 dnotify_req->filter = filter;
6648 dnotify_req->multishot = multishot;
6649 spin_lock(&GlobalMid_Lock);
6650 list_add_tail(&dnotify_req->lhead,
6651 &GlobalDnotifyReqList);
6652 spin_unlock(&GlobalMid_Lock);
6653 } else
6654 rc = -ENOMEM;
6655 }
6656 cifs_buf_release(pSMB);
6657 return rc;
6658}
6659#endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 634800c0bc06..035a568b3dbd 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1538,7 +1538,7 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses)
1538 else if (server->sign) 1538 else if (server->sign)
1539 req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 1539 req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED;
1540 1540
1541 flags |= CIFS_NO_RESP; 1541 flags |= CIFS_NO_RSP_BUF;
1542 1542
1543 iov[0].iov_base = (char *)req; 1543 iov[0].iov_base = (char *)req;
1544 iov[0].iov_len = total_len; 1544 iov[0].iov_len = total_len;
@@ -1739,7 +1739,7 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon)
1739 if (smb3_encryption_required(tcon)) 1739 if (smb3_encryption_required(tcon))
1740 flags |= CIFS_TRANSFORM_REQ; 1740 flags |= CIFS_TRANSFORM_REQ;
1741 1741
1742 flags |= CIFS_NO_RESP; 1742 flags |= CIFS_NO_RSP_BUF;
1743 1743
1744 iov[0].iov_base = (char *)req; 1744 iov[0].iov_base = (char *)req;
1745 iov[0].iov_len = total_len; 1745 iov[0].iov_len = total_len;
@@ -4166,7 +4166,7 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
4166 req->OplockLevel = oplock_level; 4166 req->OplockLevel = oplock_level;
4167 req->sync_hdr.CreditRequest = cpu_to_le16(1); 4167 req->sync_hdr.CreditRequest = cpu_to_le16(1);
4168 4168
4169 flags |= CIFS_NO_RESP; 4169 flags |= CIFS_NO_RSP_BUF;
4170 4170
4171 iov[0].iov_base = (char *)req; 4171 iov[0].iov_base = (char *)req;
4172 iov[0].iov_len = total_len; 4172 iov[0].iov_len = total_len;
@@ -4440,7 +4440,7 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
4440 struct kvec rsp_iov; 4440 struct kvec rsp_iov;
4441 int resp_buf_type; 4441 int resp_buf_type;
4442 unsigned int count; 4442 unsigned int count;
4443 int flags = CIFS_NO_RESP; 4443 int flags = CIFS_NO_RSP_BUF;
4444 unsigned int total_len; 4444 unsigned int total_len;
4445 4445
4446 cifs_dbg(FYI, "smb2_lockv num lock %d\n", num_lock); 4446 cifs_dbg(FYI, "smb2_lockv num lock %d\n", num_lock);
@@ -4533,7 +4533,7 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
4533 memcpy(req->LeaseKey, lease_key, 16); 4533 memcpy(req->LeaseKey, lease_key, 16);
4534 req->LeaseState = lease_state; 4534 req->LeaseState = lease_state;
4535 4535
4536 flags |= CIFS_NO_RESP; 4536 flags |= CIFS_NO_RSP_BUF;
4537 4537
4538 iov[0].iov_base = (char *)req; 4538 iov[0].iov_base = (char *)req;
4539 iov[0].iov_len = total_len; 4539 iov[0].iov_len = total_len;
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 5573e38b13f3..9a16ff4b9f5e 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -529,7 +529,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
529 return -EAGAIN; 529 return -EAGAIN;
530 530
531 spin_lock(&server->req_lock); 531 spin_lock(&server->req_lock);
532 if ((flags & CIFS_TIMEOUT_MASK) == CIFS_ASYNC_OP) { 532 if ((flags & CIFS_TIMEOUT_MASK) == CIFS_NON_BLOCKING) {
533 /* oplock breaks must not be held up */ 533 /* oplock breaks must not be held up */
534 server->in_flight++; 534 server->in_flight++;
535 *credits -= 1; 535 *credits -= 1;
@@ -838,7 +838,7 @@ SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
838 838
839 iov[0].iov_base = in_buf; 839 iov[0].iov_base = in_buf;
840 iov[0].iov_len = get_rfc1002_length(in_buf) + 4; 840 iov[0].iov_len = get_rfc1002_length(in_buf) + 4;
841 flags |= CIFS_NO_RESP; 841 flags |= CIFS_NO_RSP_BUF;
842 rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); 842 rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov);
843 cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc); 843 cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc);
844 844
@@ -1151,7 +1151,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
1151 flags & CIFS_LOG_ERROR); 1151 flags & CIFS_LOG_ERROR);
1152 1152
1153 /* mark it so buf will not be freed by cifs_delete_mid */ 1153 /* mark it so buf will not be freed by cifs_delete_mid */
1154 if ((flags & CIFS_NO_RESP) == 0) 1154 if ((flags & CIFS_NO_RSP_BUF) == 0)
1155 midQ[i]->resp_buf = NULL; 1155 midQ[i]->resp_buf = NULL;
1156 1156
1157 } 1157 }
@@ -1302,9 +1302,6 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
1302 if (rc < 0) 1302 if (rc < 0)
1303 goto out; 1303 goto out;
1304 1304
1305 if ((flags & CIFS_TIMEOUT_MASK) == CIFS_ASYNC_OP)
1306 goto out;
1307
1308 rc = wait_for_response(ses->server, midQ); 1305 rc = wait_for_response(ses->server, midQ);
1309 if (rc != 0) { 1306 if (rc != 0) {
1310 send_cancel(ses->server, &rqst, midQ); 1307 send_cancel(ses->server, &rqst, midQ);