From: "Theodore Ts'o" <tytso@mit.edu>
To: bugzilla-daemon@kernel.org
Cc: linux-ext4@vger.kernel.org, chengzhihao1@huawei.com
Subject: [PATCH] ext4: swap i_disksize when swaping the boot loader inode
Date: Tue, 7 Mar 2023 23:12:52 -0500 [thread overview]
Message-ID: <20230308041252.GC860405@mit.edu> (raw)
In-Reply-To: <bug-217159-13602-BE3LDOwNA7@https.bugzilla.kernel.org/>
The following patch fixes the reported issue.
From f4e156cef119f3ffcc56874da4fb9299cc14f68e Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Tue, 7 Mar 2023 23:06:59 -0500
Subject: [PATCH] ext4: swap i_disksize when swaping the boot loader inode
Normally well-behaved of EXT4_IOC_SWAP_BOOT won't actually try to
write to the either inode after using the ioctl, but if they do, the
fact that we're not swapping ei->i_disksize as well as inode->i_size
can trigger warnings.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217159
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
fs/ext4/ioctl.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 2e8c34036313..e552c5db0c95 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -329,9 +329,13 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS);
ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS);
- isize = i_size_read(inode1);
- i_size_write(inode1, i_size_read(inode2));
- i_size_write(inode2, isize);
+ /*
+ * Both inodes are locked, so we don't need to fool around
+ * with i_size_read() and i_size_write().
+ */
+ isize = inode1->i_size;
+ inode1->i_size = ei1->i_disksize = inode2->i_size;
+ inode2->i_size = ei2->i_disksize = isize;
}
void ext4_reset_inode_seed(struct inode *inode)
--
2.31.0
next prev parent reply other threads:[~2023-03-08 4:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 2:55 [Bug 217159] New: WARN in ext4_handle_inode_extension: i_size_read(inode) < EXT4_I(inode)->i_disksize bugzilla-daemon
2023-03-08 2:57 ` [Bug 217159] " bugzilla-daemon
2023-03-08 2:57 ` bugzilla-daemon
2023-03-08 4:12 ` Theodore Ts'o [this message]
2023-03-08 6:15 ` [PATCH] ext4: swap i_disksize when swaping the boot loader inode Zhihao Cheng
2023-03-08 4:19 ` [Bug 217159] WARN in ext4_handle_inode_extension: i_size_read(inode) < EXT4_I(inode)->i_disksize bugzilla-daemon
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=20230308041252.GC860405@mit.edu \
--to=tytso@mit.edu \
--cc=bugzilla-daemon@kernel.org \
--cc=chengzhihao1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).