Skip to content

Commit 5191186

Browse files
Olga KornievskaiaJ. Bruce Fields
authored andcommitted
NFSD COPY_NOTIFY xdr
Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
1 parent 84e1b21 commit 5191186

File tree

3 files changed

+129
-2
lines changed

3 files changed

+129
-2
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,13 @@ nfsd4_offload_cancel(struct svc_rqst *rqstp,
13391339
return status;
13401340
}
13411341

1342+
static __be32
1343+
nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1344+
union nfsd4_op_u *u)
1345+
{
1346+
return nfserr_notsupp;
1347+
}
1348+
13421349
static __be32
13431350
nfsd4_fallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
13441351
struct nfsd4_fallocate *fallocate, int flags)
@@ -2292,6 +2299,21 @@ static inline u32 nfsd4_offload_status_rsize(struct svc_rqst *rqstp,
22922299
1 /* osr_complete<1> optional 0 for now */) * sizeof(__be32);
22932300
}
22942301

2302+
static inline u32 nfsd4_copy_notify_rsize(struct svc_rqst *rqstp,
2303+
struct nfsd4_op *op)
2304+
{
2305+
return (op_encode_hdr_size +
2306+
3 /* cnr_lease_time */ +
2307+
1 /* We support one cnr_source_server */ +
2308+
1 /* cnr_stateid seq */ +
2309+
op_encode_stateid_maxsz /* cnr_stateid */ +
2310+
1 /* num cnr_source_server*/ +
2311+
1 /* nl4_type */ +
2312+
1 /* nl4 size */ +
2313+
XDR_QUADLEN(NFS4_OPAQUE_LIMIT) /*nl4_loc + nl4_loc_sz */)
2314+
* sizeof(__be32);
2315+
}
2316+
22952317
#ifdef CONFIG_NFSD_PNFS
22962318
static inline u32 nfsd4_getdeviceinfo_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
22972319
{
@@ -2716,6 +2738,12 @@ static const struct nfsd4_operation nfsd4_ops[] = {
27162738
.op_name = "OP_OFFLOAD_CANCEL",
27172739
.op_rsize_bop = nfsd4_only_status_rsize,
27182740
},
2741+
[OP_COPY_NOTIFY] = {
2742+
.op_func = nfsd4_copy_notify,
2743+
.op_flags = OP_MODIFIES_SOMETHING,
2744+
.op_name = "OP_COPY_NOTIFY",
2745+
.op_rsize_bop = nfsd4_copy_notify_rsize,
2746+
},
27192747
};
27202748

27212749
/**

fs/nfsd/nfs4xdr.c

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,18 @@ nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp,
18371837
return nfsd4_decode_stateid(argp, &os->stateid);
18381838
}
18391839

1840+
static __be32
1841+
nfsd4_decode_copy_notify(struct nfsd4_compoundargs *argp,
1842+
struct nfsd4_copy_notify *cn)
1843+
{
1844+
int status;
1845+
1846+
status = nfsd4_decode_stateid(argp, &cn->cpn_src_stateid);
1847+
if (status)
1848+
return status;
1849+
return nfsd4_decode_nl4_server(argp, &cn->cpn_dst);
1850+
}
1851+
18401852
static __be32
18411853
nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek)
18421854
{
@@ -1938,7 +1950,7 @@ static const nfsd4_dec nfsd4_dec_ops[] = {
19381950
/* new operations for NFSv4.2 */
19391951
[OP_ALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate,
19401952
[OP_COPY] = (nfsd4_dec)nfsd4_decode_copy,
1941-
[OP_COPY_NOTIFY] = (nfsd4_dec)nfsd4_decode_notsupp,
1953+
[OP_COPY_NOTIFY] = (nfsd4_dec)nfsd4_decode_copy_notify,
19421954
[OP_DEALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate,
19431955
[OP_IO_ADVISE] = (nfsd4_dec)nfsd4_decode_notsupp,
19441956
[OP_LAYOUTERROR] = (nfsd4_dec)nfsd4_decode_notsupp,
@@ -4306,6 +4318,46 @@ nfsd42_encode_write_res(struct nfsd4_compoundres *resp,
43064318
return nfs_ok;
43074319
}
43084320

4321+
static __be32
4322+
nfsd42_encode_nl4_server(struct nfsd4_compoundres *resp, struct nl4_server *ns)
4323+
{
4324+
struct xdr_stream *xdr = &resp->xdr;
4325+
struct nfs42_netaddr *addr;
4326+
__be32 *p;
4327+
4328+
p = xdr_reserve_space(xdr, 4);
4329+
*p++ = cpu_to_be32(ns->nl4_type);
4330+
4331+
switch (ns->nl4_type) {
4332+
case NL4_NETADDR:
4333+
addr = &ns->u.nl4_addr;
4334+
4335+
/* netid_len, netid, uaddr_len, uaddr (port included
4336+
* in RPCBIND_MAXUADDRLEN)
4337+
*/
4338+
p = xdr_reserve_space(xdr,
4339+
4 /* netid len */ +
4340+
(XDR_QUADLEN(addr->netid_len) * 4) +
4341+
4 /* uaddr len */ +
4342+
(XDR_QUADLEN(addr->addr_len) * 4));
4343+
if (!p)
4344+
return nfserr_resource;
4345+
4346+
*p++ = cpu_to_be32(addr->netid_len);
4347+
p = xdr_encode_opaque_fixed(p, addr->netid,
4348+
addr->netid_len);
4349+
*p++ = cpu_to_be32(addr->addr_len);
4350+
p = xdr_encode_opaque_fixed(p, addr->addr,
4351+
addr->addr_len);
4352+
break;
4353+
default:
4354+
WARN_ON_ONCE(ns->nl4_type != NL4_NETADDR);
4355+
return nfserr_inval;
4356+
}
4357+
4358+
return 0;
4359+
}
4360+
43094361
static __be32
43104362
nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr,
43114363
struct nfsd4_copy *copy)
@@ -4339,6 +4391,40 @@ nfsd4_encode_offload_status(struct nfsd4_compoundres *resp, __be32 nfserr,
43394391
return nfserr;
43404392
}
43414393

4394+
static __be32
4395+
nfsd4_encode_copy_notify(struct nfsd4_compoundres *resp, __be32 nfserr,
4396+
struct nfsd4_copy_notify *cn)
4397+
{
4398+
struct xdr_stream *xdr = &resp->xdr;
4399+
__be32 *p;
4400+
4401+
if (nfserr)
4402+
return nfserr;
4403+
4404+
/* 8 sec, 4 nsec */
4405+
p = xdr_reserve_space(xdr, 12);
4406+
if (!p)
4407+
return nfserr_resource;
4408+
4409+
/* cnr_lease_time */
4410+
p = xdr_encode_hyper(p, cn->cpn_sec);
4411+
*p++ = cpu_to_be32(cn->cpn_nsec);
4412+
4413+
/* cnr_stateid */
4414+
nfserr = nfsd4_encode_stateid(xdr, &cn->cpn_cnr_stateid);
4415+
if (nfserr)
4416+
return nfserr;
4417+
4418+
/* cnr_src.nl_nsvr */
4419+
p = xdr_reserve_space(xdr, 4);
4420+
if (!p)
4421+
return nfserr_resource;
4422+
4423+
*p++ = cpu_to_be32(1);
4424+
4425+
return nfsd42_encode_nl4_server(resp, &cn->cpn_src);
4426+
}
4427+
43424428
static __be32
43434429
nfsd4_encode_seek(struct nfsd4_compoundres *resp, __be32 nfserr,
43444430
struct nfsd4_seek *seek)
@@ -4436,7 +4522,7 @@ static const nfsd4_enc nfsd4_enc_ops[] = {
44364522
/* NFSv4.2 operations */
44374523
[OP_ALLOCATE] = (nfsd4_enc)nfsd4_encode_noop,
44384524
[OP_COPY] = (nfsd4_enc)nfsd4_encode_copy,
4439-
[OP_COPY_NOTIFY] = (nfsd4_enc)nfsd4_encode_noop,
4525+
[OP_COPY_NOTIFY] = (nfsd4_enc)nfsd4_encode_copy_notify,
44404526
[OP_DEALLOCATE] = (nfsd4_enc)nfsd4_encode_noop,
44414527
[OP_IO_ADVISE] = (nfsd4_enc)nfsd4_encode_noop,
44424528
[OP_LAYOUTERROR] = (nfsd4_enc)nfsd4_encode_noop,

fs/nfsd/xdr4.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,18 @@ struct nfsd4_offload_status {
570570
u32 status;
571571
};
572572

573+
struct nfsd4_copy_notify {
574+
/* request */
575+
stateid_t cpn_src_stateid;
576+
struct nl4_server cpn_dst;
577+
578+
/* response */
579+
stateid_t cpn_cnr_stateid;
580+
u64 cpn_sec;
581+
u32 cpn_nsec;
582+
struct nl4_server cpn_src;
583+
};
584+
573585
struct nfsd4_op {
574586
int opnum;
575587
const struct nfsd4_operation * opdesc;
@@ -629,6 +641,7 @@ struct nfsd4_op {
629641
struct nfsd4_clone clone;
630642
struct nfsd4_copy copy;
631643
struct nfsd4_offload_status offload_status;
644+
struct nfsd4_copy_notify copy_notify;
632645
struct nfsd4_seek seek;
633646
} u;
634647
struct nfs4_replay * replay;

0 commit comments

Comments
 (0)