xfs: introduce a new xfs_inode_has_cow_data helper
We have a few places that already check if an inode has actual data in the COW fork to avoid work on reflink inodes that do not actually have outstanding COW blocks. There are a few more places that can avoid working if doing the same check, so add a documented helper for this condition and use it in all places where it makes sense. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:

committed by
Darrick J. Wong

parent
3ba738df25
commit
51d6269030
@@ -1697,14 +1697,13 @@ xfs_inode_clear_eofblocks_tag(
|
||||
*/
|
||||
static bool
|
||||
xfs_prep_free_cowblocks(
|
||||
struct xfs_inode *ip,
|
||||
struct xfs_ifork *ifp)
|
||||
struct xfs_inode *ip)
|
||||
{
|
||||
/*
|
||||
* Just clear the tag if we have an empty cow fork or none at all. It's
|
||||
* possible the inode was fully unshared since it was originally tagged.
|
||||
*/
|
||||
if (!xfs_is_reflink_inode(ip) || !ifp->if_bytes) {
|
||||
if (!xfs_inode_has_cow_data(ip)) {
|
||||
trace_xfs_inode_free_cowblocks_invalid(ip);
|
||||
xfs_inode_clear_cowblocks_tag(ip);
|
||||
return false;
|
||||
@@ -1742,11 +1741,10 @@ xfs_inode_free_cowblocks(
|
||||
void *args)
|
||||
{
|
||||
struct xfs_eofblocks *eofb = args;
|
||||
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
|
||||
int match;
|
||||
int ret = 0;
|
||||
|
||||
if (!xfs_prep_free_cowblocks(ip, ifp))
|
||||
if (!xfs_prep_free_cowblocks(ip))
|
||||
return 0;
|
||||
|
||||
if (eofb) {
|
||||
@@ -1771,7 +1769,7 @@ xfs_inode_free_cowblocks(
|
||||
* Check again, nobody else should be able to dirty blocks or change
|
||||
* the reflink iflag now that we have the first two locks held.
|
||||
*/
|
||||
if (xfs_prep_free_cowblocks(ip, ifp))
|
||||
if (xfs_prep_free_cowblocks(ip))
|
||||
ret = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, false);
|
||||
|
||||
xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
|
||||
|
Reference in New Issue
Block a user