[PATCH] ext4: EXT4_I(sbi->s_buddy_cache)->i_state_flags is not initialized

Jiucheng Xu via B4 Relay posted 1 patch 1 week, 4 days ago
fs/ext4/mballoc.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] ext4: EXT4_I(sbi->s_buddy_cache)->i_state_flags is not initialized
Posted by Jiucheng Xu via B4 Relay 1 week, 4 days ago
From: Jiucheng Xu <jiucheng.xu@amlogic.com>

The i_state_flags originates from an inode that was previously
destroyed and then allocated to s_buddy_cache; it requires
reinitialization.

The relevant log during umount is shown below:

EXT4-fs (mmcblk0p28): unmounting filesystem xxx-xxx
EXT4-fs (mmcblk0p28): Inode 1 (39878178): inode tracked as orphan!
39878178: 1411f3c7 e0182705 78cc454d ac11f000  .....'..ME.x....
da10433b: 1a2e0146 792e03d0 9c2a04d1 0c788ad3  F......y..*...x.
a91573cf: 44270388 4f4202ea 721a12ea 340cbce0  ..'D..BO...r...4
89cb2f37: 0d13f000 4f270414 1a0b01f0 4f880fe0  ......'O.......O
810e3bc2: 3f0c02f0 482b0009 02e048d0 83f43f2a  ...?..+H.H..*?..
3f37c9f7: 02880aaf 00000000 00000000 00000000  ................

Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
---
 fs/ext4/mballoc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index dbc82b65f810fed89da7fa7149d3a05de6f107d6..20b07b2bea31ea81ffbd0b4ace3a7b218c8f4dd5 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3521,6 +3521,9 @@ static int ext4_mb_init_backend(struct super_block *sb)
 	sbi->s_buddy_cache->i_ino = EXT4_BAD_INO;
 	EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
 	ext4_set_inode_mapping_order(sbi->s_buddy_cache);
+#if (BITS_PER_LONG < 64)
+	ext4_clear_state_flags(EXT4_I(sbi->s_buddy_cache));
+#endif
 
 	for (i = 0; i < ngroups; i++) {
 		cond_resched();

---
base-commit: 4f5e8e6f012349a107531b02eed5b5ace6181449
change-id: 20260126-origin-dev-9f84135b9555

Best regards,
-- 
Jiucheng Xu <jiucheng.xu@amlogic.com>
Re: [PATCH] ext4: EXT4_I(sbi->s_buddy_cache)->i_state_flags is not initialized
Posted by Jan Kara 1 week, 3 days ago
On Tue 27-01-26 17:34:10, Jiucheng Xu via B4 Relay wrote:
> From: Jiucheng Xu <jiucheng.xu@amlogic.com>
> 
> The i_state_flags originates from an inode that was previously
> destroyed and then allocated to s_buddy_cache; it requires
> reinitialization.
> 
> The relevant log during umount is shown below:
> 
> EXT4-fs (mmcblk0p28): unmounting filesystem xxx-xxx
> EXT4-fs (mmcblk0p28): Inode 1 (39878178): inode tracked as orphan!
> 39878178: 1411f3c7 e0182705 78cc454d ac11f000  .....'..ME.x....
> da10433b: 1a2e0146 792e03d0 9c2a04d1 0c788ad3  F......y..*...x.
> a91573cf: 44270388 4f4202ea 721a12ea 340cbce0  ..'D..BO...r...4
> 89cb2f37: 0d13f000 4f270414 1a0b01f0 4f880fe0  ......'O.......O
> 810e3bc2: 3f0c02f0 482b0009 02e048d0 83f43f2a  ...?..+H.H..*?..
> 3f37c9f7: 02880aaf 00000000 00000000 00000000  ................
> 
> Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>

Thanks for the patch but this should be fixed since commit 4091c8206cfd
("ext4: clear i_state_flags when alloc inode"). Can you confirm you cannot
reproduce the issue with the latest upstream kernel?

								Honza

> ---
>  fs/ext4/mballoc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index dbc82b65f810fed89da7fa7149d3a05de6f107d6..20b07b2bea31ea81ffbd0b4ace3a7b218c8f4dd5 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -3521,6 +3521,9 @@ static int ext4_mb_init_backend(struct super_block *sb)
>  	sbi->s_buddy_cache->i_ino = EXT4_BAD_INO;
>  	EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
>  	ext4_set_inode_mapping_order(sbi->s_buddy_cache);
> +#if (BITS_PER_LONG < 64)
> +	ext4_clear_state_flags(EXT4_I(sbi->s_buddy_cache));
> +#endif
>  
>  	for (i = 0; i < ngroups; i++) {
>  		cond_resched();
> 
> ---
> base-commit: 4f5e8e6f012349a107531b02eed5b5ace6181449
> change-id: 20260126-origin-dev-9f84135b9555
> 
> Best regards,
> -- 
> Jiucheng Xu <jiucheng.xu@amlogic.com>
> 
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
Re: [PATCH] ext4: EXT4_I(sbi->s_buddy_cache)->i_state_flags is not initialized
Posted by Jiucheng Xu 1 week, 3 days ago
On 1/27/2026 9:28 PM, Jan Kara wrote:
> [You don't often get email from jack@suse.cz. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> [ EXTERNAL EMAIL ]
> 
> On Tue 27-01-26 17:34:10, Jiucheng Xu via B4 Relay wrote:
>> From: Jiucheng Xu <jiucheng.xu@amlogic.com>
>>
>> The i_state_flags originates from an inode that was previously
>> destroyed and then allocated to s_buddy_cache; it requires
>> reinitialization.
>>
>> The relevant log during umount is shown below:
>>
>> EXT4-fs (mmcblk0p28): unmounting filesystem xxx-xxx
>> EXT4-fs (mmcblk0p28): Inode 1 (39878178): inode tracked as orphan!
>> 39878178: 1411f3c7 e0182705 78cc454d ac11f000  .....'..ME.x....
>> da10433b: 1a2e0146 792e03d0 9c2a04d1 0c788ad3  F......y..*...x.
>> a91573cf: 44270388 4f4202ea 721a12ea 340cbce0  ..'D..BO...r...4
>> 89cb2f37: 0d13f000 4f270414 1a0b01f0 4f880fe0  ......'O.......O
>> 810e3bc2: 3f0c02f0 482b0009 02e048d0 83f43f2a  ...?..+H.H..*?..
>> 3f37c9f7: 02880aaf 00000000 00000000 00000000  ................
>>
>> Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
> 
> Thanks for the patch but this should be fixed since commit 4091c8206cfd
> ("ext4: clear i_state_flags when alloc inode"). Can you confirm you cannot
> reproduce the issue with the latest upstream kernel?
> 
>                                                                  Honza
> 
Thanks a lot, Honza! My Android device does not support booting with the 
latest upstream kernel. It runs 6.12.58, which doesn't include commit 
4091c8206cfd. I'm certain this patch will resolve my issue.. Thanks again!

>> ---
>>   fs/ext4/mballoc.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
>> index dbc82b65f810fed89da7fa7149d3a05de6f107d6..20b07b2bea31ea81ffbd0b4ace3a7b218c8f4dd5 100644
>> --- a/fs/ext4/mballoc.c
>> +++ b/fs/ext4/mballoc.c
>> @@ -3521,6 +3521,9 @@ static int ext4_mb_init_backend(struct super_block *sb)
>>        sbi->s_buddy_cache->i_ino = EXT4_BAD_INO;
>>        EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
>>        ext4_set_inode_mapping_order(sbi->s_buddy_cache);
>> +#if (BITS_PER_LONG < 64)
>> +     ext4_clear_state_flags(EXT4_I(sbi->s_buddy_cache));
>> +#endif
>>
>>        for (i = 0; i < ngroups; i++) {
>>                cond_resched();
>>
>> ---
>> base-commit: 4f5e8e6f012349a107531b02eed5b5ace6181449
>> change-id: 20260126-origin-dev-9f84135b9555
>>
>> Best regards,
>> --
>> Jiucheng Xu <jiucheng.xu@amlogic.com>
>>
>>
>>
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR