From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: jack@suse.cz, linux-nvdimm@lists.01.org,
Dave Chinner <david@fromorbit.com>,
linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v6 12/15] xfs: require mmap lock for xfs_break_layouts()
Date: Mon, 19 Mar 2018 10:33:45 -0700 [thread overview]
Message-ID: <20180319173345.GF1757@magnolia> (raw)
In-Reply-To: <152112914933.24669.5543317105428477772.stgit@dwillia2-desk3.amr.corp.intel.com>
On Thu, Mar 15, 2018 at 08:52:29AM -0700, Dan Williams wrote:
> In preparation for adding coordination between truncate operations and
> busy dax-pages, extend xfs_break_layouts() to assume it must be called
> with the mmap lock held. This locking scheme will be required for
> coordinating the break of 'dax layouts' (non-idle dax (ZONE_DEVICE)
> pages mapped into the file's address space).
If I'm reading this right, you've added a requirement (for xfs anyway)
that we have to have grabbed MMAPLOCK_EXCL before calling break_layout()
so that the layout breaking process will block until active dmas have
finished.
In 4.16 we added xfs_iolock_two_inodes_and_break_layout (in
xfs_reflink.c) to break pnfs leases for files that are about to be
reflinked (since pnfs and reflink aren't compatible either). I think
that function will have to be adapted to take the appropriate mmap locks
too -- definitely the exclusive mmap lock for the destination file
because we anticipate punching out blocks. I'm not sure about the
source file; I think taking the shared mmap lock is fine for that?
--D
>
> Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> Cc: Dave Chinner <david@fromorbit.com>
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> fs/xfs/xfs_file.c | 14 +++++++++-----
> fs/xfs/xfs_ioctl.c | 5 +----
> fs/xfs/xfs_iops.c | 10 +++++++---
> fs/xfs/xfs_pnfs.c | 6 ++++--
> 4 files changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 9ea08326f876..ba969019bf26 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -350,9 +350,16 @@ xfs_file_aio_write_checks(
> if (error <= 0)
> return error;
>
> + xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
> + *iolock |= XFS_MMAPLOCK_EXCL;
> error = xfs_break_layouts(inode, iolock);
> - if (error)
> + if (error) {
> + *iolock &= ~XFS_MMAPLOCK_EXCL;
> + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
> return error;
> + }
> + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
> + *iolock &= ~XFS_MMAPLOCK_EXCL;
>
> /*
> * For changing security info in file_remove_privs() we need i_rwsem
> @@ -768,7 +775,7 @@ xfs_file_fallocate(
> struct xfs_inode *ip = XFS_I(inode);
> long error;
> enum xfs_prealloc_flags flags = 0;
> - uint iolock = XFS_IOLOCK_EXCL;
> + uint iolock = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
> loff_t new_size = 0;
> bool do_file_insert = false;
>
> @@ -782,9 +789,6 @@ xfs_file_fallocate(
> if (error)
> goto out_unlock;
>
> - xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
> - iolock |= XFS_MMAPLOCK_EXCL;
> -
> if (mode & FALLOC_FL_PUNCH_HOLE) {
> error = xfs_free_file_space(ip, offset, len);
> if (error)
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 89fb1eb80aae..4151fade4bb1 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -614,7 +614,7 @@ xfs_ioc_space(
> struct xfs_inode *ip = XFS_I(inode);
> struct iattr iattr;
> enum xfs_prealloc_flags flags = 0;
> - uint iolock = XFS_IOLOCK_EXCL;
> + uint iolock = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
> int error;
>
> /*
> @@ -648,9 +648,6 @@ xfs_ioc_space(
> if (error)
> goto out_unlock;
>
> - xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
> - iolock |= XFS_MMAPLOCK_EXCL;
> -
> switch (bf->l_whence) {
> case 0: /*SEEK_SET*/
> break;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 951e84df5576..d23aa08426f9 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -1028,13 +1028,17 @@ xfs_vn_setattr(
>
> if (iattr->ia_valid & ATTR_SIZE) {
> struct xfs_inode *ip = XFS_I(d_inode(dentry));
> - uint iolock = XFS_IOLOCK_EXCL;
> + uint iolock;
> +
> + xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
> + iolock = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
>
> error = xfs_break_layouts(d_inode(dentry), &iolock);
> - if (error)
> + if (error) {
> + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
> return error;
> + }
>
> - xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
> error = xfs_vn_setattr_size(dentry, iattr);
> xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
> } else {
> diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
> index aa6c5c193f45..9fe661c2d59c 100644
> --- a/fs/xfs/xfs_pnfs.c
> +++ b/fs/xfs/xfs_pnfs.c
> @@ -38,12 +38,14 @@ xfs_break_layouts(
> struct xfs_inode *ip = XFS_I(inode);
> int error;
>
> - ASSERT(xfs_isilocked(ip, XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL));
> + ASSERT(xfs_isilocked(ip, XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL
> + | XFS_MMAPLOCK_EXCL));
>
> while ((error = break_layout(inode, false) == -EWOULDBLOCK)) {
> xfs_iunlock(ip, *iolock);
> error = break_layout(inode, true);
> - *iolock = XFS_IOLOCK_EXCL;
> + *iolock &= ~XFS_IOLOCK_SHARED;
> + *iolock |= XFS_IOLOCK_EXCL;
> xfs_ilock(ip, *iolock);
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2018-03-19 17:27 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 15:51 [PATCH v6 00/15] dax: fix dma vs truncate/hole-punch Dan Williams
2018-03-15 15:51 ` [PATCH v6 01/15] dax: store pfns in the radix Dan Williams
2018-03-15 15:51 ` [PATCH v6 02/15] fs, dax: prepare for dax-specific address_space_operations Dan Williams
2018-03-16 18:59 ` Christoph Hellwig
2018-03-15 15:51 ` [PATCH v6 03/15] block, dax: remove dead code in blkdev_writepages() Dan Williams
2018-03-16 18:59 ` Christoph Hellwig
2018-03-15 15:51 ` [PATCH v6 04/15] xfs, dax: introduce xfs_dax_aops Dan Williams
2018-03-16 19:00 ` Christoph Hellwig
2018-03-15 15:51 ` [PATCH v6 05/15] ext4, dax: introduce ext4_dax_aops Dan Williams
2018-03-15 15:51 ` [PATCH v6 06/15] ext2, dax: introduce ext2_dax_aops Dan Williams
2018-03-18 4:02 ` kbuild test robot
2018-03-18 4:02 ` [RFC PATCH] ext2, dax: ext2_dax_aops can be static kbuild test robot
2018-03-15 15:52 ` [PATCH v6 07/15] fs, dax: use page->mapping to warn if truncate collides with a busy page Dan Williams
2018-03-18 6:26 ` kbuild test robot
2018-03-15 15:52 ` [PATCH v6 08/15] mm, dax: enable filesystems to trigger dev_pagemap ->page_free callbacks Dan Williams
2018-03-15 15:52 ` [PATCH v6 09/15] mm, dev_pagemap: introduce CONFIG_DEV_PAGEMAP_OPS Dan Williams
2018-03-15 15:52 ` [PATCH v6 10/15] memremap: mark devm_memremap_pages() EXPORT_SYMBOL_GPL Dan Williams
2018-03-15 15:52 ` [PATCH v6 11/15] mm, fs, dax: handle layout changes to pinned dax mappings Dan Williams
2018-03-16 19:01 ` Christoph Hellwig
2018-03-17 22:14 ` kbuild test robot
2018-03-15 15:52 ` [PATCH v6 12/15] xfs: require mmap lock for xfs_break_layouts() Dan Williams
2018-03-16 19:04 ` Christoph Hellwig
2018-03-16 19:10 ` Dan Williams
2018-03-19 17:33 ` Darrick J. Wong [this message]
2018-03-19 17:57 ` Dan Williams
2018-03-19 18:19 ` Darrick J. Wong
2018-03-19 18:34 ` Dan Williams
2018-03-19 19:45 ` Christoph Hellwig
2018-03-19 20:10 ` Dan Williams
2018-03-19 21:14 ` Christoph Hellwig
2018-03-15 15:52 ` [PATCH v6 13/15] xfs: communicate lock drop events from xfs_break_layouts() Dan Williams
2018-03-16 19:08 ` Christoph Hellwig
2018-03-15 15:52 ` [PATCH v6 14/15] xfs: prepare xfs_break_layouts() for another layout type Dan Williams
2018-03-16 19:08 ` Christoph Hellwig
2018-03-19 17:45 ` Darrick J. Wong
2018-03-19 18:09 ` Dan Williams
2018-03-15 15:52 ` [PATCH v6 15/15] xfs, dax: introduce xfs_break_dax_layouts() Dan Williams
2018-03-16 19:09 ` Christoph Hellwig
2018-03-17 22:11 ` kbuild test robot
2018-03-17 23:47 ` kbuild test robot
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=20180319173345.GF1757@magnolia \
--to=darrick.wong@oracle.com \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-xfs@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).