Skip to content

Commit dfdeeb4

Browse files
committed
Merge branch 'tt/misc' into dev
2 parents 3c845ac + c7df4a1 commit dfdeeb4

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

fs/ext4/inode.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,8 +5580,23 @@ static int __ext4_expand_extra_isize(struct inode *inode,
55805580
{
55815581
struct ext4_inode *raw_inode;
55825582
struct ext4_xattr_ibody_header *header;
5583+
unsigned int inode_size = EXT4_INODE_SIZE(inode->i_sb);
5584+
struct ext4_inode_info *ei = EXT4_I(inode);
55835585
int error;
55845586

5587+
/* this was checked at iget time, but double check for good measure */
5588+
if ((EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > inode_size) ||
5589+
(ei->i_extra_isize & 3)) {
5590+
EXT4_ERROR_INODE(inode, "bad extra_isize %u (inode size %u)",
5591+
ei->i_extra_isize,
5592+
EXT4_INODE_SIZE(inode->i_sb));
5593+
return -EFSCORRUPTED;
5594+
}
5595+
if ((new_extra_isize < ei->i_extra_isize) ||
5596+
(new_extra_isize < 4) ||
5597+
(new_extra_isize > inode_size - EXT4_GOOD_OLD_INODE_SIZE))
5598+
return -EINVAL; /* Should never happen */
5599+
55855600
raw_inode = ext4_raw_inode(iloc);
55865601

55875602
header = IHDR(inode, raw_inode);

fs/ext4/namei.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,18 +3196,17 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
31963196
if (IS_DIRSYNC(dir))
31973197
ext4_handle_sync(handle);
31983198

3199-
if (inode->i_nlink == 0) {
3200-
ext4_warning_inode(inode, "Deleting file '%.*s' with no links",
3201-
dentry->d_name.len, dentry->d_name.name);
3202-
set_nlink(inode, 1);
3203-
}
32043199
retval = ext4_delete_entry(handle, dir, de, bh);
32053200
if (retval)
32063201
goto end_unlink;
32073202
dir->i_ctime = dir->i_mtime = current_time(dir);
32083203
ext4_update_dx_flag(dir);
32093204
ext4_mark_inode_dirty(handle, dir);
3210-
drop_nlink(inode);
3205+
if (inode->i_nlink == 0)
3206+
ext4_warning_inode(inode, "Deleting file '%.*s' with no links",
3207+
dentry->d_name.len, dentry->d_name.name);
3208+
else
3209+
drop_nlink(inode);
32113210
if (!inode->i_nlink)
32123211
ext4_orphan_add(handle, inode);
32133212
inode->i_ctime = current_time(inode);

fs/ext4/super.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,12 +3544,15 @@ static void ext4_clamp_want_extra_isize(struct super_block *sb)
35443544
{
35453545
struct ext4_sb_info *sbi = EXT4_SB(sb);
35463546
struct ext4_super_block *es = sbi->s_es;
3547+
unsigned def_extra_isize = sizeof(struct ext4_inode) -
3548+
EXT4_GOOD_OLD_INODE_SIZE;
35473549

3548-
/* determine the minimum size of new large inodes, if present */
3549-
if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE &&
3550-
sbi->s_want_extra_isize == 0) {
3551-
sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
3552-
EXT4_GOOD_OLD_INODE_SIZE;
3550+
if (sbi->s_inode_size == EXT4_GOOD_OLD_INODE_SIZE) {
3551+
sbi->s_want_extra_isize = 0;
3552+
return;
3553+
}
3554+
if (sbi->s_want_extra_isize < 4) {
3555+
sbi->s_want_extra_isize = def_extra_isize;
35533556
if (ext4_has_feature_extra_isize(sb)) {
35543557
if (sbi->s_want_extra_isize <
35553558
le16_to_cpu(es->s_want_extra_isize))
@@ -3562,10 +3565,10 @@ static void ext4_clamp_want_extra_isize(struct super_block *sb)
35623565
}
35633566
}
35643567
/* Check if enough inode space is available */
3565-
if (EXT4_GOOD_OLD_INODE_SIZE + sbi->s_want_extra_isize >
3566-
sbi->s_inode_size) {
3567-
sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
3568-
EXT4_GOOD_OLD_INODE_SIZE;
3568+
if ((sbi->s_want_extra_isize > sbi->s_inode_size) ||
3569+
(EXT4_GOOD_OLD_INODE_SIZE + sbi->s_want_extra_isize >
3570+
sbi->s_inode_size)) {
3571+
sbi->s_want_extra_isize = def_extra_isize;
35693572
ext4_msg(sb, KERN_INFO,
35703573
"required extra inode space not available");
35713574
}

0 commit comments

Comments
 (0)