Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 212767
b: refs/heads/master
c: 30ca22c
h: refs/heads/master
i:
  212765: dedea4c
  212763: f6dd626
  212759: 87b3246
  212751: 02fe5df
  212735: 2a49a03
v: v3
  • Loading branch information
Patrick J. LoPresti authored and Joel Becker committed Sep 10, 2010
1 parent 480937e commit 620f27b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 729963a1ff8d069d05dab6a024bfd59805ac622c
refs/heads/master: 30ca22c70e3ef0a96ff84de69cd7e8561b416cb2
4 changes: 2 additions & 2 deletions trunk/fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1849,8 +1849,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
goto failed_mount;
}

if (le32_to_cpu(es->s_blocks_count) >
(sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
if (generic_check_addressable(sb->s_blocksize_bits,
le32_to_cpu(es->s_blocks_count))) {
ext3_msg(sb, KERN_ERR,
"error: filesystem is too large to mount safely");
if (sizeof(sector_t) < 8)
Expand Down
8 changes: 3 additions & 5 deletions trunk/fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2831,15 +2831,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
* Test whether we have more sectors than will fit in sector_t,
* and whether the max offset is addressable by the page cache.
*/
if ((ext4_blocks_count(es) >
(sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) ||
(ext4_blocks_count(es) >
(pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - sb->s_blocksize_bits))) {
ret = generic_check_addressable(sb->s_blocksize_bits,
ext4_blocks_count(es));
if (ret) {
ext4_msg(sb, KERN_ERR, "filesystem"
" too large to mount safely on this system");
if (sizeof(sector_t) < 8)
ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled");
ret = -EFBIG;
goto failed_mount;
}

Expand Down
29 changes: 29 additions & 0 deletions trunk/fs/libfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,35 @@ int generic_file_fsync(struct file *file, int datasync)
}
EXPORT_SYMBOL(generic_file_fsync);

/**
* generic_check_addressable - Check addressability of file system
* @blocksize_bits: log of file system block size
* @num_blocks: number of blocks in file system
*
* Determine whether a file system with @num_blocks blocks (and a
* block size of 2**@blocksize_bits) is addressable by the sector_t
* and page cache of the system. Return 0 if so and -EFBIG otherwise.
*/
int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
{
u64 last_fs_block = num_blocks - 1;

if (unlikely(num_blocks == 0))
return 0;

if ((blocksize_bits < 9) || (blocksize_bits > PAGE_CACHE_SHIFT))
return -EINVAL;

if ((last_fs_block >
(sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
(last_fs_block >
(pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - blocksize_bits))) {
return -EFBIG;
}
return 0;
}
EXPORT_SYMBOL(generic_check_addressable);

/*
* No-op implementation of ->fsync for in-memory filesystems.
*/
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2374,6 +2374,8 @@ extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,

extern int generic_file_fsync(struct file *, int);

extern int generic_check_addressable(unsigned, u64);

#ifdef CONFIG_MIGRATION
extern int buffer_migrate_page(struct address_space *,
struct page *, struct page *);
Expand Down

0 comments on commit 620f27b

Please sign in to comment.