Skip to content

Commit 8955e7c

Browse files
chuckleverTrond Myklebust
authored andcommitted
NFS: Implement NFSv4.2's OFFLOAD_STATUS XDR
Add XDR encoding and decoding functions for the NFSv4.2 OFFLOAD_STATUS operation. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Benjamin Coddington <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Trond Myklebust <[email protected]>
1 parent 43502f6 commit 8955e7c

File tree

4 files changed

+91
-2
lines changed

4 files changed

+91
-2
lines changed

fs/nfs/nfs42xdr.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
#define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \
3636
XDR_QUADLEN(NFS4_STATEID_SIZE))
3737
#define decode_offload_cancel_maxsz (op_decode_hdr_maxsz)
38+
#define encode_offload_status_maxsz (op_encode_hdr_maxsz + \
39+
XDR_QUADLEN(NFS4_STATEID_SIZE))
40+
#define decode_offload_status_maxsz (op_decode_hdr_maxsz + \
41+
2 /* osr_count */ + \
42+
2 /* osr_complete */)
3843
#define encode_copy_notify_maxsz (op_encode_hdr_maxsz + \
3944
XDR_QUADLEN(NFS4_STATEID_SIZE) + \
4045
1 + /* nl4_type */ \
@@ -143,6 +148,14 @@
143148
decode_sequence_maxsz + \
144149
decode_putfh_maxsz + \
145150
decode_offload_cancel_maxsz)
151+
#define NFS4_enc_offload_status_sz (compound_encode_hdr_maxsz + \
152+
encode_sequence_maxsz + \
153+
encode_putfh_maxsz + \
154+
encode_offload_status_maxsz)
155+
#define NFS4_dec_offload_status_sz (compound_decode_hdr_maxsz + \
156+
decode_sequence_maxsz + \
157+
decode_putfh_maxsz + \
158+
decode_offload_status_maxsz)
146159
#define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \
147160
encode_sequence_maxsz + \
148161
encode_putfh_maxsz + \
@@ -345,6 +358,14 @@ static void encode_offload_cancel(struct xdr_stream *xdr,
345358
encode_nfs4_stateid(xdr, &args->osa_stateid);
346359
}
347360

361+
static void encode_offload_status(struct xdr_stream *xdr,
362+
const struct nfs42_offload_status_args *args,
363+
struct compound_hdr *hdr)
364+
{
365+
encode_op_hdr(xdr, OP_OFFLOAD_STATUS, decode_offload_status_maxsz, hdr);
366+
encode_nfs4_stateid(xdr, &args->osa_stateid);
367+
}
368+
348369
static void encode_copy_notify(struct xdr_stream *xdr,
349370
const struct nfs42_copy_notify_args *args,
350371
struct compound_hdr *hdr)
@@ -569,6 +590,25 @@ static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req,
569590
encode_nops(&hdr);
570591
}
571592

593+
/*
594+
* Encode OFFLOAD_STATUS request
595+
*/
596+
static void nfs4_xdr_enc_offload_status(struct rpc_rqst *req,
597+
struct xdr_stream *xdr,
598+
const void *data)
599+
{
600+
const struct nfs42_offload_status_args *args = data;
601+
struct compound_hdr hdr = {
602+
.minorversion = nfs4_xdr_minorversion(&args->osa_seq_args),
603+
};
604+
605+
encode_compound_hdr(xdr, req, &hdr);
606+
encode_sequence(xdr, &args->osa_seq_args, &hdr);
607+
encode_putfh(xdr, args->osa_src_fh, &hdr);
608+
encode_offload_status(xdr, args, &hdr);
609+
encode_nops(&hdr);
610+
}
611+
572612
/*
573613
* Encode COPY_NOTIFY request
574614
*/
@@ -921,6 +961,26 @@ static int decode_offload_cancel(struct xdr_stream *xdr,
921961
return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL);
922962
}
923963

964+
static int decode_offload_status(struct xdr_stream *xdr,
965+
struct nfs42_offload_status_res *res)
966+
{
967+
ssize_t result;
968+
int status;
969+
970+
status = decode_op_hdr(xdr, OP_OFFLOAD_STATUS);
971+
if (status)
972+
return status;
973+
/* osr_count */
974+
if (xdr_stream_decode_u64(xdr, &res->osr_count) < 0)
975+
return -EIO;
976+
/* osr_complete<1> */
977+
result = xdr_stream_decode_uint32_array(xdr, &res->osr_complete, 1);
978+
if (result < 0)
979+
return -EIO;
980+
res->complete_count = result;
981+
return 0;
982+
}
983+
924984
static int decode_copy_notify(struct xdr_stream *xdr,
925985
struct nfs42_copy_notify_res *res)
926986
{
@@ -1370,6 +1430,32 @@ static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp,
13701430
return status;
13711431
}
13721432

1433+
/*
1434+
* Decode OFFLOAD_STATUS response
1435+
*/
1436+
static int nfs4_xdr_dec_offload_status(struct rpc_rqst *rqstp,
1437+
struct xdr_stream *xdr,
1438+
void *data)
1439+
{
1440+
struct nfs42_offload_status_res *res = data;
1441+
struct compound_hdr hdr;
1442+
int status;
1443+
1444+
status = decode_compound_hdr(xdr, &hdr);
1445+
if (status)
1446+
goto out;
1447+
status = decode_sequence(xdr, &res->osr_seq_res, rqstp);
1448+
if (status)
1449+
goto out;
1450+
status = decode_putfh(xdr);
1451+
if (status)
1452+
goto out;
1453+
status = decode_offload_status(xdr, res);
1454+
1455+
out:
1456+
return status;
1457+
}
1458+
13731459
/*
13741460
* Decode COPY_NOTIFY response
13751461
*/

fs/nfs/nfs4xdr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7702,6 +7702,7 @@ const struct rpc_procinfo nfs4_procedures[] = {
77027702
PROC42(CLONE, enc_clone, dec_clone),
77037703
PROC42(COPY, enc_copy, dec_copy),
77047704
PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel),
7705+
PROC42(OFFLOAD_STATUS, enc_offload_status, dec_offload_status),
77057706
PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify),
77067707
PROC(LOOKUPP, enc_lookupp, dec_lookupp),
77077708
PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror),

include/linux/nfs4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ enum {
691691
NFSPROC4_CLNT_LISTXATTRS,
692692
NFSPROC4_CLNT_REMOVEXATTR,
693693
NFSPROC4_CLNT_READ_PLUS,
694+
NFSPROC4_CLNT_OFFLOAD_STATUS,
694695
};
695696

696697
/* nfs41 types */

include/linux/nfs_xdr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,9 @@ struct nfs42_offload_status_args {
15151515

15161516
struct nfs42_offload_status_res {
15171517
struct nfs4_sequence_res osr_seq_res;
1518-
uint64_t osr_count;
1519-
int osr_status;
1518+
u64 osr_count;
1519+
int complete_count;
1520+
u32 osr_complete;
15201521
};
15211522

15221523
struct nfs42_copy_notify_args {

0 commit comments

Comments
 (0)