]> git.ipfire.org Git - thirdparty/kernel/stable.git/log
thirdparty/kernel/stable.git
7 days agosmb: server: remove useless casts from KSMBD_TRANS/SMBD_TRANS
Stefan Metzmacher [Fri, 15 Aug 2025 11:04:31 +0000 (13:04 +0200)] 
smb: server: remove useless casts from KSMBD_TRANS/SMBD_TRANS

At best they gain nothing, at worst we procude real bugs.
Note container_of() already casts to a pointer of the
given type.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: replace smb_trans_direct_transfort() with SMBD_TRANS()
Stefan Metzmacher [Fri, 15 Aug 2025 11:01:30 +0000 (13:01 +0200)] 
smb: server: replace smb_trans_direct_transfort() with SMBD_TRANS()

The spelling of smb_trans_direct_transfort was wrong anyway
and we don't need the logic twice.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.recv_io.{posted,credits}
Stefan Metzmacher [Thu, 14 Aug 2025 14:33:30 +0000 (16:33 +0200)] 
smb: server: make use of smbdirect_socket.recv_io.{posted,credits}

This will make it possible to introduce common helper functions
in future.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: manage recv credits by counting posted recv_io and granted credits
Stefan Metzmacher [Thu, 14 Aug 2025 14:05:47 +0000 (16:05 +0200)] 
smb: server: manage recv credits by counting posted recv_io and granted credits

(At least for me) the logic maintaining the count of posted
recv_io messages and the count of granted credits is much
easier to understand.

From there we can easily calculate the number of new_credits we'll
grant to the peer in outgoing send_io messages.

This will simplify the move to common logic that can be
shared between client and server in the following patches.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: take the recv_credit_target from the negotiate req and always limit...
Stefan Metzmacher [Thu, 14 Aug 2025 13:50:05 +0000 (15:50 +0200)] 
smb: server: take the recv_credit_target from the negotiate req and always limit the range

The clients sends the initial recv_credit_target in the negotiate req,
so we should use that.

We also limit the range between 1 and our local defined
sp->recv_credit_max. This will simplify further logic changes.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of struct smbdirect_rw_io
Stefan Metzmacher [Mon, 18 Aug 2025 19:07:06 +0000 (21:07 +0200)] 
smb: server: make use of struct smbdirect_rw_io

This will allow us to create functions in the common
smbdirect code to be used by the server in future.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use smbdirect_socket.rw_io.credits
Stefan Metzmacher [Thu, 14 Aug 2025 10:01:50 +0000 (12:01 +0200)] 
smb: server: make use smbdirect_socket.rw_io.credits

