Skip to content

Commit f2b2465

Browse files
committed
Merge tag '6.18-rc2-smb-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - add missing tracepoints - smbdirect (RDMA) fix - fix potential issue with credits underflow - rename fix - improvement to calc_signature and additional cleanup patch * tag '6.18-rc2-smb-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: #include cifsglob.h before trace.h to allow structs in tracepoints cifs: Call the calc_signature functions directly smb: client: get rid of d_drop() in cifs_do_rename() cifs: Fix TCP_Server_Info::credits to be signed cifs: Add a couple of missing smb3_rw_credits tracepoints smb: client: allocate enough space for MR WRs and ib_drain_qp()
2 parents d281851 + 64c9471 commit f2b2465

File tree

9 files changed

+44
-39
lines changed

9 files changed

+44
-39
lines changed

fs/smb/client/cifsglob.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,6 @@ struct smb_version_operations {
534534
void (*new_lease_key)(struct cifs_fid *);
535535
int (*generate_signingkey)(struct cifs_ses *ses,
536536
struct TCP_Server_Info *server);
537-
int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *,
538-
bool allocate_crypto);
539537
int (*set_integrity)(const unsigned int, struct cifs_tcon *tcon,
540538
struct cifsFileInfo *src_file);
541539
int (*enum_snapshots)(const unsigned int xid, struct cifs_tcon *tcon,
@@ -732,7 +730,7 @@ struct TCP_Server_Info {
732730
bool nosharesock;
733731
bool tcp_nodelay;
734732
bool terminate;
735-
unsigned int credits; /* send no more requests at once */
733+
int credits; /* send no more requests at once */
736734
unsigned int max_credits; /* can override large 32000 default at mnt */
737735
unsigned int in_flight; /* number of requests on the wire to server */
738736
unsigned int max_in_flight; /* max number of requests that were on wire */

fs/smb/client/cifsproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define _CIFSPROTO_H
1010
#include <linux/nls.h>
1111
#include <linux/ctype.h>
12+
#include "cifsglob.h"
1213
#include "trace.h"
1314
#ifdef CONFIG_CIFS_DFS_UPCALL
1415
#include "dfs_cache.h"

fs/smb/client/cifssmb.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,8 @@ cifs_readv_callback(struct mid_q_entry *mid)
13111311
.rreq_debug_id = rdata->rreq->debug_id,
13121312
.rreq_debug_index = rdata->subreq.debug_index,
13131313
};
1314+
unsigned int rreq_debug_id = rdata->rreq->debug_id;
1315+
unsigned int subreq_debug_index = rdata->subreq.debug_index;
13141316

13151317
cifs_dbg(FYI, "%s: mid=%llu state=%d result=%d bytes=%zu\n",
13161318
__func__, mid->mid, mid->mid_state, rdata->result,
@@ -1374,13 +1376,19 @@ cifs_readv_callback(struct mid_q_entry *mid)
13741376
__set_bit(NETFS_SREQ_MADE_PROGRESS, &rdata->subreq.flags);
13751377
}
13761378

1379+
trace_smb3_rw_credits(rreq_debug_id, subreq_debug_index, rdata->credits.value,
1380+
server->credits, server->in_flight,
1381+
0, cifs_trace_rw_credits_read_response_clear);
13771382
rdata->credits.value = 0;
13781383
rdata->subreq.error = rdata->result;
13791384
rdata->subreq.transferred += rdata->got_bytes;
13801385
trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_progress);
13811386
netfs_read_subreq_terminated(&rdata->subreq);
13821387
release_mid(mid);
13831388
add_credits(server, &credits, 0);
1389+
trace_smb3_rw_credits(rreq_debug_id, subreq_debug_index, 0,
1390+
server->credits, server->in_flight,
1391+
credits.value, cifs_trace_rw_credits_read_response_add);
13841392
}
13851393

13861394
/* cifs_async_readv - send an async write, and set up mid to handle result */

fs/smb/client/inode.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,11 +2484,8 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
24842484
}
24852485
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
24862486
do_rename_exit:
2487-
if (rc == 0) {
2487+
if (rc == 0)
24882488
d_move(from_dentry, to_dentry);
2489-
/* Force a new lookup */
2490-
d_drop(from_dentry);
2491-
}
24922489
cifs_put_tlink(tlink);
24932490
return rc;
24942491
}

fs/smb/client/smb2ops.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5446,7 +5446,6 @@ struct smb_version_operations smb20_operations = {
54465446
.get_lease_key = smb2_get_lease_key,
54475447
.set_lease_key = smb2_set_lease_key,
54485448
.new_lease_key = smb2_new_lease_key,
5449-
.calc_signature = smb2_calc_signature,
54505449
.is_read_op = smb2_is_read_op,
54515450
.set_oplock_level = smb2_set_oplock_level,
54525451
.create_lease_buf = smb2_create_lease_buf,
@@ -5550,7 +5549,6 @@ struct smb_version_operations smb21_operations = {
55505549
.get_lease_key = smb2_get_lease_key,
55515550
.set_lease_key = smb2_set_lease_key,
55525551
.new_lease_key = smb2_new_lease_key,
5553-
.calc_signature = smb2_calc_signature,
55545552
.is_read_op = smb21_is_read_op,
55555553
.set_oplock_level = smb21_set_oplock_level,
55565554
.create_lease_buf = smb2_create_lease_buf,
@@ -5660,7 +5658,6 @@ struct smb_version_operations smb30_operations = {
56605658
.set_lease_key = smb2_set_lease_key,
56615659
.new_lease_key = smb2_new_lease_key,
56625660
.generate_signingkey = generate_smb30signingkey,
5663-
.calc_signature = smb3_calc_signature,
56645661
.set_integrity = smb3_set_integrity,
56655662
.is_read_op = smb21_is_read_op,
56665663
.set_oplock_level = smb3_set_oplock_level,
@@ -5777,7 +5774,6 @@ struct smb_version_operations smb311_operations = {
57775774
.set_lease_key = smb2_set_lease_key,
57785775
.new_lease_key = smb2_new_lease_key,
57795776
.generate_signingkey = generate_smb311signingkey,
5780-
.calc_signature = smb3_calc_signature,
57815777
.set_integrity = smb3_set_integrity,
57825778
.is_read_op = smb21_is_read_op,
57835779
.set_oplock_level = smb3_set_oplock_level,

fs/smb/client/smb2proto.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ extern struct mid_q_entry *smb2_setup_async_request(
3939
struct TCP_Server_Info *server, struct smb_rqst *rqst);
4040
extern struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server,
4141
__u64 ses_id, __u32 tid);
42-
extern int smb2_calc_signature(struct smb_rqst *rqst,
43-
struct TCP_Server_Info *server,
44-
bool allocate_crypto);
45-
extern int smb3_calc_signature(struct smb_rqst *rqst,
46-
struct TCP_Server_Info *server,
47-
bool allocate_crypto);
4842
extern void smb2_echo_request(struct work_struct *work);
4943
extern __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode);
5044
extern bool smb2_is_valid_oplock_break(char *buffer,

fs/smb/client/smb2transport.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ smb2_find_smb_tcon(struct TCP_Server_Info *server, __u64 ses_id, __u32 tid)
209209
return tcon;
210210
}
211211

212-
int
212+
static int
213213
smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
214-
bool allocate_crypto)
214+
bool allocate_crypto)
215215
{
216216
int rc;
217217
unsigned char smb2_signature[SMB2_HMACSHA256_SIZE];
@@ -465,9 +465,9 @@ generate_smb311signingkey(struct cifs_ses *ses,
465465
return generate_smb3signingkey(ses, server, &triplet);
466466
}
467467

468-
int
468+
static int
469469
smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
470-
bool allocate_crypto)
470+
bool allocate_crypto)
471471
{
472472
int rc;
473473
unsigned char smb3_signature[SMB2_CMACAES_SIZE];
@@ -477,6 +477,9 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
477477
struct smb_rqst drqst;
478478
u8 key[SMB3_SIGN_KEY_SIZE];
479479

480+
if (server->vals->protocol_id <= SMB21_PROT_ID)
481+
return smb2_calc_signature(rqst, server, allocate_crypto);
482+
480483
rc = smb3_get_sign_key(le64_to_cpu(shdr->SessionId), server, key);
481484
if (unlikely(rc)) {
482485
cifs_server_dbg(FYI, "%s: Could not get signing key\n", __func__);
@@ -547,7 +550,6 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
547550
static int
548551
smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server)
549552
{
550-
int rc = 0;
551553
struct smb2_hdr *shdr;
552554
struct smb2_sess_setup_req *ssr;
553555
bool is_binding;
@@ -574,9 +576,7 @@ smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server)
574576
return 0;
575577
}
576578

577-
rc = server->ops->calc_signature(rqst, server, false);
578-
579-
return rc;
579+
return smb3_calc_signature(rqst, server, false);
580580
}
581581

582582
int
@@ -612,7 +612,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
612612

613613
memset(shdr->Signature, 0, SMB2_SIGNATURE_SIZE);
614614

615-
rc = server->ops->calc_signature(rqst, server, true);
615+
rc = smb3_calc_signature(rqst, server, true);
616616

617617
if (rc)
618618
return rc;

