xfs
[Top] [All Lists]

[PATCH] xfs: prevent xfs_bmap_extsize_align() to exceed maximum extent s

To: xfs@xxxxxxxxxxx
Subject: [PATCH] xfs: prevent xfs_bmap_extsize_align() to exceed maximum extent size.
From: Alain Renaud <arenaud@xxxxxxx>
Date: Fri, 13 Jul 2012 12:09:28 +0200
In-reply-to: <20120712154554.377970666@xxxxxxx>
References: <20120712154554.377970666@xxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1
xfs: prevent xfs_bmap_extsize_align() to exceed maximum extent size.

When trying to do preallocation that exceed the the maximum size of
an extent, the extsize alignment can exceed this value.
We are already trying to solve this issue for delay allocation but we
have the same with prealloc. So I think the simple solution is to limit
the size in xfs_bmap_extsize_align() and remove the code specific to
delay allocation.

We do have a simple test case to confirm that the problem exist.

# cd /xfs_dir/
# xfs_io -c 'extsize 4m' .
# xfs_io -f -c 'resvsp 0 8g' test_file
XFS_IOC_RESVSP64: No space left on device

Signed-off-by: Alain Renaud <arenaud@xxxxxxx>

---
 fs/xfs/xfs_bmap.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Index: b/fs/xfs/xfs_bmap.c
===================================================================
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -1912,6 +1912,11 @@ xfs_bmap_extsize_align(
                align_alen += extsz - temp;
        }
        /*
+        * Make sure we do not exceed the maximum len of an extent.
+        */
+       align_alen = XFS_FILBLKS_MIN(align_alen,
+                                    MAXEXTLEN - (MAXEXTLEN % extsz));
+       /*
         * If the previous block overlaps with this proposed allocation
         * then move the start forward without adjusting the length.
         */
@@ -4450,13 +4455,6 @@ xfs_bmapi_reserve_delalloc(
        /* Figure out the extent size, adjust alen */
        extsz = xfs_get_extsz_hint(ip);
        if (extsz) {
-               /*
-                * Make sure we don't exceed a single extent length when we
-                * align the extent by reducing length we are going to
-                * allocate by the maximum amount extent size aligment may
-                * require.
-                */
-               alen = XFS_FILBLKS_MIN(len, MAXEXTLEN - (2 * extsz - 1));
                error = xfs_bmap_extsize_align(mp, got, prev, extsz, rt, eof,
                                               1, 0, &aoff, &alen);
                ASSERT(!error);

<Prev in Thread] Current Thread [Next in Thread>