Skip to content

Commit cb95dee

Browse files
olgakorn1amschuma-ntap
authored andcommitted
NFS OFFLOAD_CANCEL xdr
Signed-off-by: Olga Kornievskaia <kolga@netapp.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 5178a12 commit cb95dee

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed

fs/nfs/nfs42xdr.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
NFS42_WRITE_RES_SIZE + \
2727
1 /* cr_consecutive */ + \
2828
1 /* cr_synchronous */)
29+
#define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \
30+
XDR_QUADLEN(NFS4_STATEID_SIZE))
31+
#define decode_offload_cancel_maxsz (op_decode_hdr_maxsz)
2932
#define encode_deallocate_maxsz (op_encode_hdr_maxsz + \
3033
encode_fallocate_maxsz)
3134
#define decode_deallocate_maxsz (op_decode_hdr_maxsz)
@@ -75,6 +78,12 @@
7578
decode_putfh_maxsz + \
7679
decode_copy_maxsz + \
7780
decode_commit_maxsz)
81+
#define NFS4_enc_offload_cancel_sz (compound_encode_hdr_maxsz + \
82+
encode_putfh_maxsz + \
83+
encode_offload_cancel_maxsz)
84+
#define NFS4_dec_offload_cancel_sz (compound_decode_hdr_maxsz + \
85+
decode_putfh_maxsz + \
86+
decode_offload_cancel_maxsz)
7887
#define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
7988
encode_putfh_maxsz + \
8089
encode_deallocate_maxsz + \
@@ -145,6 +154,14 @@ static void encode_copy(struct xdr_stream *xdr,
145154
encode_uint32(xdr, 0); /* src server list */
146155
}
147156

157+
static void encode_offload_cancel(struct xdr_stream *xdr,
158+
const struct nfs42_offload_status_args *args,
159+
struct compound_hdr *hdr)
160+
{
161+
encode_op_hdr(xdr, OP_OFFLOAD_CANCEL, decode_offload_cancel_maxsz, hdr);
162+
encode_nfs4_stateid(xdr, &args->osa_stateid);
163+
}
164+
148165
static void encode_deallocate(struct xdr_stream *xdr,
149166
const struct nfs42_falloc_args *args,
150167
struct compound_hdr *hdr)
@@ -260,6 +277,25 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
260277
encode_nops(&hdr);
261278
}
262279

280+
/*
281+
* Encode OFFLOAD_CANEL request
282+
*/
283+
static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req,
284+
struct xdr_stream *xdr,
285+
const void *data)
286+
{
287+
const struct nfs42_offload_status_args *args = data;
288+
struct compound_hdr hdr = {
289+
.minorversion = nfs4_xdr_minorversion(&args->osa_seq_args),
290+
};
291+
292+
encode_compound_hdr(xdr, req, &hdr);
293+
encode_sequence(xdr, &args->osa_seq_args, &hdr);
294+
encode_putfh(xdr, args->osa_src_fh, &hdr);
295+
encode_offload_cancel(xdr, args, &hdr);
296+
encode_nops(&hdr);
297+
}
298+
263299
/*
264300
* Encode DEALLOCATE request
265301
*/
@@ -413,6 +449,12 @@ static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res)
413449
return decode_copy_requirements(xdr, res);
414450
}
415451

452+
static int decode_offload_cancel(struct xdr_stream *xdr,
453+
struct nfs42_offload_status_res *res)
454+
{
455+
return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL);
456+
}
457+
416458
static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
417459
{
418460
return decode_op_hdr(xdr, OP_DEALLOCATE);
@@ -512,6 +554,32 @@ static int nfs4_xdr_dec_copy(struct rpc_rqst *rqstp,
512554
return status;
513555
}
514556

557+
/*
558+
* Decode OFFLOAD_CANCEL response
559+
*/
560+
static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp,
561+
struct xdr_stream *xdr,
562+
void *data)
563+
{
564+
struct nfs42_offload_status_res *res = data;
565+
struct compound_hdr hdr;
566+
int status;
567+
568+
status = decode_compound_hdr(xdr, &hdr);
569+
if (status)
570+
goto out;
571+
status = decode_sequence(xdr, &res->osr_seq_res, rqstp);
572+
if (status)
573+
goto out;
574+
status = decode_putfh(xdr);
575+
if (status)
576+
goto out;
577+
status = decode_offload_cancel(xdr, res);
578+
579+
out:
580+
return status;
581+
}
582+
515583
/*
516584
* Decode DEALLOCATE request
517585
*/

fs/nfs/nfs4proc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9620,6 +9620,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
96209620
| NFS_CAP_LGOPEN
96219621
| NFS_CAP_ALLOCATE
96229622
| NFS_CAP_COPY
9623+
| NFS_CAP_OFFLOAD_CANCEL
96239624
| NFS_CAP_DEALLOCATE
96249625
| NFS_CAP_SEEK
96259626
| NFS_CAP_LAYOUTSTATS

fs/nfs/nfs4xdr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7789,6 +7789,7 @@ const struct rpc_procinfo nfs4_procedures[] = {
77897789
PROC42(LAYOUTSTATS, enc_layoutstats, dec_layoutstats),
77907790
PROC42(CLONE, enc_clone, dec_clone),
77917791
PROC42(COPY, enc_copy, dec_copy),
7792+
PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel),
77927793
PROC(LOOKUPP, enc_lookupp, dec_lookupp),
77937794
};
77947795

include/linux/nfs4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ enum {
527527
NFSPROC4_CLNT_LAYOUTSTATS,
528528
NFSPROC4_CLNT_CLONE,
529529
NFSPROC4_CLNT_COPY,
530+
NFSPROC4_CLNT_OFFLOAD_CANCEL,
530531

531532
NFSPROC4_CLNT_LOOKUPP,
532533
};

include/linux/nfs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,5 +255,6 @@ struct nfs_server {
255255
#define NFS_CAP_LAYOUTSTATS (1U << 22)
256256
#define NFS_CAP_CLONE (1U << 23)
257257
#define NFS_CAP_COPY (1U << 24)
258+
#define NFS_CAP_OFFLOAD_CANCEL (1U << 25)
258259

259260
#endif

include/linux/nfs_xdr.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,18 @@ struct nfs42_copy_res {
14031403
struct nfs_commitres commit_res;
14041404
};
14051405

1406+
struct nfs42_offload_status_args {
1407+
struct nfs4_sequence_args osa_seq_args;
1408+
struct nfs_fh *osa_src_fh;
1409+
nfs4_stateid osa_stateid;
1410+
};
1411+
1412+
struct nfs42_offload_status_res {
1413+
struct nfs4_sequence_res osr_seq_res;
1414+
uint64_t osr_count;
1415+
int osr_status;
1416+
};
1417+
14061418
struct nfs42_seek_args {
14071419
struct nfs4_sequence_args seq_args;
14081420

0 commit comments

Comments
 (0)