Skip to content

Commit 5003ad7

Browse files
ChenXiaoSongsmfrench
authored andcommitted
smb: move create_durable_reconn to common/smb2pdu.h
The fields in struct create_durable_reconn_req and struct create_durable are exactly the same, so remove create_durable_reconn_req from server, and use typedef to define both create_durable_req_t and create_durable_reconn_t for a single struct. Rename the following places: - struct create_durable -> create_durable_req_t - struct create_durable_reconn_req -> create_durable_reconn_t The documentation references are: - SMB2_CREATE_DURABLE_HANDLE_REQUEST in MS-SMB2 2.2.13.2.3 - SMB2_CREATE_DURABLE_HANDLE_RECONNECT in MS-SMB2 2.2.13.2.4 - SMB2_FILEID in MS-SMB2 2.2.14.1 Descriptions of the struct fields: - __u8 Reserved[16]: DurableRequest field of SMB2_CREATE_DURABLE_HANDLE_REQUEST. A 16-byte field that MUST be reserved. - __u64 PersistentFileId: Persistent field of 2.2.14.1 SMB2_FILEID - __u64 VolatileFileId: Volatile field of 2.2.14.1 SMB2_FILEID - struct Fid: Data field of SMB2_CREATE_DURABLE_HANDLE_RECONNECT. An SMB2_FILEID structure, as specified in section 2.2.14.1. Suggested-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent e7e60e8 commit 5003ad7

4 files changed

Lines changed: 16 additions & 29 deletions

File tree

fs/smb/client/smb2pdu.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,21 +2229,20 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon)
22292229
return rc;
22302230
}
22312231

2232-
2233-
static struct create_durable *
2232+
static create_durable_req_t *
22342233
create_durable_buf(void)
22352234
{
2236-
struct create_durable *buf;
2235+
create_durable_req_t *buf;
22372236

2238-
buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL);
2237+
buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL);
22392238
if (!buf)
22402239
return NULL;
22412240

22422241
buf->ccontext.DataOffset = cpu_to_le16(offsetof
2243-
(struct create_durable, Data));
2242+
(create_durable_req_t, Data));
22442243
buf->ccontext.DataLength = cpu_to_le32(16);
22452244
buf->ccontext.NameOffset = cpu_to_le16(offsetof
2246-
(struct create_durable, Name));
2245+
(create_durable_req_t, Name));
22472246
buf->ccontext.NameLength = cpu_to_le16(4);
22482247
/* SMB2_CREATE_DURABLE_HANDLE_REQUEST is "DHnQ" */
22492248
buf->Name[0] = 'D';
@@ -2253,20 +2252,20 @@ create_durable_buf(void)
22532252
return buf;
22542253
}
22552254

2256-
static struct create_durable *
2255+
static create_durable_req_t *
22572256
create_reconnect_durable_buf(struct cifs_fid *fid)
22582257
{
2259-
struct create_durable *buf;
2258+
create_durable_req_t *buf;
22602259

2261-
buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL);
2260+
buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL);
22622261
if (!buf)
22632262
return NULL;
22642263

22652264
buf->ccontext.DataOffset = cpu_to_le16(offsetof
2266-
(struct create_durable, Data));
2265+
(create_durable_req_t, Data));
22672266
buf->ccontext.DataLength = cpu_to_le32(16);
22682267
buf->ccontext.NameOffset = cpu_to_le16(offsetof
2269-
(struct create_durable, Name));
2268+
(create_durable_req_t, Name));
22702269
buf->ccontext.NameLength = cpu_to_le16(4);
22712270
buf->Data.Fid.PersistentFileId = fid->persistent_fid;
22722271
buf->Data.Fid.VolatileFileId = fid->volatile_fid;
@@ -2552,7 +2551,7 @@ add_durable_context(struct kvec *iov, unsigned int *num_iovec,
25522551
iov[num].iov_base = create_durable_buf();
25532552
if (iov[num].iov_base == NULL)
25542553
return -ENOMEM;
2555-
iov[num].iov_len = sizeof(struct create_durable);
2554+
iov[num].iov_len = sizeof(create_durable_req_t);
25562555
*num_iovec = num + 1;
25572556
return 0;
25582557
}

fs/smb/common/smb2pdu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ struct create_posix {
12651265
} __packed;
12661266

12671267
/* See MS-SMB2 2.2.13.2.3 and MS-SMB2 2.2.13.2.4 */
1268-
struct create_durable {
1268+
typedef struct {
12691269
struct create_context_hdr ccontext;
12701270
__u8 Name[8];
12711271
union {
@@ -1275,7 +1275,7 @@ struct create_durable {
12751275
__u64 VolatileFileId;
12761276
} Fid;
12771277
} Data;
1278-
} __packed;
1278+
} __packed create_durable_req_t, create_durable_reconn_t;
12791279

12801280
/* See MS-SMB2 2.2.13.2.5 */
12811281
struct create_mxac_req {

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27562756
}
27572757
case DURABLE_RECONN:
27582758
{
2759-
struct create_durable_reconn_req *recon;
2759+
create_durable_reconn_t *recon;
27602760

27612761
if (dh_info->type == DURABLE_RECONN_V2 ||
27622762
dh_info->type == DURABLE_REQ_V2) {
@@ -2766,12 +2766,12 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27662766

27672767
if (le16_to_cpu(context->DataOffset) +
27682768
le32_to_cpu(context->DataLength) <
2769-
sizeof(struct create_durable_reconn_req)) {
2769+
sizeof(create_durable_reconn_t)) {
27702770
err = -EINVAL;
27712771
goto out;
27722772
}
27732773

2774-
recon = (struct create_durable_reconn_req *)context;
2774+
recon = (create_durable_reconn_t *)context;
27752775
persistent_id = recon->Data.Fid.PersistentFileId;
27762776
dh_info->fp = ksmbd_lookup_durable_fd(persistent_id);
27772777
if (!dh_info->fp) {

fs/smb/server/smb2pdu.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ struct preauth_integrity_info {
6868

6969
#define DURABLE_HANDLE_MAX_TIMEOUT 300000
7070

71-
struct create_durable_reconn_req {
72-
struct create_context_hdr ccontext;
73-
__u8 Name[8];
74-
union {
75-
__u8 Reserved[16];
76-
struct {
77-
__u64 PersistentFileId;
78-
__u64 VolatileFileId;
79-
} Fid;
80-
} Data;
81-
} __packed;
82-
8371
struct create_alloc_size_req {
8472
struct create_context_hdr ccontext;
8573
__u8 Name[8];

0 commit comments

Comments
 (0)