NFS OFFLOAD_CANCEL xdr
authorOlga Kornievskaia <kolga@netapp.com>
Mon, 9 Jul 2018 19:13:29 +0000 (15:13 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 9 Aug 2018 16:56:38 +0000 (12:56 -0400)
Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/nfs42xdr.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4xdr.c
include/linux/nfs4.h
include/linux/nfs_fs_sb.h
include/linux/nfs_xdr.h

index 5966e1e7b1f51d059e54f4b3a5506d033ed5cc22..09a540d035b880b0e39b4ad71c6a33b3365f59a2 100644 (file)
@@ -26,6 +26,9 @@
                                         NFS42_WRITE_RES_SIZE + \
                                         1 /* cr_consecutive */ + \
                                         1 /* cr_synchronous */)
+#define encode_offload_cancel_maxsz    (op_encode_hdr_maxsz + \
+                                        XDR_QUADLEN(NFS4_STATEID_SIZE))
+#define decode_offload_cancel_maxsz    (op_decode_hdr_maxsz)
 #define encode_deallocate_maxsz                (op_encode_hdr_maxsz + \
                                         encode_fallocate_maxsz)
 #define decode_deallocate_maxsz                (op_decode_hdr_maxsz)
                                         decode_putfh_maxsz + \
                                         decode_copy_maxsz + \
                                         decode_commit_maxsz)
+#define NFS4_enc_offload_cancel_sz     (compound_encode_hdr_maxsz + \
+                                        encode_putfh_maxsz + \
+                                        encode_offload_cancel_maxsz)
+#define NFS4_dec_offload_cancel_sz     (compound_decode_hdr_maxsz + \
+                                        decode_putfh_maxsz + \
+                                        decode_offload_cancel_maxsz)
 #define NFS4_enc_deallocate_sz         (compound_encode_hdr_maxsz + \
                                         encode_putfh_maxsz + \
                                         encode_deallocate_maxsz + \
@@ -145,6 +154,14 @@ static void encode_copy(struct xdr_stream *xdr,
        encode_uint32(xdr, 0); /* src server list */
 }
 
+static void encode_offload_cancel(struct xdr_stream *xdr,
+                                 const struct nfs42_offload_status_args *args,
+                                 struct compound_hdr *hdr)
+{
+       encode_op_hdr(xdr, OP_OFFLOAD_CANCEL, decode_offload_cancel_maxsz, hdr);
+       encode_nfs4_stateid(xdr, &args->osa_stateid);
+}
+
 static void encode_deallocate(struct xdr_stream *xdr,
                              const struct nfs42_falloc_args *args,
                              struct compound_hdr *hdr)
@@ -260,6 +277,25 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
        encode_nops(&hdr);
 }
 
+/*
+ * Encode OFFLOAD_CANEL request
+ */
+static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req,
+                                       struct xdr_stream *xdr,
+                                       const void *data)
+{
+       const struct nfs42_offload_status_args *args = data;
+       struct compound_hdr hdr = {
+               .minorversion = nfs4_xdr_minorversion(&args->osa_seq_args),
+       };
+
+       encode_compound_hdr(xdr, req, &hdr);
+       encode_sequence(xdr, &args->osa_seq_args, &hdr);
+       encode_putfh(xdr, args->osa_src_fh, &hdr);
+       encode_offload_cancel(xdr, args, &hdr);
+       encode_nops(&hdr);
+}
+
 /*
  * Encode DEALLOCATE request
  */
@@ -413,6 +449,12 @@ static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res)
        return decode_copy_requirements(xdr, res);
 }
 
+static int decode_offload_cancel(struct xdr_stream *xdr,
+                                struct nfs42_offload_status_res *res)
+{
+       return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL);
+}
+
 static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
 {
        return decode_op_hdr(xdr, OP_DEALLOCATE);
@@ -512,6 +554,32 @@ out:
        return status;
 }
 
+/*
+ * Decode OFFLOAD_CANCEL response
+ */
+static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp,
+                                      struct xdr_stream *xdr,
+                                      void *data)
+{
+       struct nfs42_offload_status_res *res = data;
+       struct compound_hdr hdr;
+       int status;
+
+       status = decode_compound_hdr(xdr, &hdr);
+       if (status)
+               goto out;
+       status = decode_sequence(xdr, &res->osr_seq_res, rqstp);
+       if (status)
+               goto out;
+       status = decode_putfh(xdr);
+       if (status)
+               goto out;
+       status = decode_offload_cancel(xdr, res);
+
+out:
+       return status;
+}
+
 /*
  * Decode DEALLOCATE request
  */
index 124a9f97c36683dbb273c0a5eff7eb7f784155ae..b22b41eff9c09c32ff94795694edb4f2279c2490 100644 (file)
@@ -9620,6 +9620,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
                | NFS_CAP_LGOPEN
                | NFS_CAP_ALLOCATE
                | NFS_CAP_COPY
+               | NFS_CAP_OFFLOAD_CANCEL
                | NFS_CAP_DEALLOCATE
                | NFS_CAP_SEEK
                | NFS_CAP_LAYOUTSTATS
index cd41d2577a049b489496b24a05ec2e28b959ee9d..b7bde12d8cd518ce7b8da11d7ae3b6239ca3292f 100644 (file)
@@ -7789,6 +7789,7 @@ const struct rpc_procinfo nfs4_procedures[] = {
        PROC42(LAYOUTSTATS,     enc_layoutstats,        dec_layoutstats),
        PROC42(CLONE,           enc_clone,              dec_clone),
        PROC42(COPY,            enc_copy,               dec_copy),
+       PROC42(OFFLOAD_CANCEL,  enc_offload_cancel,     dec_offload_cancel),
        PROC(LOOKUPP,           enc_lookupp,            dec_lookupp),
 };
 
index 57ffaa20d5649f5cdc77e4a1fd088201e66286ed..c44b8729322931e85e6c47e7a311bb5308f83d68 100644 (file)
@@ -527,6 +527,7 @@ enum {
        NFSPROC4_CLNT_LAYOUTSTATS,
        NFSPROC4_CLNT_CLONE,
        NFSPROC4_CLNT_COPY,
+       NFSPROC4_CLNT_OFFLOAD_CANCEL,
 
        NFSPROC4_CLNT_LOOKUPP,
 };
index 2c18d618604ecfc7f8342236131e227c2003c89a..fbc735f08d7e1d136a09773ecfa5974286a8de97 100644 (file)
@@ -255,5 +255,6 @@ struct nfs_server {
 #define NFS_CAP_LAYOUTSTATS    (1U << 22)
 #define NFS_CAP_CLONE          (1U << 23)
 #define NFS_CAP_COPY           (1U << 24)
+#define NFS_CAP_OFFLOAD_CANCEL (1U << 25)
 
 #endif
index 3b7325cfb291cd4412205d6446e896dace4b125d..85e928a56cef6273fbfb8764160da960fd1d7ba6 100644 (file)
@@ -1403,6 +1403,18 @@ struct nfs42_copy_res {
        struct nfs_commitres            commit_res;
 };
 
+struct nfs42_offload_status_args {
+       struct nfs4_sequence_args       osa_seq_args;
+       struct nfs_fh                   *osa_src_fh;
+       nfs4_stateid                    osa_stateid;
+};
+
+struct nfs42_offload_status_res {
+       struct nfs4_sequence_res        osr_seq_res;
+       uint64_t                        osr_count;
+       int                             osr_status;
+};
+
 struct nfs42_seek_args {
        struct nfs4_sequence_args       seq_args;