linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bfields@fieldses.org (J. Bruce Fields)
To: Olga Kornievskaia <kolga@netapp.com>
Cc: bfields@redhat.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH v6 01/10] NFSD CB_OFFLOAD xdr
Date: Thu, 25 Jan 2018 11:43:31 -0500	[thread overview]
Message-ID: <20180125164331.GC20350@fieldses.org> (raw)
In-Reply-To: <20171024174752.74910-2-kolga@netapp.com>

On Tue, Oct 24, 2017 at 01:47:43PM -0400, Olga Kornievskaia wrote:
> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
> ---
>  fs/nfsd/nfs4callback.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/nfsd/state.h        |  1 +
>  fs/nfsd/xdr4.h         |  6 ++++
>  fs/nfsd/xdr4cb.h       | 10 ++++++
>  4 files changed, 114 insertions(+)
> 
> diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> index 49b0a9e..d12d914 100644
> --- a/fs/nfsd/nfs4callback.c
> +++ b/fs/nfsd/nfs4callback.c
> @@ -39,6 +39,7 @@
>  #include "state.h"
>  #include "netns.h"
>  #include "xdr4cb.h"
> +#include "xdr4.h"
>  
>  #define NFSDDBG_FACILITY                NFSDDBG_PROC
>  
> @@ -105,6 +106,7 @@ enum nfs_cb_opnum4 {
>  	OP_CB_WANTS_CANCELLED		= 12,
>  	OP_CB_NOTIFY_LOCK		= 13,
>  	OP_CB_NOTIFY_DEVICEID		= 14,
> +	OP_CB_OFFLOAD			= 15,
>  	OP_CB_ILLEGAL			= 10044
>  };
>  
> @@ -683,6 +685,100 @@ static int nfs4_xdr_dec_cb_notify_lock(struct rpc_rqst *rqstp,
>  }
>  
>  /*
> + * struct write_response4 {
> + *	stateid4	wr_callback_id<1>;
> + *	length4		wr_count;
> + *	stable_how4	wr_committed;
> + *	verifier4	wr_writeverf;
> + * };
> + * union offload_info4 switch (nfsstat4 coa_status) {
> + *	case NFS4_OK:
> + *		write_response4	coa_resok4;
> + *	default:
> + *	length4		coa_bytes_copied;
> + * };
> + * struct CB_OFFLOAD4args {
> + *	nfs_fh4		coa_fh;
> + *	stateid4	coa_stateid;
> + *	offload_info4	coa_offload_info;
> + * };
> + */
> +static void encode_offload_info4(struct xdr_stream *xdr,
> +				 __be32 nfserr,
> +				 const struct nfsd4_copy *cp)
> +{
> +	__be32 *p;
> +
> +	p = xdr_reserve_space(xdr, 4);
> +	*p++ = nfserr;
> +	if (!nfserr) {
> +		p = xdr_reserve_space(xdr, 4 + 8 + 4 + NFS4_VERIFIER_SIZE);
> +		p = xdr_encode_empty_array(p);
> +		p = xdr_encode_hyper(p, cp->cp_res.wr_bytes_written);
> +		*p++ = cpu_to_be32(cp->cp_res.wr_stable_how);
> +		p = xdr_encode_opaque_fixed(p, cp->cp_res.wr_verifier.data,
> +					    NFS4_VERIFIER_SIZE);
> +	} else {
> +		p = xdr_reserve_space(xdr, 8);
> +		p = xdr_encode_hyper(p, cp->cp_res.wr_bytes_written);

Nit: since we're not using this any more, may as well just make that:

		/* We always return success if bytes were written: */
		p = xdr_encode_hyper(p, 0);

--b.

> +	}
> +}
> +
> +static void encode_cb_offload4args(struct xdr_stream *xdr,
> +				   __be32 nfserr,
> +				   const struct knfsd_fh *fh,
> +				   const struct nfsd4_copy *cp,
> +				   struct nfs4_cb_compound_hdr *hdr)
> +{
> +	__be32 *p;
> +
> +	p = xdr_reserve_space(xdr, 4);
> +	*p++ = cpu_to_be32(OP_CB_OFFLOAD);
> +	encode_nfs_fh4(xdr, fh);
> +	encode_stateid4(xdr, &cp->cp_res.cb_stateid);
> +	encode_offload_info4(xdr, nfserr, cp);
> +
> +	hdr->nops++;
> +}
> +
> +static void nfs4_xdr_enc_cb_offload(struct rpc_rqst *req,
> +				    struct xdr_stream *xdr,
> +				    const void *data)
> +{
> +	const struct nfsd4_callback *cb = data;
> +	const struct nfsd4_copy *cp =
> +		container_of(cb, struct nfsd4_copy, cp_cb);
> +	struct nfs4_cb_compound_hdr hdr = {
> +		.ident = 0,
> +		.minorversion = cb->cb_clp->cl_minorversion,
> +	};
> +
> +	encode_cb_compound4args(xdr, &hdr);
> +	encode_cb_sequence4args(xdr, cb, &hdr);
> +	encode_cb_offload4args(xdr, cp->nfserr, &cp->fh, cp, &hdr);
> +	encode_cb_nops(&hdr);
> +}
> +
> +static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp,
> +				   struct xdr_stream *xdr,
> +				   void *data)
> +{
> +	struct nfsd4_callback *cb = data;
> +	struct nfs4_cb_compound_hdr hdr;
> +	int status;
> +
> +	status = decode_cb_compound4res(xdr, &hdr);
> +	if (unlikely(status))
> +		return status;
> +
> +	if (cb) {
> +		status = decode_cb_sequence4res(xdr, cb);
> +		if (unlikely(status || cb->cb_seq_status))
> +			return status;
> +	}
> +	return decode_cb_op_status(xdr, OP_CB_OFFLOAD, &cb->cb_status);
> +}
> +/*
>   * RPC procedure tables
>   */
>  #define PROC(proc, call, argtype, restype)				\
> @@ -703,6 +799,7 @@ static int nfs4_xdr_dec_cb_notify_lock(struct rpc_rqst *rqstp,
>  	PROC(CB_LAYOUT,	COMPOUND,	cb_layout,	cb_layout),
>  #endif
>  	PROC(CB_NOTIFY_LOCK,	COMPOUND,	cb_notify_lock,	cb_notify_lock),
> +	PROC(CB_OFFLOAD,	COMPOUND,	cb_offload,	cb_offload),
>  };
>  
>  static unsigned int nfs4_cb_counts[ARRAY_SIZE(nfs4_cb_procedures)];
> diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
> index 005c911..f8b0210 100644
> --- a/fs/nfsd/state.h
> +++ b/fs/nfsd/state.h
> @@ -570,6 +570,7 @@ enum nfsd4_cb_op {
>  	NFSPROC4_CLNT_CB_NULL = 0,
>  	NFSPROC4_CLNT_CB_RECALL,
>  	NFSPROC4_CLNT_CB_LAYOUT,
> +	NFSPROC4_CLNT_CB_OFFLOAD,
>  	NFSPROC4_CLNT_CB_SEQUENCE,
>  	NFSPROC4_CLNT_CB_NOTIFY_LOCK,
>  };
> diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
> index 1e4edbf..4ac2676 100644
> --- a/fs/nfsd/xdr4.h
> +++ b/fs/nfsd/xdr4.h
> @@ -507,6 +507,7 @@ struct nfsd42_write_res {
>  	u64			wr_bytes_written;
>  	u32			wr_stable_how;
>  	nfs4_verifier		wr_verifier;
> +	stateid_t		cb_stateid;
>  };
>  
>  struct nfsd4_copy {
> @@ -523,6 +524,11 @@ struct nfsd4_copy {
>  
>  	/* response */
>  	struct nfsd42_write_res	cp_res;
> +
> +	/* for cb_offload */
> +	struct nfsd4_callback	cp_cb;
> +	__be32			nfserr;
> +	struct knfsd_fh		fh;
>  };
>  
>  struct nfsd4_seek {
> diff --git a/fs/nfsd/xdr4cb.h b/fs/nfsd/xdr4cb.h
> index 49b719d..7e39913 100644
> --- a/fs/nfsd/xdr4cb.h
> +++ b/fs/nfsd/xdr4cb.h
> @@ -37,3 +37,13 @@
>  #define NFS4_dec_cb_notify_lock_sz	(cb_compound_dec_hdr_sz  +      \
>  					cb_sequence_dec_sz +            \
>  					op_dec_sz)
> +#define enc_cb_offload_info_sz		(1 + 1 + 2 + 1 +		\
> +					XDR_QUADLEN(NFS4_VERIFIER_SIZE))
> +#define NFS4_enc_cb_offload_sz		(cb_compound_enc_hdr_sz +       \
> +					cb_sequence_enc_sz +            \
> +					enc_nfs4_fh_sz +		\
> +					enc_stateid_sz +		\
> +					enc_cb_offload_info_sz)
> +#define NFS4_dec_cb_offload_sz		(cb_compound_dec_hdr_sz  +      \
> +					cb_sequence_dec_sz +            \
> +					op_dec_sz)
> -- 
> 1.8.3.1

  reply	other threads:[~2018-01-25 16:43 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-24 17:47 [PATCH v6 00/10] NFSD support for asynchronous COPY Olga Kornievskaia
2017-10-24 17:47 ` [PATCH v6 01/10] NFSD CB_OFFLOAD xdr Olga Kornievskaia
2018-01-25 16:43   ` J. Bruce Fields [this message]
2018-01-26 15:16     ` Olga Kornievskaia
2017-10-24 17:47 ` [PATCH v6 02/10] NFSD OFFLOAD_STATUS xdr Olga Kornievskaia
2017-10-24 17:47 ` [PATCH v6 03/10] NFSD OFFLOAD_CANCEL xdr Olga Kornievskaia
2017-10-24 17:47 ` [PATCH v6 04/10] NFSD xdr callback stateid in async COPY reply Olga Kornievskaia
2017-10-24 17:47 ` [PATCH v6 05/10] NFSD first draft of async copy Olga Kornievskaia
2018-01-25 22:04   ` J. Bruce Fields
2018-01-26 15:17     ` Olga Kornievskaia
2018-02-15 19:59     ` Olga Kornievskaia
2018-02-15 20:06       ` J. Bruce Fields
2018-01-25 22:29   ` J. Bruce Fields
2018-01-26 15:17     ` Olga Kornievskaia
2018-01-26 21:34   ` J. Bruce Fields
2018-02-02 19:50     ` Olga Kornievskaia
2018-02-02 19:55       ` J. Bruce Fields
2017-10-24 17:47 ` [PATCH v6 06/10] NFSD return nfs4_stid in nfs4_preprocess_stateid_op Olga Kornievskaia
2017-10-24 17:47 ` [PATCH v6 07/10] NFSD create new stateid for async copy Olga Kornievskaia
2018-01-26 21:37   ` J. Bruce Fields
2018-01-26 21:59   ` J. Bruce Fields
2018-02-02 20:45     ` Olga Kornievskaia
2018-02-02 21:45       ` J. Bruce Fields
2018-02-15 22:18         ` Olga Kornievskaia
2018-02-16  1:43           ` J. Bruce Fields
2018-02-16 16:06             ` Olga Kornievskaia
2018-02-16 18:12               ` J. Bruce Fields
2018-02-16 20:53                 ` Olga Kornievskaia
2018-02-20 18:48                   ` J. Bruce Fields
2018-03-06 17:15                     ` Olga Kornievskaia
2018-03-06 19:33                       ` J. Bruce Fields
2017-10-24 17:47 ` [PATCH v6 08/10] NFSD handle OFFLOAD_CANCEL op Olga Kornievskaia
2018-02-16 17:28   ` Olga Kornievskaia
2018-02-16 18:10     ` J. Bruce Fields
2017-10-24 17:47 ` [PATCH v6 09/10] NFSD support OFFLOAD_STATUS Olga Kornievskaia
2017-10-24 17:47 ` [PATCH v6 10/10] NFSD stop queued async copies on client shutdown Olga Kornievskaia
2018-01-25 22:22   ` J. Bruce Fields
2018-01-26 15:17     ` Olga Kornievskaia
2017-11-03 19:57 ` [PATCH v6 00/10] NFSD support for asynchronous COPY Olga Kornievskaia
2017-11-10 15:01   ` Olga Kornievskaia
2017-11-14  0:48     ` J. Bruce Fields
2017-11-28 20:28       ` Olga Kornievskaia
2017-11-30 20:18         ` J. Bruce Fields
2017-11-30 23:03           ` Olga Kornievskaia
2017-12-04 21:32             ` J. Bruce Fields
     [not found]               ` <CAN-5tyEVSwBmPMtUBJYDdLi7FK2MNMGuDQrrsvp776zD3Jcw0w@mail.gmail.com>
2018-01-22 16:51                 ` Olga Kornievskaia
2018-01-25 22:33                   ` J. Bruce Fields
2018-01-26 15:16                     ` Olga Kornievskaia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180125164331.GC20350@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=bfields@redhat.com \
    --cc=kolga@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).