diff options
author | Dave Chinner <dchinner@redhat.com> | 2011-01-26 20:18:18 -0500 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2011-01-28 10:05:36 -0500 |
commit | 5315837daee7ed76c31ef643915f7d76ef8c1aa3 (patch) | |
tree | de92499a896cc5d6702be364c9c3339641d3ed93 /fs/xfs | |
parent | 4ce159890c00e2cc705e955a939bf1dca7b07ab8 (diff) |
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | 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 b06ede1d0bed..f5e2a19e0f8e 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( | |||
985 | 985 | ||
986 | /* | 986 | /* |
987 | * Extent size must be a multiple of the appropriate block | 987 | * Extent size must be a multiple of the appropriate block |
988 | * size, if set at all. | 988 | * size, if set at all. It must also be smaller than the |
989 | * maximum extent size supported by the filesystem. | ||
990 | * | ||
991 | * Also, for non-realtime files, limit the extent size hint to | ||
992 | * half the size of the AGs in the filesystem so alignment | ||
993 | * doesn't result in extents larger than an AG. | ||
989 | */ | 994 | */ |
990 | if (fa->fsx_extsize != 0) { | 995 | if (fa->fsx_extsize != 0) { |
991 | xfs_extlen_t size; | 996 | xfs_extlen_t size; |
997 | xfs_fsblock_t extsize_fsb; | ||
998 | |||
999 | extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize); | ||
1000 | if (extsize_fsb > MAXEXTLEN) { | ||
1001 | code = XFS_ERROR(EINVAL); | ||
1002 | goto error_return; | ||
1003 | } | ||
992 | 1004 | ||
993 | if (XFS_IS_REALTIME_INODE(ip) || | 1005 | if (XFS_IS_REALTIME_INODE(ip) || |
994 | ((mask & FSX_XFLAGS) && | 1006 | ((mask & FSX_XFLAGS) && |
@@ -997,6 +1009,10 @@ xfs_ioctl_setattr( | |||
997 | mp->m_sb.sb_blocklog; | 1009 | mp->m_sb.sb_blocklog; |
998 | } else { | 1010 | } else { |
999 | size = mp->m_sb.sb_blocksize; | 1011 | size = mp->m_sb.sb_blocksize; |
1012 | if (extsize_fsb > mp->m_sb.sb_agblocks / 2) { | ||
1013 | code = XFS_ERROR(EINVAL); | ||
1014 | goto error_return; | ||
1015 | } | ||
1000 | } | 1016 | } |
1001 | 1017 | ||
1002 | if (fa->fsx_extsize % size) { | 1018 | if (fa->fsx_extsize % size) { |