aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2016-10-10 01:47:32 -0400
committerDave Chinner <david@fromorbit.com>2016-10-10 01:47:32 -0400
commit63646fc58d666f149b85ccf470bfc1576a779d4c (patch)
treedc640908f7a21bf0f81f0b3e51a05d5f583e9ec1
parent1f08af52e7c981e9877796a2d90b0e0f08666945 (diff)
xfs: check inode reflink flag before calling reflink functions
There are a couple of places where we don't check the inode's reflink flag before calling into the reflink code. Fix those, and add some asserts so we don't make this mistake again. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reported-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_reflink.c4
-rw-r--r--fs/xfs/xfs_super.c12
2 files changed, 9 insertions, 7 deletions
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 685c419ae011..9c58b4a83248 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -624,6 +624,7 @@ xfs_reflink_cancel_cow_range(
624 int error; 624 int error;
625 625
626 trace_xfs_reflink_cancel_cow_range(ip, offset, count); 626 trace_xfs_reflink_cancel_cow_range(ip, offset, count);
627 ASSERT(xfs_is_reflink_inode(ip));
627 628
628 offset_fsb = XFS_B_TO_FSBT(ip->i_mount, offset); 629 offset_fsb = XFS_B_TO_FSBT(ip->i_mount, offset);
629 if (count == NULLFILEOFF) 630 if (count == NULLFILEOFF)
@@ -1510,8 +1511,7 @@ xfs_reflink_clear_inode_flag(
1510 int nmaps; 1511 int nmaps;
1511 int error = 0; 1512 int error = 0;
1512 1513
1513 if (!(ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)) 1514 ASSERT(xfs_is_reflink_inode(ip));
1514 return 0;
1515 1515
1516 fbno = 0; 1516 fbno = 0;
1517 end = XFS_B_TO_FSB(mp, i_size_read(VFS_I(ip))); 1517 end = XFS_B_TO_FSB(mp, i_size_read(VFS_I(ip)));
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 72bde2811bd7..ade4691e3f74 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -947,11 +947,13 @@ xfs_fs_destroy_inode(
947 XFS_STATS_INC(ip->i_mount, vn_rele); 947 XFS_STATS_INC(ip->i_mount, vn_rele);
948 XFS_STATS_INC(ip->i_mount, vn_remove); 948 XFS_STATS_INC(ip->i_mount, vn_remove);
949 949
950 error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF); 950 if (xfs_is_reflink_inode(ip)) {
951 if (error && !XFS_FORCED_SHUTDOWN(ip->i_mount)) 951 error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF);
952 xfs_warn(ip->i_mount, "Error %d while evicting CoW blocks " 952 if (error && !XFS_FORCED_SHUTDOWN(ip->i_mount))
953 "for inode %llu.", 953 xfs_warn(ip->i_mount,
954 error, ip->i_ino); 954"Error %d while evicting CoW blocks for inode %llu.",
955 error, ip->i_ino);
956 }
955 957
956 xfs_inactive(ip); 958 xfs_inactive(ip);
957 959