* [f2fs-dev] [PATCH] f2fs: fix to avoid inconsistent quota data
@ 2021-01-28 9:02 Chao Yu
2021-01-29 6:35 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2021-01-28 9:02 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
From: Yi Chen <chenyi77@huawei.com>
Occasionally, quota data may be corrupted detected by fsck:
Info: checkpoint state = 45 : crc compacted_summary unmount
[QUOTA WARNING] Usage inconsistent for ID 0:actual (1543036928, 762) != expected (1543032832, 762)
[ASSERT] (fsck_chk_quota_files:1986) --> Quota file is missing or invalid quota file content found.
[QUOTA WARNING] Usage inconsistent for ID 0:actual (1352478720, 344) != expected (1352474624, 344)
[ASSERT] (fsck_chk_quota_files:1986) --> Quota file is missing or invalid quota file content found.
[FSCK] Unreachable nat entries [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking [Ok..]
[FSCK] Hard link checking for regular file [Ok..] [0x0]
[FSCK] valid_block_count matching with CP [Ok..] [0xdf299]
[FSCK] valid_node_count matcing with CP (de lookup) [Ok..] [0x2b01]
[FSCK] valid_node_count matcing with CP (nat lookup) [Ok..] [0x2b01]
[FSCK] valid_inode_count matched with CP [Ok..] [0x2665]
[FSCK] free segment_count matched with CP [Ok..] [0xcb04]
[FSCK] next block offset is free [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs [Fail]
The root cause is:
If we open file w/ readonly flag, disk quota info won't be initialized
for this file, however, following mmap() will force to convert inline
inode via f2fs_convert_inline_inode(), which may increase block usage
for this inode w/o updating quota data, it causes inconsistent disk quota
info.
The issue will happen in following stack:
open(file, O_RDONLY)
mmap(file)
- f2fs_convert_inline_inode
- f2fs_convert_inline_page
- f2fs_reserve_block
- f2fs_reserve_new_block
- f2fs_reserve_new_blocks
- f2fs_i_blocks_write
- dquot_claim_block
inode->i_blocks increase, but the dqb_curspace keep the size for the dquots
is NULL.
To fix this issue, let's call dquot_initialize() anyway in both
f2fs_truncate() and f2fs_convert_inline_inode() functions to avoid potential
inconsistent quota data issue.
Fixes: 0abd675e97e6 ("f2fs: support plain user/group quota")
Signed-off-by: Daiyue Zhang <zhangdaiyue1@huawei.com>
Signed-off-by: Dehe Gu <gudehe@huawei.com>
Signed-off-by: Junchao Jiang <jiangjunchao1@huawei.com>
Signed-off-by: Ge Qiu <qiuge@huawei.com>
Signed-off-by: Yi Chen <chenyi77@huawei.com>
---
fs/f2fs/file.c | 4 ++++
fs/f2fs/inline.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 7db27c81d034..00b2ce47fa37 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -771,6 +771,10 @@ int f2fs_truncate(struct inode *inode)
return -EIO;
}
+ err = dquot_initialize(inode);
+ if (err)
+ return err;
+
/* we should check inline_data size */
if (!f2fs_may_inline_data(inode)) {
err = f2fs_convert_inline_inode(inode);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 806ebabf5870..993caefcd2bb 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -192,6 +192,10 @@ int f2fs_convert_inline_inode(struct inode *inode)
f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb))
return 0;
+ err = dquot_initialize(inode);
+ if (err)
+ return err;
+
page = f2fs_grab_cache_page(inode->i_mapping, 0, false);
if (!page)
return -ENOMEM;
--
2.29.2
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix to avoid inconsistent quota data
2021-01-28 9:02 [f2fs-dev] [PATCH] f2fs: fix to avoid inconsistent quota data Chao Yu
@ 2021-01-29 6:35 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2021-01-29 6:35 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
On 2021/1/28 17:02, Chao Yu wrote:
> From: Yi Chen <chenyi77@huawei.com>
>
> Occasionally, quota data may be corrupted detected by fsck:
>
> Info: checkpoint state = 45 : crc compacted_summary unmount
> [QUOTA WARNING] Usage inconsistent for ID 0:actual (1543036928, 762) != expected (1543032832, 762)
> [ASSERT] (fsck_chk_quota_files:1986) --> Quota file is missing or invalid quota file content found.
> [QUOTA WARNING] Usage inconsistent for ID 0:actual (1352478720, 344) != expected (1352474624, 344)
> [ASSERT] (fsck_chk_quota_files:1986) --> Quota file is missing or invalid quota file content found.
>
> [FSCK] Unreachable nat entries [Ok..] [0x0]
> [FSCK] SIT valid block bitmap checking [Ok..]
> [FSCK] Hard link checking for regular file [Ok..] [0x0]
> [FSCK] valid_block_count matching with CP [Ok..] [0xdf299]
> [FSCK] valid_node_count matcing with CP (de lookup) [Ok..] [0x2b01]
> [FSCK] valid_node_count matcing with CP (nat lookup) [Ok..] [0x2b01]
> [FSCK] valid_inode_count matched with CP [Ok..] [0x2665]
> [FSCK] free segment_count matched with CP [Ok..] [0xcb04]
> [FSCK] next block offset is free [Ok..]
> [FSCK] fixing SIT types
> [FSCK] other corrupted bugs [Fail]
>
> The root cause is:
> If we open file w/ readonly flag, disk quota info won't be initialized
> for this file, however, following mmap() will force to convert inline
> inode via f2fs_convert_inline_inode(), which may increase block usage
> for this inode w/o updating quota data, it causes inconsistent disk quota
> info.
>
> The issue will happen in following stack:
> open(file, O_RDONLY)
> mmap(file)
> - f2fs_convert_inline_inode
> - f2fs_convert_inline_page
> - f2fs_reserve_block
> - f2fs_reserve_new_block
> - f2fs_reserve_new_blocks
> - f2fs_i_blocks_write
> - dquot_claim_block
> inode->i_blocks increase, but the dqb_curspace keep the size for the dquots
> is NULL.
>
> To fix this issue, let's call dquot_initialize() anyway in both
> f2fs_truncate() and f2fs_convert_inline_inode() functions to avoid potential
> inconsistent quota data issue.
>
> Fixes: 0abd675e97e6 ("f2fs: support plain user/group quota")
> Signed-off-by: Daiyue Zhang <zhangdaiyue1@huawei.com>
> Signed-off-by: Dehe Gu <gudehe@huawei.com>
> Signed-off-by: Junchao Jiang <jiangjunchao1@huawei.com>
> Signed-off-by: Ge Qiu <qiuge@huawei.com>
> Signed-off-by: Yi Chen <chenyi77@huawei.com>
[Chao Yu: clean up commit message a bit]
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-29 6:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 9:02 [f2fs-dev] [PATCH] f2fs: fix to avoid inconsistent quota data Chao Yu
2021-01-29 6:35 ` Chao Yu
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).