Skip to content

Commit 1d38f3f

Browse files
olgakorn1Olga Kornievskaia
authored andcommitted
NFS: add ca_source_server<> to COPY
Support only one source server address: the same address that the client and source server use. Signed-off-by: Andy Adamson <[email protected]> Signed-off-by: Olga Kornievskaia <[email protected]>
1 parent 0491567 commit 1d38f3f

File tree

5 files changed

+36
-13
lines changed

5 files changed

+36
-13
lines changed

fs/nfs/nfs42.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
/* nfs4.2proc.c */
1616
#ifdef CONFIG_NFS_V4_2
1717
int nfs42_proc_allocate(struct file *, loff_t, loff_t);
18-
ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t);
18+
ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t,
19+
struct nl4_server *, nfs4_stateid *);
1920
int nfs42_proc_deallocate(struct file *, loff_t, loff_t);
2021
loff_t nfs42_proc_llseek(struct file *, loff_t, int);
2122
int nfs42_proc_layoutstats_generic(struct nfs_server *,

fs/nfs/nfs42proc.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ static ssize_t _nfs42_proc_copy(struct file *src,
243243
struct file *dst,
244244
struct nfs_lock_context *dst_lock,
245245
struct nfs42_copy_args *args,
246-
struct nfs42_copy_res *res)
246+
struct nfs42_copy_res *res,
247+
struct nl4_server *nss,
248+
nfs4_stateid *cnr_stateid)
247249
{
248250
struct rpc_message msg = {
249251
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY],
@@ -257,11 +259,15 @@ static ssize_t _nfs42_proc_copy(struct file *src,
257259
size_t count = args->count;
258260
ssize_t status;
259261

260-
status = nfs4_set_rw_stateid(&args->src_stateid, src_lock->open_context,
261-
src_lock, FMODE_READ);
262-
if (status)
263-
return status;
264-
262+
if (nss) {
263+
args->cp_src = nss;
264+
nfs4_stateid_copy(&args->src_stateid, cnr_stateid);
265+
} else {
266+
status = nfs4_set_rw_stateid(&args->src_stateid,
267+
src_lock->open_context, src_lock, FMODE_READ);
268+
if (status)
269+
return status;
270+
}
265271
status = nfs_filemap_write_and_wait_range(file_inode(src)->i_mapping,
266272
pos_src, pos_src + (loff_t)count - 1);
267273
if (status)
@@ -325,8 +331,9 @@ static ssize_t _nfs42_proc_copy(struct file *src,
325331
}
326332

327333
ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
328-
struct file *dst, loff_t pos_dst,
329-
size_t count)
334+
struct file *dst, loff_t pos_dst, size_t count,
335+
struct nl4_server *nss,
336+
nfs4_stateid *cnr_stateid)
330337
{
331338
struct nfs_server *server = NFS_SERVER(file_inode(dst));
332339
struct nfs_lock_context *src_lock;
@@ -368,7 +375,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
368375
inode_lock(file_inode(dst));
369376
err = _nfs42_proc_copy(src, src_lock,
370377
dst, dst_lock,
371-
&args, &res);
378+
&args, &res,
379+
nss, cnr_stateid);
372380
inode_unlock(file_inode(dst));
373381

374382
if (err >= 0)

fs/nfs/nfs42xdr.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
#define encode_copy_maxsz (op_encode_hdr_maxsz + \
2222
XDR_QUADLEN(NFS4_STATEID_SIZE) + \
2323
XDR_QUADLEN(NFS4_STATEID_SIZE) + \
24-
2 + 2 + 2 + 1 + 1 + 1)
24+
2 + 2 + 2 + 1 + 1 + 1 +\
25+
1 + /* One cnr_source_server */\
26+
1 + /* nl4_type */ \
27+
1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
2528
#define decode_copy_maxsz (op_decode_hdr_maxsz + \
2629
NFS42_WRITE_RES_SIZE + \
2730
1 /* cr_consecutive */ + \
@@ -216,7 +219,12 @@ static void encode_copy(struct xdr_stream *xdr,
216219

217220
encode_uint32(xdr, 1); /* consecutive = true */
218221
encode_uint32(xdr, args->sync);
219-
encode_uint32(xdr, 0); /* src server list */
222+
if (args->cp_src == NULL) { /* intra-ssc */
223+
encode_uint32(xdr, 0); /* no src server list */
224+
return;
225+
}
226+
encode_uint32(xdr, 1); /* supporting 1 server */
227+
encode_nl4_server(xdr, args->cp_src);
220228
}
221229

222230
static void encode_offload_cancel(struct xdr_stream *xdr,

fs/nfs/nfs4file.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
134134
size_t count, unsigned int flags)
135135
{
136136
struct nfs42_copy_notify_res *cn_resp = NULL;
137+
struct nl4_server *nss = NULL;
138+
nfs4_stateid *cnrs = NULL;
137139
ssize_t ret;
138140

139141
/* Only offload copy if superblock is the same */
@@ -154,8 +156,11 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
154156
ret = -EOPNOTSUPP;
155157
goto out;
156158
}
159+
nss = &cn_resp->cnr_src;
160+
cnrs = &cn_resp->cnr_stateid;
157161
}
158-
ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count);
162+
ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count,
163+
nss, cnrs);
159164
out:
160165
kfree(cn_resp);
161166
return ret;

include/linux/nfs_xdr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,7 @@ struct nfs42_copy_args {
14351435

14361436
u64 count;
14371437
bool sync;
1438+
struct nl4_server *cp_src;
14381439
};
14391440

14401441
struct nfs42_write_res {

0 commit comments

Comments
 (0)