From: Dave Chinner <david@fromorbit.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: darrick.wong@oracle.com, Jan Kara <jack@suse.cz>,
linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org,
linux-xfs@vger.kernel.org, Jeff Moyer <jmoyer@redhat.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
luto@kernel.org, linux-fsdevel@vger.kernel.org,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 3/3] xfs: persist S_IOMAP_IMMUTABLE in di_flags2
Date: Tue, 1 Aug 2017 10:42:01 +1000 [thread overview]
Message-ID: <20170801004201.GM17762@dastard> (raw)
In-Reply-To: <150135742595.35318.6882401569584241548.stgit@dwillia2-desk3.amr.corp.intel.com>
On Sat, Jul 29, 2017 at 12:43:46PM -0700, Dan Williams wrote:
> Record the immutable state in the on-disk inode so that on the next boot
> the protections against reflink and hole punch etc are automatically
> restored.
Keep in mind we can't do this without all the userspace side support
for the addition to the in-disk format....
> This deliberately does not add a FS_XFLAG_IOMAP_IMMUTABLE since
> fallocate(2) is the path to toggle this flag.
That's a problem. The flag needs to be added so that we can /view/
the state of the inode through xfs_io. Just because we can't set it
through the extended inode flag interface doesn't mean the flag
should not exist.
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index c4fc79a0704f..1dcb521da456 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1021,7 +1021,8 @@ xfs_alloc_file_space(
> struct xfs_inode *ip,
> xfs_off_t offset,
> xfs_off_t len,
> - int alloc_type)
> + int alloc_type,
> + uint64_t di_flags2)
> {
> xfs_mount_t *mp = ip->i_mount;
> xfs_off_t count;
> @@ -1119,6 +1120,12 @@ xfs_alloc_file_space(
> break;
> }
> xfs_ilock(ip, XFS_ILOCK_EXCL);
> + if (di_flags2) {
> + /* fold inode attributes for this allocation */
> + ip->i_d.di_flags2 |= di_flags2;
> + di_flags2 = 0;
> + }
Yikes, no! Darrick already mentioned this, but it needs pointing out
again...
Especially as it means that we are setting the immutable flag before
we've allocated all the extents to fill the file space. If we've
implemented immutable extent maps correctly, then xfs_bmapi_write()
should be rejecting any attempt to allocate or modify extents if
that flag is set on the inode, which means this code will now fail
to allocate/zero anything...
IOWs, this flag should be the last thing that is set on the inode
once it's been fully allocated and zeroed.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
prev parent reply other threads:[~2017-08-01 0:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-29 19:43 [PATCH 0/3] fs, xfs: block map immutable files for dax, dma-to-storage, and swap Dan Williams
2017-07-29 19:43 ` [PATCH 1/3] fs, xfs: introduce S_IOMAP_IMMUTABLE Dan Williams
2017-07-31 16:02 ` Colin Walters
2017-07-31 16:29 ` Dan Williams
2017-07-31 16:32 ` Colin Walters
2017-07-31 17:42 ` Colin Walters
2017-07-31 18:23 ` Darrick J. Wong
2017-08-01 2:15 ` Colin Walters
2017-08-01 2:42 ` Dave Chinner
2017-08-05 9:45 ` Christoph Hellwig
2017-07-31 16:46 ` Darrick J. Wong
2017-07-31 17:32 ` Dan Williams
2017-07-29 19:43 ` [PATCH 2/3] fs, xfs: introduce FALLOC_FL_SEAL_BLOCK_MAP Dan Williams
2017-07-31 17:09 ` Darrick J. Wong
2017-07-31 18:25 ` Dan Williams
2017-08-01 0:30 ` Dave Chinner
2017-07-29 19:43 ` [PATCH 3/3] xfs: persist S_IOMAP_IMMUTABLE in di_flags2 Dan Williams
2017-07-31 17:15 ` Darrick J. Wong
2017-08-01 0:42 ` Dave Chinner [this message]
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=20170801004201.GM17762@dastard \
--to=david@fromorbit.com \
--cc=dan.j.williams@intel.com \
--cc=darrick.wong@oracle.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-xfs@vger.kernel.org \
--cc=luto@kernel.org \
--cc=ross.zwisler@linux.intel.com \
--cc=viro@zeniv.linux.org.uk \
/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).