All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olga Kornievskaia <aglo@umich.edu>
To: "J. Bruce Fields" <bfields@redhat.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	Olga Kornievskaia <kolga@netapp.com>,
	Trond Myklebust <Trond.Myklebust@primarydata.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	linux-nfs <linux-nfs@vger.kernel.org>
Subject: Re: [RFC v3 27/42] NFSD: allow inter server COPY to have a STALE source server fh
Date: Fri, 15 Sep 2017 15:46:03 -0400	[thread overview]
Message-ID: <CAN-5tyHasLG79AQoduP=Bt=L9Tpwy4KVi39J+47nzH2jQnseUw@mail.gmail.com> (raw)
In-Reply-To: <20170915014722.GF7734@parsley.fieldses.org>

On Thu, Sep 14, 2017 at 9:47 PM, J. Bruce Fields <bfields@redhat.com> wrote:
> On Thu, Sep 14, 2017 at 02:44:32PM -0400, Olga Kornievskaia wrote:
>> How about changing it to be more restrictive by checking within the
>> while loop that
>> if it's a PUTFH and it's followed by the SAVE_FH+PUTFH+COPY only
>> then set the NO_VERIFY_FH.
>
> I agree that the only op that could reasonably follow the first PUTFH of
> a foreign filehandle is a SAVEFH.  But once we've saved the foreign
> filehandle, the client could in theory do all sorts of stuff, as you
> say:
>
>> I guess we can allow some other operations between the 2nd PUTFH and
>> COPY because the 2nd filehandle will be validated and must be valid to
>> continue processing the compound.
>
> PUTHF+SAVEFH+PUTFH+GETATTR+COPY might be useful to get pre-copy
> attributes of the target file, for example?
>
> I'd rather not restrict this if we don't need to.
>
> We could do something like:
>
>         - if this op is PUTFH
>         - if the following is not SAVEFH, stop and verify the
>           filehandle.
>         - otherwise, skip to the next operation that uses a saved
>           filehandle.  The possibilities are:
>                 - RENAME, LINK, RESTOREFH, CLONE: stop and verify the
>                   filehandle.
>                 - COPY: if it's a local copy, stop and verify the
>                   filehandle.  Otherwise, allow the PUTFH to succeed and
>                   delay verification.

OK so I can peep into the upcoming copy and see if it's inter or intra and
then based on that I can set NO_VERIFY_FH for processing the putfh.

>> Somewhere else you were talking about how a "foreign" file handle can
>> mean something to the server. If that's the case and we do allow for
>> operations between putfh, savefh, putfh then we'll get into trouble
>> that I can't think we can get out of.
>>
>> If it's a inter copy and the source file handle means something to the
>> server I can think of the following scenario: the state won't be
>> flagged IS_STALE then the filehandle would go thru the checks you
>> listed below and can (unintentionally) result in an error (eg.,
>> err_moved?).
>
> I don't see any problem with just leaving those checks in.  If the
> current filehandle is not validated, then there's already a
> current_fh->fh_dentry check that skips the ABSENT_FH check, for example.
>
>> This should be changed to
>> if (HAS_CSTATE_FLAG(cstate, IS_STALE_FH) && op->opnum == OP_SAVEFH)
>> then we need to skip the checks for savefh as it has no valid file handle.
>>
>> Does that address your concern?
>
> I think you only need to skip the nofilehandle check in this case, not
> the other stuff.

As long as I can add that current_fh->fh_export is not null for the 2nd check
otherwise it leads to an oops.

> I don't think the IS_STALE_FH flag is needed at all.

We still need it so that the savefh process can skip the check for the
filehandle.
Or I can use something like checking that fh_dentry and fh_export are both null
and use that to mean I need to check the filehandle check in savefh.

I think explicitly marking it makes the code either to understand instead of
'knowning/remembering' that lack of fh_dentry+fh_export means inter copy?

