aboutsummaryrefslogtreecommitdiffstats
path: root/fs/libfs.c
diff options
context:
space:
mode:
authorPatrick J. LoPresti <lopresti@gmail.com>2010-07-22 18:03:41 -0400
committerJoel Becker <joel.becker@oracle.com>2010-09-10 11:41:42 -0400
commit30ca22c70e3ef0a96ff84de69cd7e8561b416cb2 (patch)
tree0da339bf657ae19a39baf3c4d31ebfb0ae6c09ce /fs/libfs.c
parent729963a1ff8d069d05dab6a024bfd59805ac622c (diff)
ext3/ext4: Factor out disk addressability check
As part of adding support for OCFS2 to mount huge volumes, we need to check that the sector_t and page cache of the system are capable of addressing the entire volume. An identical check already appears in ext3 and ext4. This patch moves the addressability check into its own function in fs/libfs.c and modifies ext3 and ext4 to invoke it. [Edited to -EINVAL instead of BUG_ON() for bad blocksize_bits -- Joel] Signed-off-by: Patrick LoPresti <lopresti@gmail.com> Cc: linux-ext4@vger.kernel.org Acked-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/libfs.c')
-rw-r--r--fs/libfs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/libfs.c b/fs/libfs.c
index 0a9da95317f7..8debe7b33769 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -913,6 +913,35 @@ int generic_file_fsync(struct file *file, int datasync)
913} 913}
914EXPORT_SYMBOL(generic_file_fsync); 914EXPORT_SYMBOL(generic_file_fsync);
915 915
916/**
917 * generic_check_addressable - Check addressability of file system
918 * @blocksize_bits: log of file system block size
919 * @num_blocks: number of blocks in file system
920 *
921 * Determine whether a file system with @num_blocks blocks (and a
922 * block size of 2**@blocksize_bits) is addressable by the sector_t
923 * and page cache of the system. Return 0 if so and -EFBIG otherwise.
924 */
925int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
926{
927 u64 last_fs_block = num_blocks - 1;
928
929 if (unlikely(num_blocks == 0))
930 return 0;
931
932 if ((blocksize_bits < 9) || (blocksize_bits > PAGE_CACHE_SHIFT))
933 return -EINVAL;
934
935 if ((last_fs_block >
936 (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
937 (last_fs_block >
938 (pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - blocksize_bits))) {
939 return -EFBIG;
940 }
941 return 0;
942}
943EXPORT_SYMBOL(generic_check_addressable);
944
916/* 945/*
917 * No-op implementation of ->fsync for in-memory filesystems. 946 * No-op implementation of ->fsync for in-memory filesystems.
918 */ 947 */