[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    xfs: limit extsize to size of AGs and/or MAXEXTLEN
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2011-01-31 22:59:46
Message-ID: 201101312259.p0VMxk0H004221 () hera ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/linus/5315837daee7ed76c31ef643915f7d76ef8c1aa3
Commit:     5315837daee7ed76c31ef643915f7d76ef8c1aa3
Parent:     4ce159890c00e2cc705e955a939bf1dca7b07ab8
Author:     Dave Chinner <dchinner@redhat.com>
AuthorDate: Thu Jan 27 12:18:18 2011 +1100
Committer:  Alex Elder <aelder@sgi.com>
CommitDate: Fri Jan 28 09:05:36 2011 -0600

    xfs: limit extsize to size of AGs and/or MAXEXTLEN
    
    The extent size hint can be set to larger than an AG. This means
    that the alignment process can push the range to be allocated
    outside the bounds of the AG, resulting in assert failures or
    corrupted bmbt records. Similarly, if the extsize is larger than the
    maximum extent size supported, the alignment process will produce
    extents that are too large to fit into the bmbt records, resulting
    in a different type of assert/corruption failure.
    
    Fix this by limiting extsize at the time іt is set firstly to be
    less than MAXEXTLEN, then to be a maximum of half the size of the
    AGs in the filesystem for non-realtime inodes. Realtime inodes do
    not allocate out of AGs, so don't have to be restricted by the size
    of AGs.
    
    Signed-off-by: Dave Chinner <dchinner@redhat.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Alex Elder <aelder@sgi.com>
---
 fs/xfs/linux-2.6/xfs_ioctl.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index b06ede1..f5e2a19 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -985,10 +985,22 @@ xfs_ioctl_setattr(
 
 		/*
 		 * Extent size must be a multiple of the appropriate block
-		 * size, if set at all.
+		 * size, if set at all. It must also be smaller than the
+		 * maximum extent size supported by the filesystem.
+		 *
+		 * Also, for non-realtime files, limit the extent size hint to
+		 * half the size of the AGs in the filesystem so alignment
+		 * doesn't result in extents larger than an AG.
 		 */
 		if (fa->fsx_extsize != 0) {
-			xfs_extlen_t	size;
+			xfs_extlen_t    size;
+			xfs_fsblock_t   extsize_fsb;
+
+			extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize);
+			if (extsize_fsb > MAXEXTLEN) {
+				code = XFS_ERROR(EINVAL);
+				goto error_return;
+			}
 
 			if (XFS_IS_REALTIME_INODE(ip) ||
 			    ((mask & FSX_XFLAGS) &&
@@ -997,6 +1009,10 @@ xfs_ioctl_setattr(
 				       mp->m_sb.sb_blocklog;
 			} else {
 				size = mp->m_sb.sb_blocksize;
+				if (extsize_fsb > mp->m_sb.sb_agblocks / 2) {
+					code = XFS_ERROR(EINVAL);
+					goto error_return;
+				}
 			}
 
 			if (fa->fsx_extsize % size) {
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic