Skip to content

Commit

Permalink
don't change s_bitmap_maxbytes
Browse files Browse the repository at this point in the history
snapshot file size is limited by 32bit logical block address
the same as extent mapped file, so there is no need to change
s_bitmap_maxbytes which also affects other indirect mapped files.
Instead, use s_maxbytes to limit snapshot files seek and
don't allow snapshot files size change by truncate syscall.
  • Loading branch information
Amir Goldstein committed Jun 1, 2011
1 parent 50e48bf commit fc9582e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 5 additions & 0 deletions fs/ext4/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int origin)
struct inode *inode = file->f_mapping->host;
loff_t maxbytes;

#ifdef CONFIG_EXT4_FS_SNAPSHOT_FILE_HUGE
if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) &&
!ext4_snapshot_file(inode))
#else
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
#endif
maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
else
maxbytes = inode->i_sb->s_maxbytes;
Expand Down
17 changes: 8 additions & 9 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -5232,15 +5232,6 @@ void ext4_truncate(struct inode *inode)
ext4_lblk_t last_block;
unsigned blocksize = inode->i_sb->s_blocksize;

#ifdef CONFIG_EXT4_FS_SNAPSHOT_FILE_HUGE
/* prevent partial truncate of snapshot files */
if (ext4_snapshot_file(inode) && inode->i_size != 0) {
snapshot_debug(1, "snapshot file (%lu) cannot be partly "
"truncated!\n", inode->i_ino);
return;
}

#endif
#ifdef CONFIG_EXT4_FS_SNAPSHOT_FILE_PERM
/* prevent truncate of files on snapshot list */
if (ext4_snapshot_list(inode)) {
Expand Down Expand Up @@ -6184,6 +6175,14 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
}

if (attr->ia_valid & ATTR_SIZE) {
#ifdef CONFIG_EXT4_FS_SNAPSHOT_FILE_HUGE
/* prevent size modification of snapshot files */
if (ext4_snapshot_file(inode) && attr->ia_size != 0) {
snapshot_debug(1, "snapshot file (%lu) only can be "
"truncated to 0!\n", inode->i_ino);
return -EPERM;
}
#endif
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);

Expand Down
4 changes: 0 additions & 4 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2484,11 +2484,7 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files)

res += 1LL << (bits-2);
res += 1LL << (2*(bits-2));
#ifdef CONFIG_EXT4_FS_SNAPSHOT_FILE_HUGE
res += (1LL + EXT4_SNAPSHOT_EXTRA_TIND_BLOCKS) << (3*(bits-2));
#else
res += 1LL << (3*(bits-2));
#endif
res <<= bits;
if (res > upper_limit)
res = upper_limit;
Expand Down

0 comments on commit fc9582e

Please sign in to comment.