Skip to content

Commit 9b1a6b7

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make use of smbdirect_socket.send_io.credits.{count,wait_queue}
This will be used by the server too and will allow to create common helper functions. Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent ca48841 commit 9b1a6b7

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

fs/smb/client/cifs_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
493493
sc->recv_io.reassembly.queue_length);
494494
seq_printf(m, "\nCurrent Credits send_credits: %u "
495495
"receive_credits: %u receive_credit_target: %u",
496-
atomic_read(&server->smbd_conn->send_credits),
496+
atomic_read(&sc->send_io.credits.count),
497497
atomic_read(&server->smbd_conn->receive_credits),
498498
server->smbd_conn->receive_credit_target);
499499
seq_printf(m, "\nPending send_pending: %u ",

fs/smb/client/smbdirect.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static int smbd_conn_upcall(
349349
sc->status = SMBDIRECT_SOCKET_DISCONNECTED;
350350
wake_up_all(&sc->status_wait);
351351
wake_up_all(&sc->recv_io.reassembly.wait_queue);
352-
wake_up_all(&info->wait_send_queue);
352+
wake_up_all(&sc->send_io.credits.wait_queue);
353353
break;
354354

355355
default:
@@ -473,7 +473,7 @@ static bool process_negotiation_response(
473473
log_rdma_event(ERR, "error: credits_granted==0\n");
474474
return false;
475475
}
476-
atomic_set(&info->send_credits, le16_to_cpu(packet->credits_granted));
476+
atomic_set(&sc->send_io.credits.count, le16_to_cpu(packet->credits_granted));
477477

478478
atomic_set(&info->receive_credits, 0);
479479

@@ -651,12 +651,12 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
651651
le16_to_cpu(data_transfer->credits_requested);
652652
if (le16_to_cpu(data_transfer->credits_granted)) {
653653
atomic_add(le16_to_cpu(data_transfer->credits_granted),
654-
&info->send_credits);
654+
&sc->send_io.credits.count);
655655
/*
656656
* We have new send credits granted from remote peer
657657
* If any sender is waiting for credits, unblock it
658658
*/
659-
wake_up(&info->wait_send_queue);
659+
wake_up(&sc->send_io.credits.wait_queue);
660660
}
661661

662662
log_incoming(INFO, "data flags %d data_offset %d data_length %d remaining_data_length %d\n",
@@ -1021,8 +1021,8 @@ static int smbd_post_send_iter(struct smbd_connection *info,
10211021

10221022
wait_credit:
10231023
/* Wait for send credits. A SMBD packet needs one credit */
1024-
rc = wait_event_interruptible(info->wait_send_queue,
1025-
atomic_read(&info->send_credits) > 0 ||
1024+
rc = wait_event_interruptible(sc->send_io.credits.wait_queue,
1025+
atomic_read(&sc->send_io.credits.count) > 0 ||
10261026
sc->status != SMBDIRECT_SOCKET_CONNECTED);
10271027
if (rc)
10281028
goto err_wait_credit;
@@ -1032,8 +1032,8 @@ static int smbd_post_send_iter(struct smbd_connection *info,
10321032
rc = -EAGAIN;
10331033
goto err_wait_credit;
10341034
}
1035-
if (unlikely(atomic_dec_return(&info->send_credits) < 0)) {
1036-
atomic_inc(&info->send_credits);
1035+
if (unlikely(atomic_dec_return(&sc->send_io.credits.count) < 0)) {
1036+
atomic_inc(&sc->send_io.credits.count);
10371037
goto wait_credit;
10381038
}
10391039

@@ -1162,7 +1162,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
11621162

11631163
err_wait_send_queue:
11641164
/* roll back send credits and pending */
1165-
atomic_inc(&info->send_credits);
1165+
atomic_inc(&sc->send_io.credits.count);
11661166

11671167
err_wait_credit:
11681168
return rc;
@@ -1843,7 +1843,6 @@ static struct smbd_connection *_smbd_get_connection(
18431843
goto allocate_cache_failed;
18441844
}
18451845

1846-
init_waitqueue_head(&info->wait_send_queue);
18471846
INIT_DELAYED_WORK(&info->idle_timer_work, idle_connection_timer);
18481847
queue_delayed_work(info->workqueue, &info->idle_timer_work,
18491848
msecs_to_jiffies(sp->keepalive_interval_msec));

fs/smb/client/smbdirect.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ struct smbd_connection {
5353
/* dynamic connection parameters defined in [MS-SMBD] 3.1.1.1 */
5454
enum keep_alive_status keep_alive_requested;
5555
int protocol;
56-
atomic_t send_credits;
5756
atomic_t receive_credits;
5857
int receive_credit_target;
5958

@@ -88,8 +87,6 @@ struct smbd_connection {
8887

8988
bool send_immediate;
9089

91-
wait_queue_head_t wait_send_queue;
92-
9390
struct workqueue_struct *workqueue;
9491
struct delayed_work idle_timer_work;
9592

0 commit comments

Comments
 (0)