This will allow to us to have functions moved into
common code in future (even if it's only used by the server).

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of struct smbdirect_send_batch
Stefan Metzmacher [Mon, 18 Aug 2025 19:16:48 +0000 (21:16 +0200)] 
smb: server: make use of struct smbdirect_send_batch

This makes it easier to move functions to the common
smbdirect code in future.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.send_io.credits.{count,wait_queue}
Stefan Metzmacher [Mon, 11 Aug 2025 15:12:58 +0000 (17:12 +0200)] 
smb: server: make use of smbdirect_socket.send_io.credits.{count,wait_queue}

This will is used by the client already and will allow to create
common helper functions.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.send_io.pending.{count,zero_wait_queue}
Stefan Metzmacher [Mon, 11 Aug 2025 13:19:51 +0000 (15:19 +0200)] 
smb: server: make use of smbdirect_socket.send_io.pending.{count,zero_wait_queue}

This will is used by the client already and will allow to create
common helper functions.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.disconnect_work
Stefan Metzmacher [Fri, 8 Aug 2025 17:07:37 +0000 (19:07 +0200)] 
smb: server: make use of smbdirect_socket.disconnect_work

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket_init()
Stefan Metzmacher [Fri, 8 Aug 2025 13:10:52 +0000 (15:10 +0200)] 
smb: server: make use of smbdirect_socket_init()

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: don't wait for info->send_pending == 0 on error
Stefan Metzmacher [Wed, 13 Aug 2025 09:39:19 +0000 (11:39 +0200)] 
smb: server: don't wait for info->send_pending == 0 on error

Instead we just wake up the waiters and let them return -ENOTCONN.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: move smb_direct_disconnect_rdma_work() into free_transport()
Stefan Metzmacher [Tue, 12 Aug 2025 08:55:31 +0000 (10:55 +0200)] 
smb: server: move smb_direct_disconnect_rdma_work() into free_transport()

The logic is also needed when smb_direct_handle_connect_request()
calls free_transport(), because rdma_accept() and RDMA_CM_EVENT_ESTABLISHED
could already be reached.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: only turn into SMBDIRECT_SOCKET_CONNECTED when negotiation is done
Stefan Metzmacher [Fri, 8 Aug 2025 10:46:25 +0000 (12:46 +0200)] 
smb: server: only turn into SMBDIRECT_SOCKET_CONNECTED when negotiation is done

From SMBDIRECT_SOCKET_CREATED we now go via the following
stages:

1. SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED
   This indicated rdma_accept needs to be called

2. SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING
   This waits for RDMA_CM_EVENT_ESTABLISHED to
   arrive

3. SMBDIRECT_SOCKET_NEGOTIATE_NEEDED
   This waits for the negotiate request to
   arrive

4. SMBDIRECT_SOCKET_NEGOTIATE_RUNNING
   This indicates the negotiate request
   arrived and needs to be processed

5. SMBDIRECT_SOCKET_CONNECTED
   The connection is ready to use

This avoids the extra 'bool negotiation_requested'
and makes the steps more clear.

In future we may want to add trace points when
changing the states, which would be useful for
debugging.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.status_wait
Stefan Metzmacher [Thu, 7 Aug 2025 09:20:55 +0000 (11:20 +0200)] 
smb: server: make use of smbdirect_socket.status_wait

This will allow us to have common helper functions soon.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: queue post_recv_credits_work in put_recvmsg() and avoid count_avail_recvmsg
Stefan Metzmacher [Mon, 11 Aug 2025 16:23:03 +0000 (18:23 +0200)] 
smb: server: queue post_recv_credits_work in put_recvmsg() and avoid count_avail_recvmsg

This is basically what the client is doing in put_receive_buffer().

It means we don't need complicated work to maintain count_avail_recvmsg.

But we keep the logic to queue post_recv_credits_work if the
peer raises the requested credit_target and put_receive_buffer()
is not called.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: add a pr_info() when the server starts running
Stefan Metzmacher [Fri, 8 Aug 2025 16:23:59 +0000 (18:23 +0200)] 
smb: server: add a pr_info() when the server starts running

We already have a message like:
ksmbd: kill command received
when the server stops running.

This makes it easier for debugging in order to match any possible
warnings/errors in dmesg with restarted server.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make only use of wake_up[_all]() in transport_rdma.c
Stefan Metzmacher [Thu, 14 Aug 2025 08:06:50 +0000 (10:06 +0200)] 
smb: server: make only use of wake_up[_all]() in transport_rdma.c

wake_up_interruptible(() doesn't wake up tasks waiting with wait_event().

So we better wake_up[_all]() in order to wake up all tasks in order
to simplify the logic.

As we currently don't use any wait_event_*_exclusive() it
doesn't really matter if we use wake_up() or wake_up_all().
But in this patch I try to use wake_up() for expected situations
and wake_up_all() for situations of a broken connection.
So don't need to adjust things in future when we
may use wait_event_*_exclusive() in order to wake up
only one process that should make progress.

Changing the wait_event_*() code in order to keep
wait_event(), wait_event_interruptible() and
wait_event_interruptible_timeout() or
changing them to wait_event_killable(),
wait_event_killable_timeout(),
wait_event_killable_exclusive()
is something to think about in a future patch.

The goal here is to avoid that some tasks are not
woken and freeze forever.

Also note that this patch only changes the existing
wake_up*() calls. Adding more wake_up*() calls for
other wait queues is also deferred to a future patch.

Link: https://lore.kernel.org/linux-cifs/13851363-0dc9-465c-9ced-3ede4904eef0@samba.org/T/#t
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.{send,recv}_io.mem.{cache,pool}
Stefan Metzmacher [Wed, 6 Aug 2025 17:36:04 +0000 (19:36 +0200)] 
smb: server: make use of smbdirect_socket.{send,recv}_io.mem.{cache,pool}

This will allow common helper functions to be created later.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of struct smbdirect_send_io
Stefan Metzmacher [Wed, 6 Aug 2025 17:36:03 +0000 (19:36 +0200)] 
smb: server: make use of struct smbdirect_send_io

This is already used by the client and will allow us
to use common helper functions soon.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of SMBDIRECT_RECV_IO_MAX_SGE
Stefan Metzmacher [Wed, 6 Aug 2025 17:36:02 +0000 (19:36 +0200)] 
smb: server: make use of SMBDIRECT_RECV_IO_MAX_SGE

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.recv_io.reassembly.*
Stefan Metzmacher [Wed, 6 Aug 2025 17:36:01 +0000 (19:36 +0200)] 
smb: server: make use of smbdirect_socket.recv_io.reassembly.*

This is also used by the client and will allow us to introduce
common helper functions soon.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket.recv_io.free.{list,lock}
Stefan Metzmacher [Wed, 6 Aug 2025 17:36:00 +0000 (19:36 +0200)] 
smb: server: make use of smbdirect_socket.recv_io.free.{list,lock}

This is already used by the client and will allow us to
add common helper functions soon.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of struct smbdirect_recv_io
Stefan Metzmacher [Wed, 6 Aug 2025 17:35:59 +0000 (19:35 +0200)] 
smb: server: make use of struct smbdirect_recv_io

This will allow us to move helper functions into common code soon
as the client already uses smbdirect_recv_io.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of smbdirect_socket->recv_io.expected
Stefan Metzmacher [Wed, 6 Aug 2025 17:35:58 +0000 (19:35 +0200)] 
smb: server: make use of smbdirect_socket->recv_io.expected

The expected incoming message type can be per connection.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of common smbdirect_socket_parameters
Stefan Metzmacher [Wed, 6 Aug 2025 17:35:57 +0000 (19:35 +0200)] 
smb: server: make use of common smbdirect_socket_parameters

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Meetakshi Setiya <meetakshisetiyaoss@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of common smbdirect_socket
Stefan Metzmacher [Wed, 6 Aug 2025 17:35:56 +0000 (19:35 +0200)] 
smb: server: make use of common smbdirect_socket

This is the next step in the direction of a common smbdirect layer.
Currently only structures are shared, but that will change
over time until everything is shared.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Meetakshi Setiya <meetakshisetiyaoss@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of common smbdirect.h
Stefan Metzmacher [Wed, 6 Aug 2025 17:35:55 +0000 (19:35 +0200)] 
smb: server: make use of common smbdirect.h

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Meetakshi Setiya <meetakshisetiyaoss@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: make use of common smbdirect_pdu.h
Stefan Metzmacher [Sat, 16 Aug 2025 01:24:30 +0000 (10:24 +0900)] 
smb: server: make use of common smbdirect_pdu.h

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Meetakshi Setiya <meetakshisetiyaoss@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: server: fix IRD/ORD negotiation with the client
Stefan Metzmacher [Wed, 20 Aug 2025 13:34:58 +0000 (15:34 +0200)] 
smb: server: fix IRD/ORD negotiation with the client

Already do real negotiation in smb_direct_handle_connect_request()
where we see the requested initiator_depth and responder_resources
from the client.

We should detect legacy iwarp clients using MPA v1
with the custom IRD/ORD negotiation.

We need to send the custom IRD/ORD in big endian,
but we need to try to let clients with broken requests
using little endian (older cifs.ko) to work.

Note the reason why this uses u8 for
initiator_depth and responder_resources is
that the rdma layer also uses it.

Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Cc: linux-rdma@vger.kernel.org
Fixes: 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: let smbd_post_send_iter() call ib_dma_map_single() for the header first
Stefan Metzmacher [Sun, 14 Sep 2025 22:55:31 +0000 (00:55 +0200)] 
smb: client: let smbd_post_send_iter() call ib_dma_map_single() for the header first

This will simplify further changes, the important part is that
request->num_sge >= 1 is only set if request->sge[0].* is valid.

Note that ib_dma_sync_single_for_device() is called in
smbd_post_send() for each sge, so the device will still
see the packet header even if it's modified after calling
ib_dma_map_single().

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: defer calling ib_alloc_pd() after we are connected
Stefan Metzmacher [Mon, 15 Sep 2025 21:32:15 +0000 (23:32 +0200)] 
smb: client: defer calling ib_alloc_pd() after we are connected

The protection domain is not needed until we're connected.

This makes further changes easier to follow...

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: allocate smbdirect workqueue at the beginning of _smbd_get_connection()
Stefan Metzmacher [Tue, 26 Aug 2025 13:54:10 +0000 (15:54 +0200)] 
smb: client: allocate smbdirect workqueue at the beginning of _smbd_get_connection()

This will simplify further changes when moving to common code.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: make consitent use of spin_lock_irq{save,restore}() in smbdirect.c
Stefan Metzmacher [Wed, 27 Aug 2025 13:34:09 +0000 (15:34 +0200)] 
smb: client: make consitent use of spin_lock_irq{save,restore}() in smbdirect.c

There is a mix of using spin_lock(), spin_lock_irq() and
spin_lock_irqsave() and it seems at least enqueue_reassembly() was wrong
in using just spin_lock() as it's called via recv_done() from a SOFTIRQ
as we're using IB_POLL_SOFTIRQ.

And Documentation/kernel-hacking/locking.rst section
"Cheat Sheet For Locking" says:

-  Otherwise (== data can be touched in an interrupt), use
   spin_lock_irqsave() and
   spin_unlock_irqrestore().

So in order to keep it simple and safe we use that version
now. It will help merging functions into common code and
have consistent locking in all cases.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: let smbd_{destroy,disconnect_rdma_{work,connection}}() wake up all wait...
Stefan Metzmacher [Tue, 2 Sep 2025 10:17:56 +0000 (12:17 +0200)] 
smb: client: let smbd_{destroy,disconnect_rdma_{work,connection}}() wake up all wait queues

This is important in order to let all waiters notice a broken connection.

We also go via smbd_disconnect_rdma_{work,connection}() for broken
connections.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: let smbd_disconnect_rdma_connection() disable all work but disconnect_work
Stefan Metzmacher [Thu, 28 Aug 2025 10:15:11 +0000 (12:15 +0200)] 
smb: client: let smbd_disconnect_rdma_connection() disable all work but disconnect_work

There's no point run these if we already know the connection
is broken.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: fill in smbdirect_socket.first_error on error
Stefan Metzmacher [Thu, 28 Aug 2025 10:12:09 +0000 (12:12 +0200)] 
smb: client: fill in smbdirect_socket.first_error on error

For now we just use -ECONNABORTED, but it will get more detailed
later.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: let smbd_disconnect_rdma_connection() set SMBDIRECT_SOCKET_ERROR...
Stefan Metzmacher [Thu, 28 Aug 2025 08:39:56 +0000 (10:39 +0200)] 
smb: client: let smbd_disconnect_rdma_connection() set SMBDIRECT_SOCKET_ERROR...

smbd_disconnect_rdma_connection() should turn the status into
an error state instead of leaving it as is until
smbd_disconnect_rdma_work() is running.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: remove unused struct smbdirect_socket argument of smbd_iter_to_mr()
Stefan Metzmacher [Thu, 21 Aug 2025 23:14:38 +0000 (01:14 +0200)] 
smb: client: remove unused struct smbdirect_socket argument of smbd_iter_to_mr()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to get_mr()
Stefan Metzmacher [Thu, 21 Aug 2025 23:14:38 +0000 (01:14 +0200)] 
smb: client: pass struct smbdirect_socket to get_mr()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_negotiate()
Stefan Metzmacher [Fri, 22 Aug 2025 09:54:30 +0000 (11:54 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_negotiate()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_post_send_negotiate_req()
Stefan Metzmacher [Fri, 22 Aug 2025 09:52:24 +0000 (11:52 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_post_send_negotiate_req()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_ia_open()
Stefan Metzmacher [Fri, 22 Aug 2025 09:34:05 +0000 (11:34 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_ia_open()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_create_id()
Stefan Metzmacher [Fri, 22 Aug 2025 09:10:57 +0000 (11:10 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_create_id()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_qp_async_error_upcall()
Stefan Metzmacher [Fri, 22 Aug 2025 09:08:13 +0000 (11:08 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_qp_async_error_upcall()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_conn_upcall()
Stefan Metzmacher [Fri, 22 Aug 2025 09:07:48 +0000 (11:07 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_conn_upcall()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_post_send_full_iter()
Stefan Metzmacher [Fri, 22 Aug 2025 09:03:52 +0000 (11:03 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_post_send_full_iter()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_post_send_empty()
Stefan Metzmacher [Fri, 22 Aug 2025 08:47:06 +0000 (10:47 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_post_send_empty()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_post_send_iter()
Stefan Metzmacher [Fri, 22 Aug 2025 08:27:01 +0000 (10:27 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_post_send_iter()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to manage_keep_alive_before_sending()
Stefan Metzmacher [Fri, 22 Aug 2025 08:21:16 +0000 (10:21 +0200)] 
smb: client: pass struct smbdirect_socket to manage_keep_alive_before_sending()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_post_send()
Stefan Metzmacher [Fri, 22 Aug 2025 08:19:28 +0000 (10:19 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_post_send()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to manage_credits_prior_sending()
Stefan Metzmacher [Fri, 22 Aug 2025 08:18:12 +0000 (10:18 +0200)] 
smb: client: pass struct smbdirect_socket to manage_credits_prior_sending()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_post_recv()
Stefan Metzmacher [Fri, 22 Aug 2025 08:14:29 +0000 (10:14 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_post_recv()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to smbd_disconnect_rdma_connection()
Stefan Metzmacher [Fri, 22 Aug 2025 08:12:35 +0000 (10:12 +0200)] 
smb: client: pass struct smbdirect_socket to smbd_disconnect_rdma_connection()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to {allocate,destroy}_mr_list()
Stefan Metzmacher [Fri, 22 Aug 2025 08:10:10 +0000 (10:10 +0200)] 
smb: client: pass struct smbdirect_socket to {allocate,destroy}_mr_list()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to {enqueue,_get_first}_reassembly()
Stefan Metzmacher [Thu, 21 Aug 2025 23:17:35 +0000 (01:17 +0200)] 
smb: client: pass struct smbdirect_socket to {enqueue,_get_first}_reassembly()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to {allocate,destroy}_caches_and_workqueue()
Stefan Metzmacher [Thu, 21 Aug 2025 23:14:38 +0000 (01:14 +0200)] 
smb: client: pass struct smbdirect_socket to {allocate,destroy}_caches_and_workqueue()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to {allocate,destroy}_receive_buffers()
Stefan Metzmacher [Thu, 21 Aug 2025 23:11:36 +0000 (01:11 +0200)] 
smb: client: pass struct smbdirect_socket to {allocate,destroy}_receive_buffers()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: pass struct smbdirect_socket to {get,put}_receive_buffer()
Stefan Metzmacher [Thu, 21 Aug 2025 23:07:11 +0000 (01:07 +0200)] 
smb: client: pass struct smbdirect_socket to {get,put}_receive_buffer()

This will make it easier to move function to the common code
in future.

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>
7 days agosmb: client: make use of smbdirect_socket.mr_io
Stefan Metzmacher [Thu, 21 Aug 2025 22:57:19 +0000 (00:57 +0200)] 
smb: client: make use of smbdirect_socket.mr_io

Now struct smbd_connection only contains struct smbdirect_socket,
this is an important step towards having common functions as well.

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>
7 days agosmb: client: make use of smbdirect_socket_parameters.max_frmr_depth
Stefan Metzmacher [Thu, 21 Aug 2025 22:32:34 +0000 (00:32 +0200)] 
smb: client: make use of smbdirect_socket_parameters.max_frmr_depth

This make it easier to have common code later.

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>
7 days agosmb: client: make use of struct smbdirect_mr_io
Stefan Metzmacher [Thu, 21 Aug 2025 21:36:33 +0000 (23:36 +0200)] 
smb: client: make use of struct smbdirect_mr_io

This will allow us to move to common functions in future too.

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>
7 days agosmb: client: add and use smbd_get_parameters()
Stefan Metzmacher [Thu, 21 Aug 2025 22:23:53 +0000 (00:23 +0200)] 
smb: client: add and use smbd_get_parameters()

In future struct smbdirect_socket_parameters will be the only
public structure for the smb layer. This prepares this...

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>
7 days agosmb: client: make use of smbdirect_socket.workqueue
Stefan Metzmacher [Fri, 22 Aug 2025 10:29:03 +0000 (12:29 +0200)] 
smb: client: make use of smbdirect_socket.workqueue

This will simplify the move to common code...

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>
7 days agosmb: client: move rdma_readwrite_threshold from smbd_connection to TCP_Server_Info
Stefan Metzmacher [Thu, 21 Aug 2025 12:50:56 +0000 (14:50 +0200)] 
smb: client: move rdma_readwrite_threshold from smbd_connection to TCP_Server_Info

This belongs to the SMB layer not to the transport layer, it
just uses the negotiated transport parameters to adjust the
value if needed.

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>
7 days agosmb: client: make use of smbdirect_socket.statistics
Stefan Metzmacher [Tue, 19 Aug 2025 11:54:35 +0000 (13:54 +0200)] 
smb: client: make use of smbdirect_socket.statistics

This will allow us to use common functions soon.

Note this generates the following warnings from
scripts/checkpatch.pl --quiet:

 WARNING: quoted string split across lines
 #59: FILE: fs/smb/client/cifs_debug.c:481:
 +               seq_printf(m, "\nDebug count_get_receive_buffer: %llu "
 +                       "count_put_receive_buffer: %llu count_send_empty: %llu",

 WARNING: quoted string split across lines
 #66: FILE: fs/smb/client/cifs_debug.c:486:
                 seq_printf(m, "\nRead Queue "
 +                       "count_enqueue_reassembly_queue: %llu "

 WARNING: quoted string split across lines
 #67: FILE: fs/smb/client/cifs_debug.c:487:
 +                       "count_enqueue_reassembly_queue: %llu "
 +                       "count_dequeue_reassembly_queue: %llu "

 total: 0 errors, 3 warnings, 83 lines checked
 scripts/checkpatch.pl: FAILED

But I left them in there, because it matches the code
arround it...

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>
7 days agosmb: client: remove unused smbd_connection.count_reassembly_queue
Stefan Metzmacher [Tue, 19 Aug 2025 10:03:59 +0000 (12:03 +0200)] 
smb: client: remove unused smbd_connection.count_reassembly_queue

This basically represents the same information as
sc->recv_io.reassembly.queue_length.

The only thing that's different is that
smbd_connection.count_reassembly_queue was updated in each
loop step, while sc->recv_io.reassembly.queue_length is only
updated once after the loop in smbd_recv.
Also sc->recv_io.reassembly.queue_length is updated under
a spinlock.

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>
7 days agosmb: client: remove unused smbd_connection->protocol
Stefan Metzmacher [Mon, 18 Aug 2025 08:42:42 +0000 (10:42 +0200)] 
smb: client: remove unused smbd_connection->protocol

There is only one protocol version for smbdirect yet and
this variable is write only.

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>
7 days agosmb: client: make use of smbdirect_socket.idle.{keepalive,immediate_work,timer_work}
Stefan Metzmacher [Fri, 15 Aug 2025 15:57:32 +0000 (17:57 +0200)] 
smb: client: make use of smbdirect_socket.idle.{keepalive,immediate_work,timer_work}

This will allow client and server to use the common structures in order
to share common functions later.

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>
7 days agosmb: client: fix smbdirect keep alive handling to match the documentation
Stefan Metzmacher [Thu, 14 Aug 2025 17:41:12 +0000 (19:41 +0200)] 
smb: client: fix smbdirect keep alive handling to match the documentation

We setup the first timer with the negotiate timeout and set
KEEP_ALIVE_PENDING, so that the expired timer disconnects.

On every incoming message we need to reset the timer to the keepalive
interval (120s).

On SMBDIRECT_FLAG_RESPONSE_REQUESTED we need to schedule a response
instead of setting KEEP_ALIVE_PENDING. Doing both would mean
we would also set SMBDIRECT_FLAG_RESPONSE_REQUESTED in that
response. If both ends would do that we'd play ping pong in
a busy loop.

If we move to KEEP_ALIVE_SENT and send the keepalive request
with SMBDIRECT_FLAG_RESPONSE_REQUESTED, we need to setup the
timer with keepalive timeout (5s) in order to disconnect
if no incoming message reset the timer.

The fired timer sets KEEP_ALIVE_PENDING and also
setup timer with keepalive timeout (5s) in order to disconnect
if no incoming message reset the timer.
We do that before queueing the send_immediate_work
and have that timer in case we didn't reach the send code
that typically sets the timer to keepalive timeout.

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>
7 days agosmb: client: send empty packets via send_immediate_work
Stefan Metzmacher [Fri, 15 Aug 2025 10:53:35 +0000 (12:53 +0200)] 
smb: client: send empty packets via send_immediate_work

This is what the server already does and it makes
refactoring for common structures and functions much easier.

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>
7 days agosmb: client: make use of smbdirect_socket.rdma.legacy_iwarp
Stefan Metzmacher [Thu, 21 Aug 2025 10:22:46 +0000 (12:22 +0200)] 
smb: client: make use of smbdirect_socket.rdma.legacy_iwarp

Currently it's write only for the client, but it will likely be use
for debugging later.

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>
7 days agosmb: client: make use of smbdirect_socket_parameters.{initiator_depth,responder_resou...
Stefan Metzmacher [Tue, 19 Aug 2025 21:18:21 +0000 (23:18 +0200)] 
smb: client: make use of smbdirect_socket_parameters.{initiator_depth,responder_resources}

This will make it easier to specify these from the outside of the core
code first and then negotiate the value with the peer.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: make use of smbdirect_socket_parameters.{resolve_{addr,route},rdma_conne...
Stefan Metzmacher [Thu, 14 Aug 2025 17:39:22 +0000 (19:39 +0200)] 
smb: client: make use of smbdirect_socket_parameters.{resolve_{addr,route},rdma_connect,negotiate}_timeout_msec

This will make future changes to these values much saner.

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>
7 days agosmb: client: fill smbdirect_socket_parameters at the beginning and use the values...
Stefan Metzmacher [Fri, 15 Aug 2025 09:03:04 +0000 (11:03 +0200)] 
smb: client: fill smbdirect_socket_parameters at the beginning and use the values from there

This is what we should do and it also simplifies the following changes.

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>
7 days agosmb: client: remove useless smbd_connection.send_immediate
Stefan Metzmacher [Thu, 14 Aug 2025 16:34:02 +0000 (18:34 +0200)] 
smb: client: remove useless smbd_connection.send_immediate

We always set it to true before having an if statement that checks it is
true...

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>
7 days agosmb: client: make use of smbdirect_socket.recv_io.{posted,credits}
Stefan Metzmacher [Thu, 14 Aug 2025 14:32:30 +0000 (16:32 +0200)] 
smb: client: make use of smbdirect_socket.recv_io.{posted,credits}

This will make it possible to introduce common helper functions
in future.

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>
7 days agosmb: client: count the number of posted recv_io messages in order to calculated credits
Stefan Metzmacher [Thu, 14 Aug 2025 11:57:37 +0000 (13:57 +0200)] 
smb: client: count the number of posted recv_io messages in order to calculated credits

(At least for me) the logic maintaining the count of posted
recv_io messages and the count of granted credits is much easier
to understand.

From there we can easily calculate the number of new_credits we'll
grant to the peer in outgoing send_io messages.

This will simplify the move to common logic that can be
shared between client and server in the following patches.

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>
7 days agosmb: client: limit the range of info->receive_credit_target
Stefan Metzmacher [Thu, 14 Aug 2025 13:01:35 +0000 (15:01 +0200)] 
smb: client: limit the range of info->receive_credit_target

This simplifies further changes...

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>
7 days agosmb: client: remove info->wait_receive_queues handling in smbd_destroy()
Stefan Metzmacher [Tue, 12 Aug 2025 07:24:57 +0000 (09:24 +0200)] 
smb: client: remove info->wait_receive_queues handling in smbd_destroy()

We already call ib_drain_qp() before, which is an sync operation
that only returns in the queues are fully drained.

ib_drain_qp() completes pending requests with IB_WC_WR_FLUSH_ERR
so we have already called put_receive_buffer().

So all smbdirect_recv_io objects are either in the
smbdirect_socket.recv_io.free.list or
smbdirect_socket.recv_io.reassembly.list.

Then we explicitly iterate smbdirect_socket.recv_io.reassembly.list
and call put_receive_buffer(), so every object is
in smbdirect_socket.recv_io.free.list.

It means info->count_receive_queue == sp->recv_credit_max was
already true and calling wait_event(info->wait_receive_queues...
is pointless.

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>
7 days agosmb: client: make use of ib_wc_status_msg() and skip IB_WC_WR_FLUSH_ERR logging
Stefan Metzmacher [Tue, 12 Aug 2025 07:44:07 +0000 (09:44 +0200)] 
smb: client: make use of ib_wc_status_msg() and skip IB_WC_WR_FLUSH_ERR logging

There's no need to get log message for every IB_WC_WR_FLUSH_ERR
completion, but any other error should be logged at level ERR.

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>
7 days agosmb: client: queue post_recv_credits_work also if the peer raises the credit target
Stefan Metzmacher [Mon, 11 Aug 2025 15:53:55 +0000 (17:53 +0200)] 
smb: client: queue post_recv_credits_work also if the peer raises the credit target

This is already handled in the server, but currently it done
in a very complex way there. So we do it much simpler.

Note that put_receive_buffer() will take care of it
in case data_length is 0.

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>
7 days agosmb: client: make sure smbd_disconnect_rdma_work() doesn't run after smbd_destroy...
Stefan Metzmacher [Tue, 12 Aug 2025 07:10:07 +0000 (09:10 +0200)] 
smb: client: make sure smbd_disconnect_rdma_work() doesn't run after smbd_destroy() took over

If we're already disconnecting we don't need to queue the
disconnect_work again. disable_work() turns the next queue_work()
into a no-op.

Also let smbd_destroy() cancel(and disable) queued disconnect_work and
call smbd_disconnect_rdma_work() inline.

The makes it more obvious that disconnect_work is never queued
again after smbd_destroy() called smbd_disconnect_rdma_work().

It also means we have a single place to call rdma_disconnect().

While there we better also disable all other [delayed_]work.

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>
7 days agosmb: client: make use of smbdirect_socket.send_io.credits.{count,wait_queue}
Stefan Metzmacher [Mon, 11 Aug 2025 15:11:08 +0000 (17:11 +0200)] 
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>
7 days agosmb: client: make use of smbdirect_socket.send_io.pending.{count,{dec,zero}_wait_queue}
Stefan Metzmacher [Mon, 11 Aug 2025 13:19:51 +0000 (15:19 +0200)] 
smb: client: make use of smbdirect_socket.send_io.pending.{count,{dec,zero}_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>
7 days agosmb: client: make use of smbdirect_socket.disconnect_work
Stefan Metzmacher [Fri, 8 Aug 2025 17:06:49 +0000 (19:06 +0200)] 
smb: client: make use of smbdirect_socket.disconnect_work

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>
7 days agosmb: client: make use of smbdirect_socket_init()
Stefan Metzmacher [Fri, 8 Aug 2025 13:10:52 +0000 (15:10 +0200)] 
smb: client: make use of smbdirect_socket_init()

It's much safer to initialize the whole structure at
the beginning than doing it all over the place
and then miss to move it if code changes.

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>
7 days agosmb: client: make only use of wake_up[_all]() in smbdirect.c
Stefan Metzmacher [Thu, 14 Aug 2025 08:06:50 +0000 (10:06 +0200)] 
smb: client: make only use of wake_up[_all]() in smbdirect.c

wake_up_interruptible[_all]() doesn't wake up tasks waiting
with wait_event().

So we better wake_up[_all]() in order to wake up all tasks in order
to simplify the logic.

As we currently don't use any wait_event_*_exclusive() it
doesn't really matter if we use wake_up() or wake_up_all().
But in this patch I try to use wake_up() for expected situations
and wake_up_all() for situations of a broken connection.
So don't need to adjust things in future when we
may use wait_event_*_exclusive() in order to wake up
only one process that should make progress.

Changing the wait_event_*() code in order to keep
wait_event(), wait_event_interruptible() and
wait_event_interruptible_timeout() or
changing them to wait_event_killable(),
wait_event_killable_timeout(),
wait_event_killable_exclusive()
is something to think about in a future patch.

The goal here is to avoid that some tasks are not
woken and freeze forever.

Also note that this patch only changes the existing
wake_up*() calls. Adding more wake_up*() calls for
other wait queues is also deferred to a future patch.

Link: https://lore.kernel.org/linux-cifs/13851363-0dc9-465c-9ced-3ede4904eef0@samba.org/T/#t
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>
7 days agosmb: client: make use of smbdirect_socket.status_wait
Stefan Metzmacher [Fri, 8 Aug 2025 16:48:17 +0000 (18:48 +0200)] 
smb: client: make use of smbdirect_socket.status_wait

This will allow us to have common helper functions soon.

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>
7 days agosmb: client: use status_wait and SMBDIRECT_SOCKET_RESOLVE_{ADDR,ROUTE}_RUNNING for...
Stefan Metzmacher [Fri, 8 Aug 2025 16:48:15 +0000 (18:48 +0200)] 
smb: client: use status_wait and SMBDIRECT_SOCKET_RESOLVE_{ADDR,ROUTE}_RUNNING for completion

We can use the state change from
SMBDIRECT_SOCKET_RESOLVE_{ADDR,ROUTE}_RUNNING
to the next state in order to wake the caller to do the next step.

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>
7 days agosmb: client: use status_wait and SMBDIRECT_SOCKET_NEGOTIATE_RUNNING for completion
Stefan Metzmacher [Fri, 8 Aug 2025 16:48:14 +0000 (18:48 +0200)] 
smb: client: use status_wait and SMBDIRECT_SOCKET_NEGOTIATE_RUNNING for completion

We can use the state change from SMBDIRECT_SOCKET_NEGOTIATE_RUNNING to
SMBDIRECT_SOCKET_CONNECTED or SMBDIRECT_SOCKET_NEGOTIATE_FAILED in order
to notify the caller if the negotiation is over.

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>
7 days agosmb: client: adjust smbdirect related output of cifs_debug_data_proc_show()
Stefan Metzmacher [Mon, 8 Sep 2025 10:14:43 +0000 (12:14 +0200)] 
smb: client: adjust smbdirect related output of cifs_debug_data_proc_show()

For the reader it is not obvious that the counter values are displayed
in hex as there's no leading '0x' before '%x'.

So changed them to %u instead and added '0x' for non-counter values
and also a string for the status.

Note this generates some checkpatch warnings like this:

 WARNING: quoted string split across lines
 #45: FILE: fs/smb/client/cifs_debug.c:460:
 +               seq_printf(m, "\nSMBDirect protocol version: 0x%x "
 +                       "transport status: %s (%u)",

But I'll leave this is the current style in the
related code...

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>
7 days agosmb: smbdirect: introduce smbdirect_socket.first_error
Stefan Metzmacher [Thu, 28 Aug 2025 10:11:02 +0000 (12:11 +0200)] 
smb: smbdirect: introduce smbdirect_socket.first_error

This will be used when a connected conection gets the first error.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client/smbdirect: introduce SMBDIRECT_SOCKET_ERROR
Stefan Metzmacher [Thu, 28 Aug 2025 08:39:56 +0000 (10:39 +0200)] 
smb: client/smbdirect: introduce SMBDIRECT_SOCKET_ERROR

This will be used to turn SMBDIRECT_SOCKET_CONNECTED into an
error within smbd_disconnect_rdma_connection() on the client
and smb_direct_disconnect_rdma_connection() on the server.

We do this in a single commit with the client as otherwise it
won't build because the enum value is not handled in the
switch statement.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client/smbdirect: replace SMBDIRECT_SOCKET_CONNECTING with more detailed states
Stefan Metzmacher [Fri, 8 Aug 2025 16:48:13 +0000 (18:48 +0200)] 
smb: client/smbdirect: replace SMBDIRECT_SOCKET_CONNECTING with more detailed states

The process of reaching a functional connection represented by
SMBDIRECT_SOCKET_CONNECTED, is more complex than using a single
SMBDIRECT_SOCKET_CONNECTING state.

This will allow us to remove a lot of special variables and
completions in the following commits.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: client: fix sending the iwrap custom IRD/ORD negotiation messages
Stefan Metzmacher [Wed, 20 Aug 2025 09:25:06 +0000 (11:25 +0200)] 
smb: client: fix sending the iwrap custom IRD/ORD negotiation messages

Do a real negotiation and check the servers initiator_depth and
responder_resources.

This should use big endian in order to be useful.
I have captures of windows clients showing this.

The fact that we used little endian up to now
means that we sent very large numbers and the
negotiation with the server truncated them to the
server limits.

Note the reason why this uses u8 for
initiator_depth and responder_resources is
that the rdma layer also uses it.

The inconsitency regarding the initiator_depth
and responder_resources values being reversed
for iwarp devices in RDMA_CM_EVENT_ESTABLISHED
should also be fixed later, but for now we should
fix it.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Cc: linux-rdma@vger.kernel.org
Fixes: c7398583340a ("CIFS: SMBD: Implement RDMA memory registration")
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: smbdirect: let smbdirect_socket_init() initialize all [delayed_]work_structs...
Stefan Metzmacher [Tue, 26 Aug 2025 14:30:32 +0000 (16:30 +0200)] 
smb: smbdirect: let smbdirect_socket_init() initialize all [delayed_]work_structs as disabled

This safer to start with and allows common code not care about if the
caller uses these or not. E.g. sc->mr_io.recovery_work is only used
on the client...

Note disable_[delayed_]work_sync() requires a valid function pointer
in INIT_[DELAYED_]WORK(). The non _sync() version don't require it,
but as we need to use the _sync() version on cleanup we better use
it here too, it won't block anyway here...

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: smbdirect: introduce smbdirect_socket.mr_io.*
Stefan Metzmacher [Tue, 19 Aug 2025 07:34:27 +0000 (09:34 +0200)] 
smb: smbdirect: introduce smbdirect_socket.mr_io.*

This will be used by the client and will allow us to move to
common code...

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
7 days agosmb: smbdirect: introduce smbdirect_socket_parameters.max_frmr_depth
Stefan Metzmacher [Thu, 21 Aug 2025 21:50:42 +0000 (23:50 +0200)] 
smb: smbdirect: introduce smbdirect_socket_parameters.max_frmr_depth

This will be used by the client...

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>