Message ID | 20180920144220.2181-2-hch@lst.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [1/5] xfs: cancel COW blocks before swapext | expand |
On Thu, Sep 20, 2018 at 04:42:16PM +0200, Christoph Hellwig wrote: > We need to make sure we have no outstanding COW blocks before we swap > extents, as there is nothing preventing us from having COW preallocations > on an inode that swapext is called on. That case can easily be > reproduced by the upcoming always_cow mode. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Seems reasonable to me, Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> --D > --- > fs/xfs/xfs_bmap_util.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c > index 414dbc31139c..e0e9cbc98ccd 100644 > --- a/fs/xfs/xfs_bmap_util.c > +++ b/fs/xfs/xfs_bmap_util.c > @@ -1515,6 +1515,12 @@ xfs_swap_extent_flush( > return error; > truncate_pagecache_range(VFS_I(ip), 0, -1); > > + if (xfs_inode_has_cow_data(ip)) { > + error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, true); > + if (error) > + return error; > + } > + > /* Verify O_DIRECT for ftmp */ > if (VFS_I(ip)->i_mapping->nrpages) > return -EINVAL; > -- > 2.18.0 >
On Thu, Sep 20, 2018 at 04:42:16PM +0200, Christoph Hellwig wrote: > We need to make sure we have no outstanding COW blocks before we swap > extents, as there is nothing preventing us from having COW preallocations > on an inode that swapext is called on. That case can easily be > reproduced by the upcoming always_cow mode. > Why? Is the current code to swap the cow forks not sufficient or problematic in some way? > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > fs/xfs/xfs_bmap_util.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c > index 414dbc31139c..e0e9cbc98ccd 100644 > --- a/fs/xfs/xfs_bmap_util.c > +++ b/fs/xfs/xfs_bmap_util.c > @@ -1515,6 +1515,12 @@ xfs_swap_extent_flush( > return error; > truncate_pagecache_range(VFS_I(ip), 0, -1); > > + if (xfs_inode_has_cow_data(ip)) { > + error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, true); > + if (error) > + return error; > + } > + The change seems fine, but doesn't this make the follow on code to swap the cow blocks tags spurious..? Brian > /* Verify O_DIRECT for ftmp */ > if (VFS_I(ip)->i_mapping->nrpages) > return -EINVAL; > -- > 2.18.0 >
On Thu, Sep 27, 2018 at 11:07:31AM -0400, Brian Foster wrote: > On Thu, Sep 20, 2018 at 04:42:16PM +0200, Christoph Hellwig wrote: > > We need to make sure we have no outstanding COW blocks before we swap > > extents, as there is nothing preventing us from having COW preallocations > > on an inode that swapext is called on. That case can easily be > > reproduced by the upcoming always_cow mode. > > > > Why? Is the current code to swap the cow forks not sufficient or > problematic in some way? The code didn't seem happy with non-delalloc COW fork extents sticking around over swapext, but I'd have to go back and look up why. It seemed easiest to just cancel them as there is no reason to keep these alive over a swapext.
On Mon, Oct 01, 2018 at 12:50:30AM +0200, Christoph Hellwig wrote: > On Thu, Sep 27, 2018 at 11:07:31AM -0400, Brian Foster wrote: > > On Thu, Sep 20, 2018 at 04:42:16PM +0200, Christoph Hellwig wrote: > > > We need to make sure we have no outstanding COW blocks before we swap > > > extents, as there is nothing preventing us from having COW preallocations > > > on an inode that swapext is called on. That case can easily be > > > reproduced by the upcoming always_cow mode. > > > > > > > Why? Is the current code to swap the cow forks not sufficient or > > problematic in some way? > > The code didn't seem happy with non-delalloc COW fork extents sticking > around over swapext, but I'd have to go back and look up why. > It would be nice to have at least a high level note in the commit log for historical purposes, so we have a reference on what needs fixing if we revisit it in the future. > It seemed easiest to just cancel them as there is no reason to keep > these alive over a swapext. Seems reasonable to me. I'd just perhaps replace the cowblocks flag swap code with asserts or something to be consistent, because it seems that should never be set on either inode with this change in place. Brian
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 414dbc31139c..e0e9cbc98ccd 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1515,6 +1515,12 @@ xfs_swap_extent_flush( return error; truncate_pagecache_range(VFS_I(ip), 0, -1); + if (xfs_inode_has_cow_data(ip)) { + error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, true); + if (error) + return error; + } + /* Verify O_DIRECT for ftmp */ if (VFS_I(ip)->i_mapping->nrpages) return -EINVAL;
We need to make sure we have no outstanding COW blocks before we swap extents, as there is nothing preventing us from having COW preallocations on an inode that swapext is called on. That case can easily be reproduced by the upcoming always_cow mode. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/xfs/xfs_bmap_util.c | 6 ++++++ 1 file changed, 6 insertions(+)