* [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files
@ 2017-09-04 15:49 Darrick J. Wong
2017-09-04 16:17 ` Carlos Maiolino
2017-09-04 19:33 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Darrick J. Wong @ 2017-09-04 15:49 UTC (permalink / raw)
To: xfs; +Cc: Amir Goldstein, Christoph Hellwig
If we have speculative cow preallocations hanging around in the cow
fork, don't let a truncate operation clear the reflink flag because if
we do then there's a chance we'll forget to free those extents when we
destroy the incore inode.
Reported-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/xfs_inode.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 5599dda..4ec5b7f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1624,10 +1624,12 @@ xfs_itruncate_extents(
goto out;
/*
- * Clear the reflink flag if we truncated everything.
+ * Clear the reflink flag if there are no data fork blocks and
+ * there are no extents staged in the cow fork.
*/
- if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) {
- ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
+ if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {
+ if (ip->i_d.di_nblocks == 0)
+ ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
xfs_inode_clear_cowblocks_tag(ip);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files
2017-09-04 15:49 [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files Darrick J. Wong
@ 2017-09-04 16:17 ` Carlos Maiolino
2017-09-04 19:33 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2017-09-04 16:17 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs, Amir Goldstein, Christoph Hellwig
On Mon, Sep 04, 2017 at 08:49:44AM -0700, Darrick J. Wong wrote:
> If we have speculative cow preallocations hanging around in the cow
> fork, don't let a truncate operation clear the reflink flag because if
> we do then there's a chance we'll forget to free those extents when we
> destroy the incore inode.
>
> Reported-by: Amir Goldstein <amir73il@gmail.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Looks good,
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> fs/xfs/xfs_inode.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 5599dda..4ec5b7f 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1624,10 +1624,12 @@ xfs_itruncate_extents(
> goto out;
>
> /*
> - * Clear the reflink flag if we truncated everything.
> + * Clear the reflink flag if there are no data fork blocks and
> + * there are no extents staged in the cow fork.
> */
> - if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) {
> - ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> + if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {
> + if (ip->i_d.di_nblocks == 0)
> + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> xfs_inode_clear_cowblocks_tag(ip);
> }
>
> --
> 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
--
Carlos
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files
2017-09-04 15:49 [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files Darrick J. Wong
2017-09-04 16:17 ` Carlos Maiolino
@ 2017-09-04 19:33 ` Christoph Hellwig
2017-09-04 19:50 ` Darrick J. Wong
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2017-09-04 19:33 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs, Amir Goldstein, Christoph Hellwig
On Mon, Sep 04, 2017 at 08:49:44AM -0700, Darrick J. Wong wrote:
> If we have speculative cow preallocations hanging around in the cow
> fork, don't let a truncate operation clear the reflink flag because if
> we do then there's a chance we'll forget to free those extents when we
> destroy the incore inode.
>
> Reported-by: Amir Goldstein <amir73il@gmail.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/xfs_inode.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 5599dda..4ec5b7f 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1624,10 +1624,12 @@ xfs_itruncate_extents(
> goto out;
>
> /*
> - * Clear the reflink flag if we truncated everything.
> + * Clear the reflink flag if there are no data fork blocks and
> + * there are no extents staged in the cow fork.
> */
> - if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) {
> - ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> + if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {
> + if (ip->i_d.di_nblocks == 0)
> + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> xfs_inode_clear_cowblocks_tag(ip);
This part looks ok:
Reviewed-by: Christoph Hellwig <hch@lst.de>
But while looking at that I decided I'd want to take a look at
other places where we potentially clear XFS_DIFLAG2_REFLINK.
In xfs_ioctl_setattr_xflags it seems like it's not currently safe
for setting the RT flag vs having COW extents? I also think we'd
need the iolock for every change to the rt flag, so this probably
needs a bigger rework..
swapext also doesn't seem to flush out existing cow extents.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files
2017-09-04 19:33 ` Christoph Hellwig
@ 2017-09-04 19:50 ` Darrick J. Wong
0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2017-09-04 19:50 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs, Amir Goldstein
On Mon, Sep 04, 2017 at 12:33:52PM -0700, Christoph Hellwig wrote:
> On Mon, Sep 04, 2017 at 08:49:44AM -0700, Darrick J. Wong wrote:
> > If we have speculative cow preallocations hanging around in the cow
> > fork, don't let a truncate operation clear the reflink flag because if
> > we do then there's a chance we'll forget to free those extents when we
> > destroy the incore inode.
> >
> > Reported-by: Amir Goldstein <amir73il@gmail.com>
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > fs/xfs/xfs_inode.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 5599dda..4ec5b7f 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -1624,10 +1624,12 @@ xfs_itruncate_extents(
> > goto out;
> >
> > /*
> > - * Clear the reflink flag if we truncated everything.
> > + * Clear the reflink flag if there are no data fork blocks and
> > + * there are no extents staged in the cow fork.
> > */
> > - if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) {
> > - ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> > + if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {
> > + if (ip->i_d.di_nblocks == 0)
> > + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> > xfs_inode_clear_cowblocks_tag(ip);
>
> This part looks ok:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
> But while looking at that I decided I'd want to take a look at
> other places where we potentially clear XFS_DIFLAG2_REFLINK.
>
> In xfs_ioctl_setattr_xflags it seems like it's not currently safe
> for setting the RT flag vs having COW extents?
Yeah... if we set the rt flag (which for now implies clearing reflink)
we also have to kill everything in the cow fork.
> I also think we'd need the iolock for every change to the rt flag, so
> this probably needs a bigger rework..
<eep>
> swapext also doesn't seem to flush out existing cow extents.
Yes, it swaps the cow forks too... except that there's a bug where we
only swap them if the reflink flags mismatch on ip/tip, and don't swap
i_cnextents at all, ever. Ugggh.
--D
> --
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-04 19:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-04 15:49 [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files Darrick J. Wong
2017-09-04 16:17 ` Carlos Maiolino
2017-09-04 19:33 ` Christoph Hellwig
2017-09-04 19:50 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox