From: "J. Bruce Fields" <bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
To: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: Jeff Layton <jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
xfs-VZNHf3L845pBDgjK7y7TUQ@public.gmane.org
Subject: Re: [PATCH 03/20] fs: add FL_LAYOUT lease type
Date: Thu, 22 Jan 2015 15:14:42 -0500 [thread overview]
Message-ID: <20150122201442.GJ898@fieldses.org> (raw)
In-Reply-To: <1421925006-24231-4-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
On Thu, Jan 22, 2015 at 12:09:49PM +0100, Christoph Hellwig wrote:
> This (ab-)uses the file locking code to allow filesystems to recall
> outstanding pNFS layouts on a file. This new lease type is similar but
> not quite the same as FL_DELEG. A FL_LAYOUT lease can always be granted,
> an a per-filesystem lock (XFS iolock for the initial implementation)
> ensures not FL_LAYOUT leases granted when we would need to recall them.
So when there's a conflicting operation it's xfs's responsibility to
call break_layout and wait for the recall?
(And what roughly is the set of conflicting operations?)
--b.
>
> Also included are changes that allow multiple outstanding read
> leases of different types on the same file as long as they have a
> differnt owner. This wasn't a problem until now as nfsd never set
> FL_LEASE leases, and no one else used FL_DELEG leases, but given that
> nfsd will also issues FL_LAYOUT leases we will have to handle it now.
>
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> ---
> fs/locks.c | 14 ++++++++++----
> include/linux/fs.h | 16 ++++++++++++++++
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 65350a23..6b9772d1 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -137,7 +137,7 @@
>
> #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX)
> #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK)
> -#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG))
> +#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT))
> #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK)
>
> static bool lease_breaking(struct file_lock *fl)
> @@ -1371,6 +1371,8 @@ static void time_out_leases(struct inode *inode, struct list_head *dispose)
>
> static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
> {
> + if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT))
> + return false;
> if ((breaker->fl_flags & FL_DELEG) && (lease->fl_flags & FL_LEASE))
> return false;
> return locks_conflict(breaker, lease);
> @@ -1594,11 +1596,14 @@ int fcntl_getlease(struct file *filp)
> * conflict with the lease we're trying to set.
> */
> static int
> -check_conflicting_open(const struct dentry *dentry, const long arg)
> +check_conflicting_open(const struct dentry *dentry, const long arg, int flags)
> {
> int ret = 0;
> struct inode *inode = dentry->d_inode;
>
> + if (flags & FL_LAYOUT)
> + return 0;
> +
> if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
> return -EAGAIN;
>
> @@ -1647,7 +1652,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
>
> spin_lock(&ctx->flc_lock);
> time_out_leases(inode, &dispose);
> - error = check_conflicting_open(dentry, arg);
> + error = check_conflicting_open(dentry, arg, lease->fl_flags);
> if (error)
> goto out;
>
> @@ -1703,7 +1708,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
> * precedes these checks.
> */
> smp_mb();
> - error = check_conflicting_open(dentry, arg);
> + error = check_conflicting_open(dentry, arg, lease->fl_flags);
> if (error) {
> locks_unlink_lock_ctx(lease, &ctx->flc_lease_cnt);
> goto out;
> @@ -1787,6 +1792,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
> WARN_ON_ONCE(1);
> return -ENOLCK;
> }
> +
> return generic_add_lease(filp, arg, flp, priv);
> default:
> return -EINVAL;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index f87cb2f..d5658f4 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -875,6 +875,7 @@ static inline struct file *get_file(struct file *f)
> #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */
> #define FL_UNLOCK_PENDING 512 /* Lease is being broken */
> #define FL_OFDLCK 1024 /* lock is "owned" by struct file */
> +#define FL_LAYOUT 2048 /* outstanding pNFS layout */
>
> /*
> * Special return value from posix_lock_file() and vfs_lock_file() for
> @@ -2036,6 +2037,16 @@ static inline int break_deleg_wait(struct inode **delegated_inode)
> return ret;
> }
>
> +static inline int break_layout(struct inode *inode, bool wait)
> +{
> + smp_mb();
> + if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
> + return __break_lease(inode,
> + wait ? O_WRONLY : O_WRONLY | O_NONBLOCK,
> + FL_LAYOUT);
> + return 0;
> +}
> +
> #else /* !CONFIG_FILE_LOCKING */
> static inline int locks_mandatory_locked(struct file *file)
> {
> @@ -2091,6 +2102,11 @@ static inline int break_deleg_wait(struct inode **delegated_inode)
> return 0;
> }
>
> +static inline int break_layout(struct inode *inode, bool wait)
> +{
> + return 0;
> +}
> +
> #endif /* CONFIG_FILE_LOCKING */
>
> /* fs/open.c */
> --
> 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-01-22 20:14 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-22 11:09 a simple and scalable pNFS block layout server V2 Christoph Hellwig
2015-01-22 11:09 ` [PATCH 04/20] nfsd: factor out a helper to decode nfstime4 values Christoph Hellwig
[not found] ` <1421925006-24231-5-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-01-22 20:15 ` J. Bruce Fields
2015-01-22 11:09 ` [PATCH 05/20] nfsd: move nfsd_fh_match to nfsfh.h Christoph Hellwig
2015-01-22 11:09 ` [PATCH 09/20] nfsd: make find_any_file available outside nfs4state.c Christoph Hellwig
[not found] ` <1421925006-24231-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-01-22 11:09 ` [PATCH 01/20] nfs: add LAYOUT_TYPE_MAX enum value Christoph Hellwig
2015-01-22 11:09 ` [PATCH 02/20] fs: track fl_owner for leases Christoph Hellwig
2015-01-22 11:09 ` [PATCH 03/20] fs: add FL_LAYOUT lease type Christoph Hellwig
2015-01-22 15:45 ` Jeff Layton
[not found] ` <1421925006-24231-4-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-01-22 20:14 ` J. Bruce Fields [this message]
[not found] ` <20150122201442.GJ898-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-01-22 20:18 ` Christoph Hellwig
2015-01-22 11:09 ` [PATCH 06/20] nfsd: add fh_fsid_match helper Christoph Hellwig
2015-01-22 11:09 ` [PATCH 07/20] nfsd: make lookup/alloc/unhash_stid available outside nfs4state.c Christoph Hellwig
2015-01-22 11:09 ` [PATCH 08/20] nfsd: make find/get/put file " Christoph Hellwig
2015-01-22 11:09 ` [PATCH 10/20] nfsd: implement pNFS operations Christoph Hellwig
[not found] ` <1421925006-24231-11-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-01-29 20:33 ` J. Bruce Fields
[not found] ` <20150129203346.GA11064-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-02-02 12:43 ` Christoph Hellwig
2015-02-02 14:28 ` J. Bruce Fields
[not found] ` <20150202142832.GC22301-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-02-02 14:56 ` Christoph Hellwig
[not found] ` <20150202145619.GA18387-jcswGhMUV9g@public.gmane.org>
2015-02-02 15:00 ` J. Bruce Fields
[not found] ` <20150202150032.GD22301-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-02-02 18:56 ` Christoph Hellwig
[not found] ` <20150202185638.GB23319-jcswGhMUV9g@public.gmane.org>
2015-02-03 16:08 ` J. Bruce Fields
2015-01-22 11:09 ` [PATCH 11/20] nfsd: implement pNFS layout recalls Christoph Hellwig
2015-01-22 11:10 ` [PATCH 14/20] exportfs: add methods for block layout exports Christoph Hellwig
2015-01-22 11:10 ` [PATCH 16/20] xfs: pass a 64-bit count argument to xfs_iomap_write_unwritten Christoph Hellwig
2015-01-29 20:52 ` J. Bruce Fields
2015-02-02 7:30 ` Christoph Hellwig
2015-02-02 19:24 ` Dave Chinner
2015-02-02 19:43 ` Dave Chinner
2015-02-02 19:48 ` J. Bruce Fields
2015-02-03 18:35 ` Christoph Hellwig
[not found] ` <20150203183533.GA16929-jcswGhMUV9g@public.gmane.org>
2015-02-11 22:35 ` J. Bruce Fields
2015-02-11 22:54 ` J. Bruce Fields
2015-02-04 7:57 ` Christoph Hellwig
[not found] ` <20150204075756.GA763-jcswGhMUV9g@public.gmane.org>
2015-02-04 20:02 ` Dave Chinner
2015-01-22 11:10 ` [PATCH 17/20] xfs: update the superblock using a synchronous transaction in growfs Christoph Hellwig
2015-01-22 11:10 ` [PATCH 19/20] xfs: implement pNFS export operations Christoph Hellwig
[not found] ` <1421925006-24231-20-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-02-05 0:47 ` Dave Chinner
2015-02-05 7:08 ` Christoph Hellwig
[not found] ` <20150205070858.GA593-jcswGhMUV9g@public.gmane.org>
2015-02-05 13:57 ` Christoph Hellwig
[not found] ` <20150205135756.GA6386-jcswGhMUV9g@public.gmane.org>
2015-02-06 22:20 ` Dave Chinner
2015-02-06 22:42 ` J. Bruce Fields
2015-02-08 13:34 ` Christoph Hellwig
[not found] ` <20150208133435.GA27081-jcswGhMUV9g@public.gmane.org>
2015-02-08 14:09 ` Jeff Layton
[not found] ` <20150208090942.51e99687-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2015-02-09 20:11 ` J. Bruce Fields
[not found] ` <20150209201154.GA27746-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-02-10 0:04 ` Dave Chinner
2015-02-13 1:11 ` J. Bruce Fields
2015-02-13 1:54 ` Dave Chinner
2015-02-13 2:38 ` Stephen Rothwell
2015-02-15 23:25 ` Dave Chinner
2015-01-22 11:10 ` [PATCH 20/20] xfs: recall pNFS layouts on conflicting access Christoph Hellwig
[not found] ` <1421925006-24231-21-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-02-05 0:51 ` Dave Chinner
2015-01-22 20:01 ` a simple and scalable pNFS block layout server V2 J. Bruce Fields
2015-01-22 20:06 ` J. Bruce Fields
2015-01-22 20:20 ` Christoph Hellwig
[not found] ` <20150122200618.GI898-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-01-22 20:20 ` Jeff Layton
2015-01-22 11:09 ` [PATCH 12/20] nfsd: update documentation for pNFS support Christoph Hellwig
2015-01-22 11:09 ` [PATCH 13/20] nfsd: add trace events Christoph Hellwig
2015-01-22 11:10 ` [PATCH 15/20] nfsd: pNFS block layout driver Christoph Hellwig
2015-01-22 11:10 ` [PATCH 18/20] xfs: factor out a xfs_update_prealloc_flags() helper Christoph Hellwig
[not found] ` <1421925006-24231-19-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-02-01 23:06 ` Dave Chinner
2015-01-22 16:04 ` a simple and scalable pNFS block layout server V2 Chuck Lever
2015-01-22 16:21 ` Christoph Hellwig
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=20150122201442.GJ898@fieldses.org \
--to=bfields-uc3wqj2krung9huczpvpmw@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=xfs-VZNHf3L845pBDgjK7y7TUQ@public.gmane.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).