]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xfs: error out if trying to add attrs and anextents > 0
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 5 Dec 2016 01:38:11 +0000 (12:38 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 5 Dec 2016 01:38:11 +0000 (12:38 +1100)
We shouldn't assert if somehow we end up trying to add an attr fork to
an inode that apparently already has attr extents because this is an
indication of on-disk corruption.  Instead, return an error code to
userspace.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/libxfs/xfs_bmap.c

index 829ad632533b80eac845008972f4a2d24a15bf3a..29ffc0569ce19eb8fbb602bdc27e75e1b22a779c 100644 (file)
@@ -1153,6 +1153,10 @@ xfs_bmap_add_attrfork(
                goto trans_cancel;
        if (XFS_IFORK_Q(ip))
                goto trans_cancel;
+       if (ip->i_d.di_anextents != 0) {
+               error = -EFSCORRUPTED;
+               goto trans_cancel;
+       }
        if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS) {
                /*
                 * For inodes coming from pre-6.2 filesystems.
@@ -1160,7 +1164,6 @@ xfs_bmap_add_attrfork(
                ASSERT(ip->i_d.di_aformat == 0);
                ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
        }
-       ASSERT(ip->i_d.di_anextents == 0);
 
        xfs_trans_ijoin(tp, ip, 0);
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);