]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: Check for extent overflow when trivally adding a new extent
authorChandan Babu R <chandanrlinux@gmail.com>
Mon, 5 Apr 2021 21:58:13 +0000 (17:58 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Mon, 5 Apr 2021 21:58:13 +0000 (17:58 -0400)
Source kernel commit: 727e1acd297cae15449607d6e2ee39c71216cf1a

When adding a new data extent (without modifying an inode's existing
extents) the extent count increases only by 1. This commit checks for
extent count overflow in such cases.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_bmap.c
libxfs/xfs_inode_fork.h

index 1e53cbdd083358ea246f0e9c00ee702bba5ab36f..336c6d6f1ad4d50fb350a57131db4f4b81d4c42f 100644 (file)
@@ -4520,6 +4520,12 @@ xfs_bmapi_convert_delalloc(
                return error;
 
        xfs_ilock(ip, XFS_ILOCK_EXCL);
+
+       error = xfs_iext_count_may_overflow(ip, whichfork,
+                       XFS_IEXT_ADD_NOSPLIT_CNT);
+       if (error)
+               goto out_trans_cancel;
+
        xfs_trans_ijoin(tp, ip, 0);
 
        if (!xfs_iext_lookup_extent(ip, ifp, offset_fsb, &bma.icur, &bma.got) ||
index 0beb8e2a00becf3abec2fecf898b2e5da1011693..7fc2b129a2e79ff998acc4c0ced441cf8d18e205 100644 (file)
@@ -34,6 +34,12 @@ struct xfs_ifork {
 #define        XFS_IFEXTENTS   0x02    /* All extent pointers are read in */
 #define        XFS_IFBROOT     0x04    /* i_broot points to the bmap b-tree root */
 
+/*
+ * Worst-case increase in the fork extent count when we're adding a single
+ * extent to a fork and there's no possibility of splitting an existing mapping.
+ */
+#define XFS_IEXT_ADD_NOSPLIT_CNT       (1)
+
 /*
  * Fork handling.
  */