Ye Bin
18a759f7f9
ext4: fix bug_on in ext4_writepages
...
commit ef09ed5d37b84d18562b30cf7253e57062d0db05 upstream.
we got issue as follows:
EXT4-fs error (device loop0): ext4_mb_generate_buddy:1141: group 0, block bitmap and bg descriptor inconsistent: 25 vs 31513 free cls
------------[ cut here ]------------
kernel BUG at fs/ext4/inode.c:2708!
invalid opcode: 0000 [#1 ] PREEMPT SMP KASAN PTI
CPU: 2 PID: 2147 Comm: rep Not tainted 5.18.0-rc2-next-20220413+ #155
RIP: 0010:ext4_writepages+0x1977/0x1c10
RSP: 0018:ffff88811d3e7880 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffff88811c098000
RDX: 0000000000000000 RSI: ffff88811c098000 RDI: 0000000000000002
RBP: ffff888128140f50 R08: ffffffffb1ff6387 R09: 0000000000000000
R10: 0000000000000007 R11: ffffed10250281ea R12: 0000000000000001
R13: 00000000000000a4 R14: ffff88811d3e7bb8 R15: ffff888128141028
FS: 00007f443aed9740(0000) GS:ffff8883aef00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020007200 CR3: 000000011c2a4000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
do_writepages+0x130/0x3a0
filemap_fdatawrite_wbc+0x83/0xa0
filemap_flush+0xab/0xe0
ext4_alloc_da_blocks+0x51/0x120
__ext4_ioctl+0x1534/0x3210
__x64_sys_ioctl+0x12c/0x170
do_syscall_64+0x3b/0x90
It may happen as follows:
1. write inline_data inode
vfs_write
new_sync_write
ext4_file_write_iter
ext4_buffered_write_iter
generic_perform_write
ext4_da_write_begin
ext4_da_write_inline_data_begin -> If inline data size too
small will allocate block to write, then mapping will has
dirty page
ext4_da_convert_inline_data_to_extent ->clear EXT4_STATE_MAY_INLINE_DATA
2. fallocate
do_vfs_ioctl
ioctl_preallocate
vfs_fallocate
ext4_fallocate
ext4_convert_inline_data
ext4_convert_inline_data_nolock
ext4_map_blocks -> fail will goto restore data
ext4_restore_inline_data
ext4_create_inline_data
ext4_write_inline_data
ext4_set_inode_state -> set inode EXT4_STATE_MAY_INLINE_DATA
3. writepages
__ext4_ioctl
ext4_alloc_da_blocks
filemap_flush
filemap_fdatawrite_wbc
do_writepages
ext4_writepages
if (ext4_has_inline_data(inode))
BUG_ON(ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA))
The root cause of this issue is we destory inline data until call
ext4_writepages under delay allocation mode. But there maybe already
convert from inline to extent. To solve this issue, we call
filemap_flush first..
Cc: stable@kernel.org
Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220516122634.1690462-1-yebin10@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-09 10:23:20 +02:00
..
2022-02-08 18:34:04 +01:00
2022-06-09 10:22:40 +02:00
2021-10-20 21:09:02 -04:00
2021-08-19 09:02:55 +09:00
2022-06-09 10:22:30 +02:00
2021-08-27 13:34:02 +01:00
2022-05-18 10:26:55 +02:00
2022-06-09 10:22:43 +02:00
2022-03-02 11:48:02 +01:00
2021-11-18 19:16:11 +01:00
2022-01-27 11:03:55 +01:00
2022-02-01 17:27:01 +01:00
2022-01-27 11:04:23 +01:00
2022-05-01 17:22:32 +02:00
2022-06-06 08:43:37 +02:00
2022-04-08 14:23:35 +02:00
2022-06-09 10:23:20 +02:00
2022-06-09 10:23:18 +02:00
2022-06-09 10:22:42 +02:00
2021-10-04 22:13:12 +01:00
2022-05-01 17:22:28 +02:00
2022-06-09 10:22:40 +02:00
2021-07-15 10:13:49 -07:00
2021-08-26 22:28:02 +02:00
2021-07-27 11:00:36 +02:00
2022-06-09 10:23:11 +02:00
2022-06-09 10:22:55 +02:00
2021-11-12 15:05:50 +01:00
2022-04-27 14:39:02 +02:00
2022-04-08 14:22:53 +02:00
2022-06-09 10:22:41 +02:00
2021-10-04 10:27:18 +02:00
2022-05-09 09:14:40 +02:00
2022-02-05 12:38:57 +01:00
2022-04-13 20:59:10 +02:00
2021-12-29 12:28:59 +01:00
2022-06-09 10:23:17 +02:00
2021-10-04 22:02:17 +01:00
2022-06-09 10:23:12 +02:00
2022-05-25 09:57:26 +02:00
2022-06-09 10:22:50 +02:00
2022-05-01 17:22:28 +02:00
2022-06-09 10:22:28 +02:00
2022-04-08 14:22:56 +02:00
2022-01-20 09:13:13 +01:00
2022-02-05 12:38:59 +01:00
2022-06-09 10:23:10 +02:00
2022-04-08 14:23:01 +02:00
2021-09-21 08:36:48 -07:00
2022-02-23 12:03:06 +01:00
2021-09-03 15:33:47 -07:00
2021-12-14 10:57:12 +01:00
2021-08-16 10:50:32 -06:00
2021-08-06 13:05:28 +02:00
2022-03-02 11:48:05 +01:00
2022-04-08 14:24:08 +02:00
2022-05-15 20:18:52 +02:00
2021-08-19 09:02:55 +09:00
2021-09-27 11:26:21 -07:00
2021-09-22 10:56:34 -07:00
2022-05-01 17:22:32 +02:00
2022-05-09 09:14:41 +02:00
2021-12-14 10:57:22 +01:00
2021-11-25 09:48:46 +01:00
2021-08-18 22:08:24 +02:00
2021-09-05 10:15:05 -07:00
2022-04-08 14:24:17 +02:00
2022-04-08 14:24:18 +02:00
2022-06-09 10:22:26 +02:00
2022-04-08 14:22:54 +02:00
2022-04-08 14:24:18 +02:00
2021-09-02 10:07:29 -07:00
2022-06-09 10:23:09 +02:00
2021-09-03 09:58:10 -07:00
2021-09-06 07:20:56 -04:00
2021-09-09 13:25:49 -07:00
2022-04-08 14:23:01 +02:00
2021-09-03 10:08:28 -07:00
2022-05-18 10:26:57 +02:00
2022-04-08 14:23:54 +02:00
2021-08-23 01:25:40 -04:00
2022-01-20 09:13:14 +01:00
2021-09-07 16:07:47 -04:00
2022-06-09 10:23:18 +02:00
2021-11-25 09:49:08 +01:00
2022-04-27 14:38:50 +02:00
2022-05-25 09:57:21 +02:00
2021-12-22 09:32:51 +01:00
2021-08-29 07:55:55 -06:00
2022-05-25 09:57:26 +02:00
2021-09-12 10:10:21 -07:00
2021-07-25 22:33:03 -07:00
2021-10-18 20:22:03 -10:00
2021-09-07 11:21:48 -07:00
2021-09-12 10:10:21 -07:00
2022-04-27 14:38:57 +02:00
2022-01-05 12:42:39 +01:00
2021-11-18 19:17:17 +01:00
2022-06-06 08:43:37 +02:00
2021-08-18 22:08:24 +02:00
2021-08-24 07:52:45 -04:00
2021-08-23 06:15:36 -04:00
2022-01-29 10:58:25 +01:00
2021-07-19 17:18:48 -07:00
2021-12-14 10:57:15 +01:00
2022-04-27 14:38:57 +02:00
2022-02-23 12:03:05 +01:00
2022-04-27 14:38:50 +02:00
2021-08-10 17:57:22 +02:00
2021-10-18 20:22:02 -10:00