-----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEq1nRK9aeMoq1VSgcnJ2qBz9kQNkFAlx5SeAACgkQnJ2qBz9k QNlzLAf/c+1o6fd4mH9uBMqEHwo+g7cKcr76j00h60bZpMJ0N/k91o8KtUKDixLJ wG1o3FtaFyOpKXInjQOZZ83XQybjpDDFO67pCss/OYZ9bHtWM6ZfrYQzpxpIXu2E 7/FFjZV7MlugmnqJbvYRvMr2Tx7IrqOeWZ0ZIUMRnghuBarLpbiOqFaTbGlqS8e1 haFRhbxv0sA44YN9N40XVpg6P+cRsxJ4cHDSyQn4+X9CoYdKZ69utXyiiaV2L/Gc iNYn2fkh7IDkgxF8imwHSLhvvAVangWWphhTX/XVnCPq0FKTRw9e2tRdt77IlDlX w/GCHKnXaM6GnGDj4t83KV4yrdXGsQ== =xrvx -----END PGP SIGNATURE----- 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:
commit
a9913f23f3
|
@ -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);
|
||||
|
|
|
@ -1474,6 +1474,17 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
|
|||
if (lvd->integritySeqExt.extLength)
|
||||
udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));
|
||||
ret = 0;
|
||||
|
||||
if (!sbi->s_lvid_bh) {
|
||||
/* We can't generate unique IDs without a valid LVID */
|
||||
if (sb_rdonly(sb)) {
|
||||
UDF_SET_FLAG(sb, UDF_FLAG_RW_INCOMPAT);
|
||||
} else {
|
||||
udf_warn(sb, "Damaged or missing LVID, forcing "
|
||||
"readonly mount\n");
|
||||
ret = -EACCES;
|
||||
}
|
||||
}
|
||||
out_bh:
|
||||
brelse(bh);
|
||||
return ret;
|
||||
|
@ -1943,13 +1954,24 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void udf_finalize_lvid(struct logicalVolIntegrityDesc *lvid)
|
||||
{
|
||||
struct timespec64 ts;
|
||||
|
||||
ktime_get_real_ts64(&ts);
|
||||
udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
|
||||
lvid->descTag.descCRC = cpu_to_le16(
|
||||
crc_itu_t(0, (char *)lvid + sizeof(struct tag),
|
||||
le16_to_cpu(lvid->descTag.descCRCLength)));
|
||||
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
|
||||
}
|
||||
|
||||
static void udf_open_lvid(struct super_block *sb)
|
||||
{
|
||||
struct udf_sb_info *sbi = UDF_SB(sb);
|
||||
struct buffer_head *bh = sbi->s_lvid_bh;
|
||||
struct logicalVolIntegrityDesc *lvid;
|
||||
struct logicalVolIntegrityDescImpUse *lvidiu;
|
||||
struct timespec64 ts;
|
||||
|
||||
if (!bh)
|
||||
return;
|
||||
|
@ -1961,18 +1983,12 @@ static void udf_open_lvid(struct super_block *sb)
|
|||
mutex_lock(&sbi->s_alloc_mutex);
|
||||
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
|
||||
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
|
||||
ktime_get_real_ts64(&ts);
|
||||
udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
|
||||
if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE)
|
||||
lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
|
||||
else
|
||||
UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT);
|
||||
|
||||
lvid->descTag.descCRC = cpu_to_le16(
|
||||
crc_itu_t(0, (char *)lvid + sizeof(struct tag),
|
||||
le16_to_cpu(lvid->descTag.descCRCLength)));
|
||||
|
||||
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
|
||||
udf_finalize_lvid(lvid);
|
||||
mark_buffer_dirty(bh);
|
||||
sbi->s_lvid_dirty = 0;
|
||||
mutex_unlock(&sbi->s_alloc_mutex);
|
||||
|
@ -1986,7 +2002,6 @@ static void udf_close_lvid(struct super_block *sb)
|
|||
struct buffer_head *bh = sbi->s_lvid_bh;
|
||||
struct logicalVolIntegrityDesc *lvid;
|
||||
struct logicalVolIntegrityDescImpUse *lvidiu;
|
||||
struct timespec64 ts;
|
||||
|
||||
if (!bh)
|
||||
return;
|
||||
|
@ -1998,8 +2013,6 @@ static void udf_close_lvid(struct super_block *sb)
|
|||
mutex_lock(&sbi->s_alloc_mutex);
|
||||
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
|
||||
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
|
||||
ktime_get_real_ts64(&ts);
|
||||
udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
|
||||
if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
|
||||
lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
|
||||
if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
|
||||
|
@ -2009,17 +2022,13 @@ static void udf_close_lvid(struct super_block *sb)
|
|||
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT))
|
||||
lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
|
||||
|
||||
lvid->descTag.descCRC = cpu_to_le16(
|
||||
crc_itu_t(0, (char *)lvid + sizeof(struct tag),
|
||||
le16_to_cpu(lvid->descTag.descCRCLength)));
|
||||
|
||||
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
|
||||
/*
|
||||
* We set buffer uptodate unconditionally here to avoid spurious
|
||||
* warnings from mark_buffer_dirty() when previous EIO has marked
|
||||
* the buffer as !uptodate
|
||||
*/
|
||||
set_buffer_uptodate(bh);
|
||||
udf_finalize_lvid(lvid);
|
||||
mark_buffer_dirty(bh);
|
||||
sbi->s_lvid_dirty = 0;
|
||||
mutex_unlock(&sbi->s_alloc_mutex);
|
||||
|
@ -2048,8 +2057,8 @@ u64 lvid_get_unique_id(struct super_block *sb)
|
|||
if (!(++uniqueID & 0xFFFFFFFF))
|
||||
uniqueID += 16;
|
||||
lvhd->uniqueID = cpu_to_le64(uniqueID);
|
||||
udf_updated_lvid(sb);
|
||||
mutex_unlock(&sbi->s_alloc_mutex);
|
||||
mark_buffer_dirty(bh);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -2320,11 +2329,17 @@ static int udf_sync_fs(struct super_block *sb, int wait)
|
|||
|
||||
mutex_lock(&sbi->s_alloc_mutex);
|
||||
if (sbi->s_lvid_dirty) {
|
||||
struct buffer_head *bh = sbi->s_lvid_bh;
|
||||
struct logicalVolIntegrityDesc *lvid;
|
||||
|
||||
lvid = (struct logicalVolIntegrityDesc *)bh->b_data;
|
||||
udf_finalize_lvid(lvid);
|
||||
|
||||
/*
|
||||
* Blockdevice will be synced later so we don't have to submit
|
||||
* the buffer for IO
|
||||
*/
|
||||
mark_buffer_dirty(sbi->s_lvid_bh);
|
||||
mark_buffer_dirty(bh);
|
||||
sbi->s_lvid_dirty = 0;
|
||||
}
|
||||
mutex_unlock(&sbi->s_alloc_mutex);
|
||||
|
|
Loading…
Reference in New Issue