xfs
[Top] [All Lists]

[PATCH V2] xfs: prevent xfs_bmap_extsize_align() to exceed maximum exten

To: xfs@xxxxxxxxxxx
Subject: [PATCH V2] xfs: prevent xfs_bmap_extsize_align() to exceed maximum extent size.
From: Alain Renaud <arenaud@xxxxxxx>
Date: Tue, 17 Jul 2012 18:35:03 +0200
In-reply-to: <4FFFF3D8.7060001@xxxxxxx>
References: <20120712154554.377970666@xxxxxxx> <4FFFF3D8.7060001@xxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1
Here is a second revision. Needed to remove an ASSERT and added a new one.

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 |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 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.
 	 */
@@ -1999,7 +2004,6 @@ xfs_bmap_extsize_align(
 			return XFS_ERROR(EINVAL);
 	} else {
 		ASSERT(orig_off >= align_off);
-		ASSERT(orig_end <= align_off + align_alen);
 	}
 
 #ifdef DEBUG
@@ -2009,6 +2013,7 @@ xfs_bmap_extsize_align(
 		ASSERT(align_off >= prevp->br_startoff + prevp->br_blockcount);
 #endif
 
+	ASSERT(align_alen <= MAXEXTLEN);
 	*lenp = align_alen;
 	*offp = align_off;
 	return 0;
@@ -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);

-- 
===============================================
Alain Renaud     - Cluster File System Engineer 
arenaud@xxxxxxx  - SGI
===============================================


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