Commit 97a1b87e authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Dave Chinner

xfs: remove isize check from unshare operation

Now that fallocate has an explicit unshare flag again, let's try
to remove the inode reflink flag whenever the user unshares any
part of a file since checking is cheap compared to the CoW.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reported-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 024adf48
...@@ -1570,8 +1570,7 @@ xfs_reflink_clear_inode_flag( ...@@ -1570,8 +1570,7 @@ xfs_reflink_clear_inode_flag(
*/ */
STATIC int STATIC int
xfs_reflink_try_clear_inode_flag( xfs_reflink_try_clear_inode_flag(
struct xfs_inode *ip, struct xfs_inode *ip)
xfs_off_t old_isize)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
...@@ -1585,9 +1584,6 @@ xfs_reflink_try_clear_inode_flag( ...@@ -1585,9 +1584,6 @@ xfs_reflink_try_clear_inode_flag(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
if (old_isize != i_size_read(VFS_I(ip)))
goto cancel;
error = xfs_reflink_clear_inode_flag(ip, &tp); error = xfs_reflink_clear_inode_flag(ip, &tp);
if (error) if (error)
goto cancel; goto cancel;
...@@ -1630,7 +1626,7 @@ xfs_reflink_unshare( ...@@ -1630,7 +1626,7 @@ xfs_reflink_unshare(
/* Try to CoW the selected ranges */ /* Try to CoW the selected ranges */
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
fbno = XFS_B_TO_FSB(mp, offset); fbno = XFS_B_TO_FSBT(mp, offset);
isize = i_size_read(VFS_I(ip)); isize = i_size_read(VFS_I(ip));
end = XFS_B_TO_FSB(mp, offset + len); end = XFS_B_TO_FSB(mp, offset + len);
error = xfs_reflink_dirty_extents(ip, fbno, end, isize); error = xfs_reflink_dirty_extents(ip, fbno, end, isize);
...@@ -1643,12 +1639,10 @@ xfs_reflink_unshare( ...@@ -1643,12 +1639,10 @@ xfs_reflink_unshare(
if (error) if (error)
goto out; goto out;
/* Turn off the reflink flag if we unshared the whole file */ /* Turn off the reflink flag if possible. */
if (offset == 0 && len == isize) { error = xfs_reflink_try_clear_inode_flag(ip);
error = xfs_reflink_try_clear_inode_flag(ip, isize);
if (error) if (error)
goto out; goto out;
}
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment