[PATCH 1/5] smb: common: split out smb_direct related header files

Tom Talpey tom at talpey.com
Tue May 27 18:50:29 UTC 2025


I love the idea. Couple of questions on the pathnames...

On 5/27/2025 12:12 PM, Stefan Metzmacher wrote:
> This is just a start moving into a common smb_direct layer.
> 
> Cc: Steve French <smfrench at gmail.com>
> Cc: Tom Talpey <tom at talpey.com>
> Cc: Long Li <longli at microsoft.com>
> Cc: Namjae Jeon <linkinjeon at kernel.org>
> Cc: Hyunchul Lee <hyc.lee at gmail.com>
> Cc: linux-cifs at vger.kernel.org
> Cc: samba-technical at lists.samba.org
> Signed-off-by: Stefan Metzmacher <metze at samba.org>
> ---
>   fs/smb/common/smb_direct/smb_direct.h     | 11 +++++
>   fs/smb/common/smb_direct/smb_direct_pdu.h | 51 +++++++++++++++++++++++

Why the underscore in "smb_direct", in both components? The protocol
doesn't use this, and it seems awkward and search-unfriendly.

>   fs/smb/server/transport_rdma.h            | 43 +------------------
>   3 files changed, 64 insertions(+), 41 deletions(-)
>   create mode 100644 fs/smb/common/smb_direct/smb_direct.h
>   create mode 100644 fs/smb/common/smb_direct/smb_direct_pdu.h
> 
> diff --git a/fs/smb/common/smb_direct/smb_direct.h b/fs/smb/common/smb_direct/smb_direct.h
> new file mode 100644
> index 000000000000..c745c37a3fea
> --- /dev/null
> +++ b/fs/smb/common/smb_direct/smb_direct.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + *   Copyright (C) 2025, Stefan Metzmacher <metze at samba.org>
> + */
> +
> +#ifndef __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
> +#define __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
> +
> +#include "smb_direct_pdu.h"

And, why the empty redirection? It seems unnecessary, do I assume it
will later contain API signatures for the planned common layer? Perhaps
it should say this, to avoid confusion while that work is being done.

I'll review more later, but a first pass looks good!

Tom.


> +
> +#endif /* __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__ */
> diff --git a/fs/smb/common/smb_direct/smb_direct_pdu.h b/fs/smb/common/smb_direct/smb_direct_pdu.h
> new file mode 100644
> index 000000000000..ab73cd8f807a
> --- /dev/null
> +++ b/fs/smb/common/smb_direct/smb_direct_pdu.h
> @@ -0,0 +1,51 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + *   Copyright (C) 2017, Microsoft Corporation.
> + *   Copyright (C) 2018, LG Electronics.
> + */
> +
> +#ifndef __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__
> +#define __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__
> +
> +/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
> +struct smb_direct_negotiate_req {
> +	__le16 min_version;
> +	__le16 max_version;
> +	__le16 reserved;
> +	__le16 credits_requested;
> +	__le32 preferred_send_size;
> +	__le32 max_receive_size;
> +	__le32 max_fragmented_size;
> +} __packed;
> +
> +/* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
> +struct smb_direct_negotiate_resp {
> +	__le16 min_version;
> +	__le16 max_version;
> +	__le16 negotiated_version;
> +	__le16 reserved;
> +	__le16 credits_requested;
> +	__le16 credits_granted;
> +	__le32 status;
> +	__le32 max_readwrite_size;
> +	__le32 preferred_send_size;
> +	__le32 max_receive_size;
> +	__le32 max_fragmented_size;
> +} __packed;
> +
> +#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
> +
> +/* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
> +struct smb_direct_data_transfer {
> +	__le16 credits_requested;
> +	__le16 credits_granted;
> +	__le16 flags;
> +	__le16 reserved;
> +	__le32 remaining_data_length;
> +	__le32 data_offset;
> +	__le32 data_length;
> +	__le32 padding;
> +	__u8 buffer[];
> +} __packed;
> +
> +#endif /* __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__ */
> diff --git a/fs/smb/server/transport_rdma.h b/fs/smb/server/transport_rdma.h
> index 77aee4e5c9dc..71909b6d8021 100644
> --- a/fs/smb/server/transport_rdma.h
> +++ b/fs/smb/server/transport_rdma.h
> @@ -7,51 +7,12 @@
>   #ifndef __KSMBD_TRANSPORT_RDMA_H__
>   #define __KSMBD_TRANSPORT_RDMA_H__
>   
> +#include "../common/smb_direct/smb_direct.h"
> +
>   #define SMBD_DEFAULT_IOSIZE (8 * 1024 * 1024)
>   #define SMBD_MIN_IOSIZE (512 * 1024)
>   #define SMBD_MAX_IOSIZE (16 * 1024 * 1024)
>   
> -/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
> -struct smb_direct_negotiate_req {
> -	__le16 min_version;
> -	__le16 max_version;
> -	__le16 reserved;
> -	__le16 credits_requested;
> -	__le32 preferred_send_size;
> -	__le32 max_receive_size;
> -	__le32 max_fragmented_size;
> -} __packed;
> -
> -/* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
> -struct smb_direct_negotiate_resp {
> -	__le16 min_version;
> -	__le16 max_version;
> -	__le16 negotiated_version;
> -	__le16 reserved;
> -	__le16 credits_requested;
> -	__le16 credits_granted;
> -	__le32 status;
> -	__le32 max_readwrite_size;
> -	__le32 preferred_send_size;
> -	__le32 max_receive_size;
> -	__le32 max_fragmented_size;
> -} __packed;
> -
> -#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
> -
> -/* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
> -struct smb_direct_data_transfer {
> -	__le16 credits_requested;
> -	__le16 credits_granted;
> -	__le16 flags;
> -	__le16 reserved;
> -	__le32 remaining_data_length;
> -	__le32 data_offset;
> -	__le32 data_length;
> -	__le32 padding;
> -	__u8 buffer[];
> -} __packed;
> -
>   #ifdef CONFIG_SMB_SERVER_SMBDIRECT
>   int ksmbd_rdma_init(void);
>   void ksmbd_rdma_destroy(void);




More information about the samba-technical mailing list