Skip to content

Commit cc26f59

Browse files
ZhangGuoDongsmfrench
authored andcommitted
smb: move copychunk definitions to common/smb2pdu.h
Rename 3 places: - copychunk_ioctl -> copychunk_ioctl_req - copychunk -> srv_copychunk - server: ResumeKey -> SourceKeyU64 Merge the struct members of the server and the client, then move duplicate definitions to common header file. Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 7844d50 commit cc26f59

6 files changed

Lines changed: 34 additions & 57 deletions

File tree

fs/smb/client/cifspdu.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,14 +1323,6 @@ typedef struct smb_com_ntransact_rsp {
13231323
/* parms and data follow */
13241324
} __attribute__((packed)) NTRANSACT_RSP;
13251325

1326-
/* See MS-SMB 2.2.7.2.1.1 */
1327-
struct srv_copychunk {
1328-
__le64 SourceOffset;
1329-
__le64 DestinationOffset;
1330-
__le32 CopyLength;
1331-
__u32 Reserved;
1332-
} __packed;
1333-
13341326
typedef struct smb_com_transaction_ioctl_req {
13351327
struct smb_hdr hdr; /* wct = 23 */
13361328
__u8 MaxSetupCount;

fs/smb/client/smb2ops.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
15241524
static int
15251525
SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
15261526
u64 persistent_fid, u64 volatile_fid,
1527-
struct copychunk_ioctl *pcchunk)
1527+
struct copychunk_ioctl_req *pcchunk)
15281528
{
15291529
int rc;
15301530
unsigned int ret_data_len;
@@ -1857,10 +1857,10 @@ smb2_copychunk_range(const unsigned int xid,
18571857
{
18581858
int rc = 0;
18591859
unsigned int ret_data_len = 0;
1860-
struct copychunk_ioctl *cc_req = NULL;
1860+
struct copychunk_ioctl_req *cc_req = NULL;
18611861
struct copychunk_ioctl_rsp *cc_rsp = NULL;
18621862
struct cifs_tcon *tcon;
1863-
struct copychunk *chunk;
1863+
struct srv_copychunk *chunk;
18641864
u32 chunks, chunk_count, chunk_bytes;
18651865
u32 copy_bytes, copy_bytes_left;
18661866
u32 chunks_written, bytes_written;

fs/smb/client/smb2pdu.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -193,36 +193,12 @@ struct crt_sd_ctxt {
193193
struct smb3_sd sd;
194194
} __packed;
195195

196-
197-
#define COPY_CHUNK_RES_KEY_SIZE 24
198196
struct resume_key_req {
199197
char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
200198
__le32 ContextLength; /* MBZ */
201199
char Context[]; /* ignored, Windows sets to 4 bytes of zero */
202200
} __packed;
203201

204-
205-
struct copychunk {
206-
__le64 SourceOffset;
207-
__le64 TargetOffset;
208-
__le32 Length;
209-
__le32 Reserved;
210-
} __packed;
211-
212-
/* this goes in the ioctl buffer when doing a copychunk request */
213-
struct copychunk_ioctl {
214-
char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
215-
__le32 ChunkCount;
216-
__le32 Reserved;
217-
struct copychunk Chunks[];
218-
} __packed;
219-
220-
struct copychunk_ioctl_rsp {
221-
__le32 ChunksWritten;
222-
__le32 ChunkBytesWritten;
223-
__le32 TotalBytesWritten;
224-
} __packed;
225-
226202
/* See MS-FSCC 2.3.29 and 2.3.30 */
227203
struct get_retrieval_pointer_count_req {
228204
__le64 StartingVcn; /* virtual cluster number (signed) */

fs/smb/common/smb2pdu.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,35 @@ struct smb2_ioctl_req {
13881388
__u8 Buffer[];
13891389
} __packed;
13901390

1391+
/* See MS-SMB2 2.2.31.1.1 */
1392+
struct srv_copychunk {
1393+
__le64 SourceOffset;
1394+
__le64 TargetOffset;
1395+
__le32 Length;
1396+
__le32 Reserved;
1397+
} __packed;
1398+
1399+
#define COPY_CHUNK_RES_KEY_SIZE 24
1400+
1401+
/* See MS-SMB2 2.2.31.1 */
1402+
/* this goes in the ioctl buffer when doing a copychunk request */
1403+
struct copychunk_ioctl_req {
1404+
union {
1405+
char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
1406+
__le64 SourceKeyU64[3];
1407+
};
1408+
__le32 ChunkCount;
1409+
__le32 Reserved;
1410+
struct srv_copychunk Chunks[] __counted_by_le(ChunkCount);
1411+
} __packed;
1412+
1413+
/* See MS-SMB2 2.2.32.1 */
1414+
struct copychunk_ioctl_rsp {
1415+
__le32 ChunksWritten;
1416+
__le32 ChunkBytesWritten;
1417+
__le32 TotalBytesWritten;
1418+
} __packed;
1419+
13911420
struct smb2_ioctl_rsp {
13921421
struct smb2_hdr hdr;
13931422
__le16 StructureSize; /* Must be 49 */

fs/smb/server/smb2pdu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7754,11 +7754,11 @@ static int fsctl_copychunk(struct ksmbd_work *work,
77547754
}
77557755

77567756
src_fp = ksmbd_lookup_foreign_fd(work,
7757-
le64_to_cpu(ci_req->ResumeKey[0]));
7757+
le64_to_cpu(ci_req->SourceKeyU64[0]));
77587758
dst_fp = ksmbd_lookup_fd_slow(work, volatile_id, persistent_id);
77597759
ret = -EINVAL;
77607760
if (!src_fp ||
7761-
src_fp->persistent_id != le64_to_cpu(ci_req->ResumeKey[1])) {
7761+
src_fp->persistent_id != le64_to_cpu(ci_req->SourceKeyU64[1])) {
77627762
rsp->hdr.Status = STATUS_OBJECT_NAME_NOT_FOUND;
77637763
goto out;
77647764
}

fs/smb/server/smb2pdu.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,26 +174,6 @@ struct resume_key_ioctl_rsp {
174174
__u8 Context[4]; /* ignored, Windows sets to 4 bytes of zero */
175175
} __packed;
176176

177-
struct srv_copychunk {
178-
__le64 SourceOffset;
179-
__le64 TargetOffset;
180-
__le32 Length;
181-
__le32 Reserved;
182-
} __packed;
183-
184-
struct copychunk_ioctl_req {
185-
__le64 ResumeKey[3];
186-
__le32 ChunkCount;
187-
__le32 Reserved;
188-
struct srv_copychunk Chunks[] __counted_by_le(ChunkCount);
189-
} __packed;
190-
191-
struct copychunk_ioctl_rsp {
192-
__le32 ChunksWritten;
193-
__le32 ChunkBytesWritten;
194-
__le32 TotalBytesWritten;
195-
} __packed;
196-
197177
struct file_sparse {
198178
__u8 SetSparse;
199179
} __packed;

0 commit comments

Comments
 (0)