From: Zhang Yi <yi.zhang@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>, <jack@suse.cz>,
<yi.zhang@huawei.com>, <yukuai3@huawei.com>
Subject: [PATCH v2 3/4] ext4: don't return error if huge_file feature mismatch
Date: Thu, 19 Aug 2021 14:57:03 +0800 [thread overview]
Message-ID: <20210819065704.1248402-4-yi.zhang@huawei.com> (raw)
In-Reply-To: <20210819065704.1248402-1-yi.zhang@huawei.com>
In ext4_inode_blocks_set(), huge_file feature should exist when setting
i_blocks beyond a 32 bit variable could be represented, return EFBIG if
not. This error should never happen in theory since sb->s_maxbytes should
not have allowed this, and we have already init sb->s_maxbytes according
to this feature in ext4_fill_super(). So switch to use WARN_ON_ONCE
instead.
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
---
fs/ext4/inode.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index eae1b2d0b550..d0d7a5295bf9 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4902,9 +4902,9 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
return ERR_PTR(ret);
}
-static int ext4_inode_blocks_set(handle_t *handle,
- struct ext4_inode *raw_inode,
- struct ext4_inode_info *ei)
+static void ext4_inode_blocks_set(handle_t *handle,
+ struct ext4_inode *raw_inode,
+ struct ext4_inode_info *ei)
{
struct inode *inode = &(ei->vfs_inode);
u64 i_blocks = READ_ONCE(inode->i_blocks);
@@ -4918,10 +4918,15 @@ static int ext4_inode_blocks_set(handle_t *handle,
raw_inode->i_blocks_lo = cpu_to_le32(i_blocks);
raw_inode->i_blocks_high = 0;
ext4_clear_inode_flag(inode, EXT4_INODE_HUGE_FILE);
- return 0;
+ return;
}
- if (!ext4_has_feature_huge_file(sb))
- return -EFBIG;
+
+ /*
+ * This should never happen since sb->s_maxbytes should not have
+ * allowed this, which was set according to the huge_file feature
+ * in ext4_fill_super().
+ */
+ WARN_ON_ONCE(!ext4_has_feature_huge_file(sb));
if (i_blocks <= 0xffffffffffffULL) {
/*
@@ -4938,7 +4943,6 @@ static int ext4_inode_blocks_set(handle_t *handle,
raw_inode->i_blocks_lo = cpu_to_le32(i_blocks);
raw_inode->i_blocks_high = cpu_to_le16(i_blocks >> 32);
}
- return 0;
}
static void __ext4_update_other_inode_time(struct super_block *sb,
@@ -5029,11 +5033,7 @@ static int ext4_do_update_inode(handle_t *handle,
if (ext4_test_inode_state(inode, EXT4_STATE_NEW))
memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
- err = ext4_inode_blocks_set(handle, raw_inode, ei);
- if (err) {
- spin_unlock(&ei->i_raw_lock);
- goto out_brelse;
- }
+ ext4_inode_blocks_set(handle, raw_inode, ei);
raw_inode->i_mode = cpu_to_le16(inode->i_mode);
i_uid = i_uid_read(inode);
--
2.31.1
next prev parent reply other threads:[~2021-08-19 6:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-19 6:57 [PATCH v2 0/4] ext4: fix a inode checksum error Zhang Yi
2021-08-19 6:57 ` [PATCH v2 1/4] ext4: move inode eio simulation behind io completeion Zhang Yi
2021-08-19 6:57 ` [PATCH v2 2/4] ext4: remove an unnecessary if statement in __ext4_get_inode_loc() Zhang Yi
2021-08-19 6:57 ` Zhang Yi [this message]
2021-08-19 10:26 ` [PATCH v2 3/4] ext4: don't return error if huge_file feature mismatch Jan Kara
2021-08-19 13:11 ` Zhang Yi
2021-08-19 6:57 ` [PATCH v2 4/4] ext4: prevent getting empty inode buffer Zhang Yi
2021-08-19 10:35 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210819065704.1248402-4-yi.zhang@huawei.com \
--to=yi.zhang@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox