Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

ChenXiaoSong and committed by
Steve French
5003ad71 e7e60e8b

+16 -29
+11 -12
fs/smb/client/smb2pdu.c
··· 2229 2229 return rc; 2230 2230 } 2231 2231 2232 - 2233 - static struct create_durable * 2232 + static create_durable_req_t * 2234 2233 create_durable_buf(void) 2235 2234 { 2236 - struct create_durable *buf; 2235 + create_durable_req_t *buf; 2237 2236 2238 - buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL); 2237 + buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL); 2239 2238 if (!buf) 2240 2239 return NULL; 2241 2240 2242 2241 buf->ccontext.DataOffset = cpu_to_le16(offsetof 2243 - (struct create_durable, Data)); 2242 + (create_durable_req_t, Data)); 2244 2243 buf->ccontext.DataLength = cpu_to_le32(16); 2245 2244 buf->ccontext.NameOffset = cpu_to_le16(offsetof 2246 - (struct create_durable, Name)); 2245 + (create_durable_req_t, Name)); 2247 2246 buf->ccontext.NameLength = cpu_to_le16(4); 2248 2247 /* SMB2_CREATE_DURABLE_HANDLE_REQUEST is "DHnQ" */ 2249 2248 buf->Name[0] = 'D'; ··· 2252 2253 return buf; 2253 2254 } 2254 2255 2255 - static struct create_durable * 2256 + static create_durable_req_t * 2256 2257 create_reconnect_durable_buf(struct cifs_fid *fid) 2257 2258 { 2258 - struct create_durable *buf; 2259 + create_durable_req_t *buf; 2259 2260 2260 - buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL); 2261 + buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL); 2261 2262 if (!buf) 2262 2263 return NULL; 2263 2264 2264 2265 buf->ccontext.DataOffset = cpu_to_le16(offsetof 2265 - (struct create_durable, Data)); 2266 + (create_durable_req_t, Data)); 2266 2267 buf->ccontext.DataLength = cpu_to_le32(16); 2267 2268 buf->ccontext.NameOffset = cpu_to_le16(offsetof 2268 - (struct create_durable, Name)); 2269 + (create_durable_req_t, Name)); 2269 2270 buf->ccontext.NameLength = cpu_to_le16(4); 2270 2271 buf->Data.Fid.PersistentFileId = fid->persistent_fid; 2271 2272 buf->Data.Fid.VolatileFileId = fid->volatile_fid; ··· 2551 2552 iov[num].iov_base = create_durable_buf(); 2552 2553 if (iov[num].iov_base == NULL) 2553 2554 return -ENOMEM; 2554 - iov[num].iov_len = sizeof(struct create_durable); 2555 + iov[num].iov_len = sizeof(create_durable_req_t); 2555 2556 *num_iovec = num + 1; 2556 2557 return 0; 2557 2558 }
+2 -2
fs/smb/common/smb2pdu.h
··· 1265 1265 } __packed; 1266 1266 1267 1267 /* See MS-SMB2 2.2.13.2.3 and MS-SMB2 2.2.13.2.4 */ 1268 - struct create_durable { 1268 + typedef struct { 1269 1269 struct create_context_hdr ccontext; 1270 1270 __u8 Name[8]; 1271 1271 union { ··· 1275 1275 __u64 VolatileFileId; 1276 1276 } Fid; 1277 1277 } Data; 1278 - } __packed; 1278 + } __packed create_durable_req_t, create_durable_reconn_t; 1279 1279 1280 1280 /* See MS-SMB2 2.2.13.2.5 */ 1281 1281 struct create_mxac_req {
+3 -3
fs/smb/server/smb2pdu.c
··· 2756 2756 } 2757 2757 case DURABLE_RECONN: 2758 2758 { 2759 - struct create_durable_reconn_req *recon; 2759 + create_durable_reconn_t *recon; 2760 2760 2761 2761 if (dh_info->type == DURABLE_RECONN_V2 || 2762 2762 dh_info->type == DURABLE_REQ_V2) { ··· 2766 2766 2767 2767 if (le16_to_cpu(context->DataOffset) + 2768 2768 le32_to_cpu(context->DataLength) < 2769 - sizeof(struct create_durable_reconn_req)) { 2769 + sizeof(create_durable_reconn_t)) { 2770 2770 err = -EINVAL; 2771 2771 goto out; 2772 2772 } 2773 2773 2774 - recon = (struct create_durable_reconn_req *)context; 2774 + recon = (create_durable_reconn_t *)context; 2775 2775 persistent_id = recon->Data.Fid.PersistentFileId; 2776 2776 dh_info->fp = ksmbd_lookup_durable_fd(persistent_id); 2777 2777 if (!dh_info->fp) {
-12
fs/smb/server/smb2pdu.h
··· 68 68 69 69 #define DURABLE_HANDLE_MAX_TIMEOUT 300000 70 70 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 - 83 71 struct create_alloc_size_req { 84 72 struct create_context_hdr ccontext; 85 73 __u8 Name[8];