From: Jeff Layton <jlayton@redhat.com>
To: "J. Bruce Fields" <bfields@redhat.com>
Cc: NeilBrown <neilb@suse.com>,
linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Trond Myklebust <trond.myklebust@primarydata.com>
Subject: Re: [PATCH 1/3] fs: cleanup to hide some details of delegation logic
Date: Thu, 31 Aug 2017 19:13:05 -0400 [thread overview]
Message-ID: <1504221185.4682.8.camel@redhat.com> (raw)
In-Reply-To: <20170831211002.GG8223@parsley.fieldses.org>
On Thu, 2017-08-31 at 17:10 -0400, J. Bruce Fields wrote:
> On Wed, Aug 30, 2017 at 03:50:59PM -0400, Jeff Layton wrote:
> > ACK, I like that better too. I think a kerneldoc header is probably
> > warranted here too, since this is a bit of an odd return situation.
>
> Am I overdoing it?:
>
> --b.
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 6421feeda4bd..2261728cc900 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2285,6 +2285,25 @@ static inline int break_deleg(struct inode *inode, void *who, unsigned int mode)
>
> #define DELEG_NO_WAIT ((struct inode *)1)
>
> +/**
> + * try_break_deleg - initiate a delegation break
> + * @inode: inode to break the delegation on
> + * @deleg_break_ctl: delegation state; see below
> + *
> + * VFS operations that are incompatible with a delegation call this to
> + * break any delegations on the inode first. The caller must first lock
> + * the inode to prevent races with processes granting new delegations.
> + *
> + * Delegations may be slow to recall, so we initiate the recall but do
> + * not wait for it here while holding locks. The caller should instead
> + * drop locks and call break_deleg_wait() which will wait for a recall,
> + * if there is one. The inode to wait on will be stored in
> + * deleg_break_ctl, which also tracks who is breaking the delegation in
> + * the NFS case. The caller can then retry the operation (possibly on a
> + * different inode, since a new lookup may have been required after
> + * reacquiring locks.)
> + */
> +
> static inline int try_break_deleg(struct inode *inode, struct deleg_break_ctl *deleg_break_ctl)
> {
> int ret;
> @@ -2299,6 +2318,22 @@ static inline int try_break_deleg(struct inode *inode, struct deleg_break_ctl *d
> return ret;
> }
>
> +/**
> + * break_deleg_wait - wait on a delegation recall if necessary
> + * @deleg_break_ctl: delegation state
> + * @error: error to use if there is no delegation to wait on
> + *
> + * This should be called with the deleg_break_ctl previously passed to
> + * try_break_deleg().
> + *
> + * If the previous try_break_deleg() found no delegation in need of
> + * breaking, this is a no-op that just returns the given error.
> + *
> + * Otherwise it will wait for the delegation recall. If the wait is
> + * succesful, it will return a positive value to indicate to the caller
> + * that it should retry the operation that originally prompted the
> + * break.
> + */
> static inline int break_deleg_wait(struct deleg_break_ctl *deleg_break_ctl, int error)
> {
> if (!deleg_break_ctl->delegated_inode)
No, I like it. This is tricky code, and having the rationale and
detailed behavior spelled out in detail is a good thing.
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2017-08-31 23:13 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-25 21:52 [PATCH 0/3] Eliminate delegation self-conflicts J. Bruce Fields
2017-08-25 21:52 ` [PATCH 1/3] fs: cleanup to hide some details of delegation logic J. Bruce Fields
2017-08-28 3:54 ` NeilBrown
2017-08-29 21:37 ` J. Bruce Fields
2017-08-30 19:50 ` Jeff Layton
2017-08-31 21:10 ` J. Bruce Fields
2017-08-31 23:13 ` Jeff Layton [this message]
2017-08-25 21:52 ` [PATCH 2/3] fs: hide another detail " J. Bruce Fields
2017-08-28 4:43 ` NeilBrown
2017-08-29 21:40 ` J. Bruce Fields
2017-08-30 0:43 ` NeilBrown
2017-08-30 17:09 ` J. Bruce Fields
2017-08-30 23:26 ` NeilBrown
2017-08-31 19:05 ` J. Bruce Fields
2017-08-31 23:27 ` NeilBrown
2017-09-01 16:18 ` J. Bruce Fields
2017-09-04 4:52 ` NeilBrown
2017-09-05 19:56 ` J. Bruce Fields
2017-09-05 21:35 ` NeilBrown
2017-09-06 16:03 ` J. Bruce Fields
2017-09-07 0:43 ` NeilBrown
2017-09-08 15:06 ` J. Bruce Fields
2018-03-16 14:42 ` J. Bruce Fields
2017-08-25 21:52 ` [PATCH 3/3] nfsd: clients don't need to break their own delegations J. Bruce Fields
2017-08-28 4:32 ` NeilBrown
2017-08-29 21:49 ` J. Bruce Fields
2018-03-16 14:43 ` J. Bruce Fields
2017-09-07 22:01 ` J. Bruce Fields
2017-09-07 22:01 ` J. Bruce Fields
2017-09-08 5:06 ` NeilBrown
2017-09-08 15:05 ` J. Bruce Fields
2017-09-08 15:05 ` J. Bruce Fields
2017-08-26 18:06 ` [PATCH 0/3] Eliminate delegation self-conflicts Chuck Lever
2017-08-29 21:52 ` J. Bruce Fields
2017-08-29 23:39 ` Chuck Lever
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=1504221185.4682.8.camel@redhat.com \
--to=jlayton@redhat.com \
--cc=bfields@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.com \
--cc=trond.myklebust@primarydata.com \
/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.