>> >>               if (!current_fh->fh_dentry) {
>> >>                       if (!(opdesc->op_flags & ALLOWED_WITHOUT_FH)) {
>> >>                               op->status = nfserr_nofilehandle;
>> >> @@ -1844,6 +1880,7 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp,
>> >>
>> >>               if (opdesc->op_get_currentstateid)
>> >>                       opdesc->op_get_currentstateid(cstate, &op->u);
>> >> +call_op:
>> >>               op->status = opdesc->op_func(rqstp, cstate, &op->u);
>> >>
>> >>               /* Only from SEQUENCE */
>> >> @@ -1862,6 +1899,14 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp,
>> >>                       if (need_wrongsec_check(rqstp))
>> >>                               op->status = check_nfsd_access(current_fh->fh_export, rqstp);
>> >>               }
>> >> +             /* Only from intra COPY */
>> >> +             if (cstate->status == nfserr_copy_stalefh) {
>> >> +                     dprintk("%s NFS4.2 intra COPY stale src filehandle\n",
>> >> +                             __func__);
>> >> +                     status = nfserr_stale;
>> >> +                     nfsd4_adjust_encode(resp);
>> >
>> > Are you sure it's safe just to throw away any operations since that
>> > stale PUTFH?  What if some of those operations had side effects?
>>
>> If COPY comes in PUTFH,SAVEFH, PUTFH,COPY compound then
>> I think it's safe?
>
> The spec says "If a server supports the inter-server copy feature, a
> PUTFH followed by a SAVEFH MUST NOT return NFS4ERR_STALE for either
> operation.  These restrictions do not pose substantial difficulties for
> servers.  CURRENT_FH and SAVED_FH may be validated in the context of the
> operation referencing them and an NFS4ERR_STALE error returned for an
> invalid filehandle at that point."
>
> So we're supposed to return NFS4ERR_STALE on the COPY, not the PUTFH.
> So there's no need for this backtracking.

You are right.

  reply	other threads:[~2017-09-15 19:46 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 16:43 [PATCH v3 00/42] NFS/NFSD support for async and inter COPY Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 01/42] fs: Don't copy beyond the end of the file Olga Kornievskaia
2017-07-11 18:39   ` Anna Schumaker
2017-07-11 16:43 ` [RFC v3 02/42] VFS permit cross device vfs_copy_file_range Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 03/42] NFS CB_OFFLOAD xdr Olga Kornievskaia
2017-07-11 20:27   ` Anna Schumaker
2017-07-11 16:43 ` [RFC v3 04/42] NFS OFFLOAD_STATUS xdr Olga Kornievskaia
2017-07-11 21:01   ` Anna Schumaker
2017-07-12 17:23     ` Olga Kornievskaia
2017-07-12 17:25       ` Anna Schumaker
2017-07-11 16:43 ` [RFC v3 05/42] NFS OFFLOAD_STATUS op Olga Kornievskaia
2017-07-12 12:41   ` Anna Schumaker
2017-07-11 16:43 ` [RFC v3 06/42] NFS OFFLOAD_CANCEL xdr Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 07/42] NFS COPY xdr handle async reply Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 08/42] NFS add support for asynchronous COPY Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 09/42] NFS handle COPY reply CB_OFFLOAD call race Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 10/42] NFS export nfs4_async_handle_error Olga Kornievskaia
2017-07-12 13:56   ` Anna Schumaker
2017-07-12 17:18     ` Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 11/42] NFS test for intra vs inter COPY Olga Kornievskaia
2017-07-12 14:06   ` Anna Schumaker
2017-07-12 17:21     ` Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 12/42] NFS send OFFLOAD_CANCEL when COPY killed Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 13/42] NFS handle COPY ERR_OFFLOAD_NO_REQS Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 14/42] NFS if we got partial copy ignore errors Olga Kornievskaia
2017-07-12 14:52   ` Anna Schumaker
2017-07-12 17:19     ` Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 15/42] NFS recover from destination server reboot for copies Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 16/42] NFS NFSD defining nl4_servers structure needed by both Olga Kornievskaia
2017-09-06 20:35   ` J. Bruce Fields
2017-09-08 20:51     ` Olga Kornievskaia
2017-09-11 16:22       ` J. Bruce Fields
2017-07-11 16:43 ` [RFC v3 17/42] NFS add COPY_NOTIFY operation Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 18/42] NFS add ca_source_server<> to COPY Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 19/42] NFS also send OFFLOAD_CANCEL to source server Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 20/42] NFS inter ssc open Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 21/42] NFS skip recovery of copy open on dest server Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 22/42] NFS for "inter" copy treat ESTALE as ENOTSUPP Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 23/42] NFS add a simple sync nfs4_proc_commit after async COPY Olga Kornievskaia
2017-07-12 17:13   ` Anna Schumaker
2017-07-12 17:18     ` Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 24/42] NFSD add ca_source_server<> to COPY Olga Kornievskaia
2017-07-11 16:43 ` [RFC v3 25/42] NFSD add COPY_NOTIFY operation Olga Kornievskaia
2017-09-06 20:45   ` J. Bruce Fields
2017-09-13 14:39     ` Olga Kornievskaia
2017-09-06 21:34   ` J. Bruce Fields
2017-09-13 14:38     ` Olga Kornievskaia
2017-09-06 21:37   ` J. Bruce Fields
2017-09-13 14:38     ` Olga Kornievskaia
2017-09-13 14:42       ` J. Bruce Fields
2017-07-11 16:44 ` [RFC v3 26/42] NFSD generalize nfsd4_compound_state flag names Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 27/42] NFSD: allow inter server COPY to have a STALE source server fh Olga Kornievskaia
2017-09-08 19:38   ` J. Bruce Fields
2017-09-08 19:52     ` Olga Kornievskaia
2017-09-08 19:57       ` J. Bruce Fields
2017-09-08 20:09         ` Olga Kornievskaia
2017-09-14 18:44     ` Olga Kornievskaia
2017-09-15  1:47       ` J. Bruce Fields
2017-09-15 19:46         ` Olga Kornievskaia [this message]
2017-09-15 20:02           ` J. Bruce Fields
2017-09-15 20:06             ` J. Bruce Fields
2017-09-15 20:11               ` Olga Kornievskaia
2017-09-16 14:44               ` J. Bruce Fields
2017-07-11 16:44 ` [RFC v3 28/42] NFSD add nfs4 inter ssc to nfsd4_copy Olga Kornievskaia
2017-09-08 20:28   ` J. Bruce Fields
2017-07-11 16:44 ` [RFC v3 29/42] NFSD return nfs4_stid in nfs4_preprocess_stateid_op Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 30/42] NFSD Unique stateid_t for inter server to server COPY authentication Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 31/42] NFSD CB_OFFLOAD xdr Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 32/42] NFSD OFFLOAD_STATUS xdr Olga Kornievskaia
2017-07-12 19:39   ` Anna Schumaker
2017-07-11 16:44 ` [RFC v3 33/42] NFSD OFFLOAD_CANCEL xdr Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 34/42] NFSD xdr callback stateid in async COPY reply Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 35/42] NFSD first draft of async copy Olga Kornievskaia
2017-07-12 20:29   ` Anna Schumaker
2017-07-11 16:44 ` [RFC v3 36/42] NFSD handle OFFLOAD_CANCEL op Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 37/42] NFSD stop queued async copies on client shutdown Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 38/42] NFSD create new stateid for async copy Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 39/42] NFSD define EBADF in nfserrno Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 40/42] NFSD support OFFLOAD_STATUS Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 41/42] NFSD remove copy stateid when vfs_copy_file_range completes Olga Kornievskaia
2017-07-11 16:44 ` [RFC v3 42/42] NFSD delay the umount after COPY 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='CAN-5tyHasLG79AQoduP=Bt=L9Tpwy4KVi39J+47nzH2jQnseUw@mail.gmail.com' \
    --to=aglo@umich.edu \
    --cc=Trond.Myklebust@primarydata.com \
    --cc=anna.schumaker@netapp.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.