Merge tag 'fs_for_v5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull ext2 and udf fixes from Jan Kara:
"A couple of fixes for udf and ext2. Namely:
- fix making ext2 mountable (again) with 64k blocksize
- fix for ext2 statx(2) handling
- fix for udf handling of corrupted filesystem so that it doesn't get
corrupted even further
- couple smaller ext2 and udf cleanups"
* tag 'fs_for_v5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
udf: Drop pointless check from udf_sync_fs()
ext2: support statx syscall
udf: disallow RW mount without valid integrity descriptor
udf: finalize integrity descriptor before writeback
udf: factor out LVID finalization for reuse
ext2: Fix underflow in ext2_max_size()
ext2: Fix a typo in comment
ext2: Remove redundant check for finding no group
ext2: Annotate implicit fall through in __ext2_truncate_blocks
ext2: Set superblock revision when enabling xattr feature
ext2: Remove redundant check on s_inode_size
ext2: set proper return code
This commit is contained in:
@@ -758,6 +758,7 @@ extern int ext2_write_inode (struct inode *, struct writeback_control *);
|
||||
extern void ext2_evict_inode(struct inode *);
|
||||
extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
|
||||
extern int ext2_setattr (struct dentry *, struct iattr *);
|
||||
extern int ext2_getattr (const struct path *, struct kstat *, u32, unsigned int);
|
||||
extern void ext2_set_inode_flags(struct inode *inode);
|
||||
extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
||||
u64 start, u64 len);
|
||||
|
||||
@@ -199,6 +199,7 @@ const struct inode_operations ext2_file_inode_operations = {
|
||||
#ifdef CONFIG_EXT2_FS_XATTR
|
||||
.listxattr = ext2_listxattr,
|
||||
#endif
|
||||
.getattr = ext2_getattr,
|
||||
.setattr = ext2_setattr,
|
||||
.get_acl = ext2_get_acl,
|
||||
.set_acl = ext2_set_acl,
|
||||
|
||||
@@ -222,8 +222,6 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
|
||||
best_desc = desc;
|
||||
}
|
||||
}
|
||||
if (!best_desc)
|
||||
return -1;
|
||||
|
||||
return best_group;
|
||||
}
|
||||
|
||||
@@ -717,7 +717,7 @@ static int ext2_get_blocks(struct inode *inode,
|
||||
/* the number of blocks need to allocate for [d,t]indirect blocks */
|
||||
indirect_blks = (chain + depth) - partial - 1;
|
||||
/*
|
||||
* Next look up the indirect map to count the totoal number of
|
||||
* Next look up the indirect map to count the total number of
|
||||
* direct blocks to allocate for this branch.
|
||||
*/
|
||||
count = ext2_blks_to_allocate(partial, indirect_blks,
|
||||
@@ -1239,6 +1239,7 @@ do_indirects:
|
||||
mark_inode_dirty(inode);
|
||||
ext2_free_branches(inode, &nr, &nr+1, 1);
|
||||
}
|
||||
/* fall through */
|
||||
case EXT2_IND_BLOCK:
|
||||
nr = i_data[EXT2_DIND_BLOCK];
|
||||
if (nr) {
|
||||
@@ -1246,6 +1247,7 @@ do_indirects:
|
||||
mark_inode_dirty(inode);
|
||||
ext2_free_branches(inode, &nr, &nr+1, 2);
|
||||
}
|
||||
/* fall through */
|
||||
case EXT2_DIND_BLOCK:
|
||||
nr = i_data[EXT2_TIND_BLOCK];
|
||||
if (nr) {
|
||||
@@ -1635,6 +1637,32 @@ int ext2_write_inode(struct inode *inode, struct writeback_control *wbc)
|
||||
return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
|
||||
}
|
||||
|
||||
int ext2_getattr(const struct path *path, struct kstat *stat,
|
||||
u32 request_mask, unsigned int query_falgs)
|
||||
{
|
||||
struct inode *inode = d_inode(path->dentry);
|
||||
struct ext2_inode_info *ei = EXT2_I(inode);
|
||||
unsigned int flags;
|
||||
|
||||
flags = ei->i_flags & EXT2_FL_USER_VISIBLE;
|
||||
if (flags & EXT2_APPEND_FL)
|
||||
stat->attributes |= STATX_ATTR_APPEND;
|
||||
if (flags & EXT2_COMPR_FL)
|
||||
stat->attributes |= STATX_ATTR_COMPRESSED;
|
||||
if (flags & EXT2_IMMUTABLE_FL)
|
||||
stat->attributes |= STATX_ATTR_IMMUTABLE;
|
||||
if (flags & EXT2_NODUMP_FL)
|
||||
stat->attributes |= STATX_ATTR_NODUMP;
|
||||
stat->attributes_mask |= (STATX_ATTR_APPEND |
|
||||
STATX_ATTR_COMPRESSED |
|
||||
STATX_ATTR_ENCRYPTED |
|
||||
STATX_ATTR_IMMUTABLE |
|
||||
STATX_ATTR_NODUMP);
|
||||
|
||||
generic_fillattr(inode, stat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
|
||||
{
|
||||
struct inode *inode = d_inode(dentry);
|
||||
|
||||
@@ -416,6 +416,7 @@ const struct inode_operations ext2_dir_inode_operations = {
|
||||
#ifdef CONFIG_EXT2_FS_XATTR
|
||||
.listxattr = ext2_listxattr,
|
||||
#endif
|
||||
.getattr = ext2_getattr,
|
||||
.setattr = ext2_setattr,
|
||||
.get_acl = ext2_get_acl,
|
||||
.set_acl = ext2_set_acl,
|
||||
@@ -426,6 +427,7 @@ const struct inode_operations ext2_special_inode_operations = {
|
||||
#ifdef CONFIG_EXT2_FS_XATTR
|
||||
.listxattr = ext2_listxattr,
|
||||
#endif
|
||||
.getattr = ext2_getattr,
|
||||
.setattr = ext2_setattr,
|
||||
.get_acl = ext2_get_acl,
|
||||
.set_acl = ext2_set_acl,
|
||||
|
||||
@@ -757,7 +757,8 @@ static loff_t ext2_max_size(int bits)
|
||||
{
|
||||
loff_t res = EXT2_NDIR_BLOCKS;
|
||||
int meta_blocks;
|
||||
loff_t upper_limit;
|
||||
unsigned int upper_limit;
|
||||
unsigned int ppb = 1 << (bits-2);
|
||||
|
||||
/* This is calculated to be the largest file size for a
|
||||
* dense, file such that the total number of
|
||||
@@ -771,24 +772,34 @@ static loff_t ext2_max_size(int bits)
|
||||
/* total blocks in file system block size */
|
||||
upper_limit >>= (bits - 9);
|
||||
|
||||
|
||||
/* indirect blocks */
|
||||
meta_blocks = 1;
|
||||
/* double indirect blocks */
|
||||
meta_blocks += 1 + (1LL << (bits-2));
|
||||
/* tripple indirect blocks */
|
||||
meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2)));
|
||||
|
||||
upper_limit -= meta_blocks;
|
||||
upper_limit <<= bits;
|
||||
|
||||
/* Compute how many blocks we can address by block tree */
|
||||
res += 1LL << (bits-2);
|
||||
res += 1LL << (2*(bits-2));
|
||||
res += 1LL << (3*(bits-2));
|
||||
res <<= bits;
|
||||
if (res > upper_limit)
|
||||
res = upper_limit;
|
||||
/* Does block tree limit file size? */
|
||||
if (res < upper_limit)
|
||||
goto check_lfs;
|
||||
|
||||
res = upper_limit;
|
||||
/* How many metadata blocks are needed for addressing upper_limit? */
|
||||
upper_limit -= EXT2_NDIR_BLOCKS;
|
||||
/* indirect blocks */
|
||||
meta_blocks = 1;
|
||||
upper_limit -= ppb;
|
||||
/* double indirect blocks */
|
||||
if (upper_limit < ppb * ppb) {
|
||||
meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb);
|
||||
res -= meta_blocks;
|
||||
goto check_lfs;
|
||||
}
|
||||
meta_blocks += 1 + ppb;
|
||||
upper_limit -= ppb * ppb;
|
||||
/* tripple indirect blocks for the rest */
|
||||
meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb) +
|
||||
DIV_ROUND_UP(upper_limit, ppb*ppb);
|
||||
res -= meta_blocks;
|
||||
check_lfs:
|
||||
res <<= bits;
|
||||
if (res > MAX_LFS_FILESIZE)
|
||||
res = MAX_LFS_FILESIZE;
|
||||
|
||||
@@ -1024,8 +1035,6 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
|
||||
sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
|
||||
sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
|
||||
|
||||
if (EXT2_INODE_SIZE(sb) == 0)
|
||||
goto cantfind_ext2;
|
||||
sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
|
||||
if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0)
|
||||
goto cantfind_ext2;
|
||||
@@ -1087,12 +1096,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
|
||||
sizeof(struct buffer_head *),
|
||||
GFP_KERNEL);
|
||||
if (sbi->s_group_desc == NULL) {
|
||||
ret = -ENOMEM;
|
||||
ext2_msg(sb, KERN_ERR, "error: not enough memory");
|
||||
goto failed_mount;
|
||||
}
|
||||
bgl_lock_init(sbi->s_blockgroup_lock);
|
||||
sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
|
||||
if (!sbi->s_debts) {
|
||||
ret = -ENOMEM;
|
||||
ext2_msg(sb, KERN_ERR, "error: not enough memory");
|
||||
goto failed_mount_group_desc;
|
||||
}
|
||||
@@ -1148,6 +1159,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
|
||||
#ifdef CONFIG_EXT2_FS_XATTR
|
||||
sbi->s_ea_block_cache = ext2_xattr_create_cache();
|
||||
if (!sbi->s_ea_block_cache) {
|
||||
ret = -ENOMEM;
|
||||
ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
|
||||
goto failed_mount3;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
const struct inode_operations ext2_symlink_inode_operations = {
|
||||
.get_link = page_get_link,
|
||||
.getattr = ext2_getattr,
|
||||
.setattr = ext2_setattr,
|
||||
#ifdef CONFIG_EXT2_FS_XATTR
|
||||
.listxattr = ext2_listxattr,
|
||||
@@ -31,6 +32,7 @@ const struct inode_operations ext2_symlink_inode_operations = {
|
||||
|
||||
const struct inode_operations ext2_fast_symlink_inode_operations = {
|
||||
.get_link = simple_get_link,
|
||||
.getattr = ext2_getattr,
|
||||
.setattr = ext2_setattr,
|
||||
#ifdef CONFIG_EXT2_FS_XATTR
|
||||
.listxattr = ext2_listxattr,
|
||||
|
||||
@@ -342,6 +342,7 @@ static void ext2_xattr_update_super_block(struct super_block *sb)
|
||||
return;
|
||||
|
||||
spin_lock(&EXT2_SB(sb)->s_lock);
|
||||
ext2_update_dynamic_rev(sb);
|
||||
EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR);
|
||||
spin_unlock(&EXT2_SB(sb)->s_lock);
|
||||
mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
|
||||
|
||||
Reference in New Issue
Block a user