fs/smb/client/smbdirect.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,7 @@ static struct smbd_connection *_smbd_get_connection(
17671767
struct smbdirect_socket *sc;
17681768
struct smbdirect_socket_parameters *sp;
17691769
struct rdma_conn_param conn_param;
1770+
struct ib_qp_cap qp_cap;
17701771
struct ib_qp_init_attr qp_attr;
17711772
struct sockaddr_in *addr_in = (struct sockaddr_in *) dstaddr;
17721773
struct ib_port_immutable port_immutable;
@@ -1838,6 +1839,25 @@ static struct smbd_connection *_smbd_get_connection(
18381839
goto config_failed;
18391840
}
18401841

1842+
sp->responder_resources =
1843+
min_t(u8, sp->responder_resources,
1844+
sc->ib.dev->attrs.max_qp_rd_atom);
1845+
log_rdma_mr(INFO, "responder_resources=%d\n",
1846+
sp->responder_resources);
1847+
1848+
/*
1849+
* We use allocate sp->responder_resources * 2 MRs
1850+
* and each MR needs WRs for REG and INV, so
1851+
* we use '* 4'.
1852+
*
1853+
* +1 for ib_drain_qp()
1854+
*/
1855+
memset(&qp_cap, 0, sizeof(qp_cap));
1856+
qp_cap.max_send_wr = sp->send_credit_target + sp->responder_resources * 4 + 1;
1857+
qp_cap.max_recv_wr = sp->recv_credit_max + 1;
1858+
qp_cap.max_send_sge = SMBDIRECT_SEND_IO_MAX_SGE;
1859+
qp_cap.max_recv_sge = SMBDIRECT_RECV_IO_MAX_SGE;
1860+
18411861
sc->ib.pd = ib_alloc_pd(sc->ib.dev, 0);
18421862
if (IS_ERR(sc->ib.pd)) {
18431863
rc = PTR_ERR(sc->ib.pd);
@@ -1848,15 +1868,15 @@ static struct smbd_connection *_smbd_get_connection(
18481868

18491869
sc->ib.send_cq =
18501870
ib_alloc_cq_any(sc->ib.dev, sc,
1851-
sp->send_credit_target, IB_POLL_SOFTIRQ);
1871+
qp_cap.max_send_wr, IB_POLL_SOFTIRQ);
18521872
if (IS_ERR(sc->ib.send_cq)) {
18531873
sc->ib.send_cq = NULL;
18541874
goto alloc_cq_failed;
18551875
}
18561876

18571877
sc->ib.recv_cq =
18581878
ib_alloc_cq_any(sc->ib.dev, sc,
1859-
sp->recv_credit_max, IB_POLL_SOFTIRQ);
1879+
qp_cap.max_recv_wr, IB_POLL_SOFTIRQ);
18601880
if (IS_ERR(sc->ib.recv_cq)) {
18611881
sc->ib.recv_cq = NULL;
18621882
goto alloc_cq_failed;
@@ -1865,11 +1885,7 @@ static struct smbd_connection *_smbd_get_connection(
18651885
memset(&qp_attr, 0, sizeof(qp_attr));
18661886
qp_attr.event_handler = smbd_qp_async_error_upcall;
18671887
qp_attr.qp_context = sc;
1868-
qp_attr.cap.max_send_wr = sp->send_credit_target;
1869-
qp_attr.cap.max_recv_wr = sp->recv_credit_max;
1870-
qp_attr.cap.max_send_sge = SMBDIRECT_SEND_IO_MAX_SGE;
1871-
qp_attr.cap.max_recv_sge = SMBDIRECT_RECV_IO_MAX_SGE;
1872-
qp_attr.cap.max_inline_data = 0;
1888+
qp_attr.cap = qp_cap;
18731889
qp_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
18741890
qp_attr.qp_type = IB_QPT_RC;
18751891
qp_attr.send_cq = sc->ib.send_cq;
@@ -1883,12 +1899,6 @@ static struct smbd_connection *_smbd_get_connection(
18831899
}
18841900
sc->ib.qp = sc->rdma.cm_id->qp;
18851901

1886-
sp->responder_resources =
1887-
min_t(u8, sp->responder_resources,
1888-
sc->ib.dev->attrs.max_qp_rd_atom);
1889-
log_rdma_mr(INFO, "responder_resources=%d\n",
1890-
sp->responder_resources);
1891-
18921902
memset(&conn_param, 0, sizeof(conn_param));
18931903
conn_param.initiator_depth = sp->initiator_depth;
18941904
conn_param.responder_resources = sp->responder_resources;

fs/smb/client/trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
*
55
* Author(s): Steve French <[email protected]>
66
*/
7+
#include "cifsglob.h"
78
#define CREATE_TRACE_POINTS
89
#include "trace.h"

0 commit comments

Comments
 (0)