* [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
@ 2025-05-12 11:54 ` Chao Yu
0 siblings, 0 replies; 14+ messages in thread
From: Chao Yu @ 2025-05-12 11:54 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu
Add f2fs_bug_on() to check whether memory preallocation will fail or
not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/checkpoint.c | 4 +++-
fs/f2fs/node.c | 7 +++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index e7907858eb70..3f223bade520 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
{
struct inode_management *im = &sbi->im[type];
struct ino_entry *e = NULL, *new = NULL;
+ int ret;
if (type == FLUSH_INO) {
rcu_read_lock();
@@ -516,7 +517,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
new = f2fs_kmem_cache_alloc(ino_entry_slab,
GFP_NOFS, true, NULL);
- radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+ ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+ f2fs_bug_on(sbi, ret);
spin_lock(&im->ino_lock);
e = radix_tree_lookup(&im->ino_root, ino);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 3f6b8037d25f..88d3032236cb 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct free_nid *i, *e;
struct nat_entry *ne;
- int err = -EINVAL;
+ int err;
bool ret = false;
/* 0 nid should not be used */
@@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
i->nid = nid;
i->state = FREE_NID;
- radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+ err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+ f2fs_bug_on(sbi, err);
+
+ err = -EINVAL;
spin_lock(&nm_i->nid_list_lock);
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [f2fs-dev] [PATCH 2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
2025-05-12 11:54 ` Chao Yu
@ 2025-05-12 11:54 ` Chao Yu
-1 siblings, 0 replies; 14+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-05-12 11:54 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
mapping_read_folio_gfp() will return a folio, it should always be
uptodate, let's check folio uptodate status to detect any potenial
bug.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/super.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 0ee783224953..ea207a9edc10 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2973,6 +2973,17 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
goto repeat;
}
+ /*
+ * should never happen, just leave f2fs_bug_on() here to catch
+ * any potential bug.
+ */
+ if (unlikely(!folio_test_uptodate(folio))) {
+ f2fs_folio_put(folio, true);
+ set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
+ f2fs_bug_on(F2FS_SB(sb), 1);
+ return -EIO;
+ }
+
memcpy_from_folio(data, folio, offset, tocopy);
f2fs_folio_put(folio, true);
--
2.49.0
_______________________________________________
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] 14+ messages in thread* [PATCH 2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
@ 2025-05-12 11:54 ` Chao Yu
0 siblings, 0 replies; 14+ messages in thread
From: Chao Yu @ 2025-05-12 11:54 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu
mapping_read_folio_gfp() will return a folio, it should always be
uptodate, let's check folio uptodate status to detect any potenial
bug.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/super.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 0ee783224953..ea207a9edc10 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2973,6 +2973,17 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
goto repeat;
}
+ /*
+ * should never happen, just leave f2fs_bug_on() here to catch
+ * any potential bug.
+ */
+ if (unlikely(!folio_test_uptodate(folio))) {
+ f2fs_folio_put(folio, true);
+ set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
+ f2fs_bug_on(F2FS_SB(sb), 1);
+ return -EIO;
+ }
+
memcpy_from_folio(data, folio, offset, tocopy);
f2fs_folio_put(folio, true);
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [f2fs-dev] [PATCH 2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
2025-05-12 11:54 ` Chao Yu
@ 2025-05-12 15:27 ` Jaegeuk Kim
-1 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-05-12 15:27 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel
On 05/12, Chao Yu wrote:
> mapping_read_folio_gfp() will return a folio, it should always be
> uptodate, let's check folio uptodate status to detect any potenial
> bug.
If it's supposed to be uptodate, can you add f2fs_bug_on() only?
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fs/f2fs/super.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 0ee783224953..ea207a9edc10 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2973,6 +2973,17 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
> goto repeat;
> }
>
> + /*
> + * should never happen, just leave f2fs_bug_on() here to catch
> + * any potential bug.
> + */
> + if (unlikely(!folio_test_uptodate(folio))) {
> + f2fs_folio_put(folio, true);
> + set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
> + f2fs_bug_on(F2FS_SB(sb), 1);
> + return -EIO;
> + }
> +
> memcpy_from_folio(data, folio, offset, tocopy);
> f2fs_folio_put(folio, true);
>
> --
> 2.49.0
_______________________________________________
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] 14+ messages in thread* Re: [PATCH 2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
@ 2025-05-12 15:27 ` Jaegeuk Kim
0 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2025-05-12 15:27 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel
On 05/12, Chao Yu wrote:
> mapping_read_folio_gfp() will return a folio, it should always be
> uptodate, let's check folio uptodate status to detect any potenial
> bug.
If it's supposed to be uptodate, can you add f2fs_bug_on() only?
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fs/f2fs/super.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 0ee783224953..ea207a9edc10 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2973,6 +2973,17 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
> goto repeat;
> }
>
> + /*
> + * should never happen, just leave f2fs_bug_on() here to catch
> + * any potential bug.
> + */
> + if (unlikely(!folio_test_uptodate(folio))) {
> + f2fs_folio_put(folio, true);
> + set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
> + f2fs_bug_on(F2FS_SB(sb), 1);
> + return -EIO;
> + }
> +
> memcpy_from_folio(data, folio, offset, tocopy);
> f2fs_folio_put(folio, true);
>
> --
> 2.49.0
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [f2fs-dev] [PATCH 2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
2025-05-12 15:27 ` Jaegeuk Kim
@ 2025-05-13 2:45 ` Chao Yu
-1 siblings, 0 replies; 14+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-05-13 2:45 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel
On 5/12/25 23:27, Jaegeuk Kim wrote:
> On 05/12, Chao Yu wrote:
>> mapping_read_folio_gfp() will return a folio, it should always be
>> uptodate, let's check folio uptodate status to detect any potenial
>> bug.
>
> If it's supposed to be uptodate, can you add f2fs_bug_on() only?
Sure.
Thanks,
>
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> fs/f2fs/super.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 0ee783224953..ea207a9edc10 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2973,6 +2973,17 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
>> goto repeat;
>> }
>>
>> + /*
>> + * should never happen, just leave f2fs_bug_on() here to catch
>> + * any potential bug.
>> + */
>> + if (unlikely(!folio_test_uptodate(folio))) {
>> + f2fs_folio_put(folio, true);
>> + set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
>> + f2fs_bug_on(F2FS_SB(sb), 1);
>> + return -EIO;
>> + }
>> +
>> memcpy_from_folio(data, folio, offset, tocopy);
>> f2fs_folio_put(folio, true);
>>
>> --
>> 2.49.0
_______________________________________________
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] 14+ messages in thread* Re: [PATCH 2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
@ 2025-05-13 2:45 ` Chao Yu
0 siblings, 0 replies; 14+ messages in thread
From: Chao Yu @ 2025-05-13 2:45 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: chao, linux-f2fs-devel, linux-kernel
On 5/12/25 23:27, Jaegeuk Kim wrote:
> On 05/12, Chao Yu wrote:
>> mapping_read_folio_gfp() will return a folio, it should always be
>> uptodate, let's check folio uptodate status to detect any potenial
>> bug.
>
> If it's supposed to be uptodate, can you add f2fs_bug_on() only?
Sure.
Thanks,
>
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> fs/f2fs/super.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 0ee783224953..ea207a9edc10 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2973,6 +2973,17 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
>> goto repeat;
>> }
>>
>> + /*
>> + * should never happen, just leave f2fs_bug_on() here to catch
>> + * any potential bug.
>> + */
>> + if (unlikely(!folio_test_uptodate(folio))) {
>> + f2fs_folio_put(folio, true);
>> + set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
>> + f2fs_bug_on(F2FS_SB(sb), 1);
>> + return -EIO;
>> + }
>> +
>> memcpy_from_folio(data, folio, offset, tocopy);
>> f2fs_folio_put(folio, true);
>>
>> --
>> 2.49.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
2025-05-12 11:54 ` Chao Yu
@ 2025-05-12 15:26 ` Jaegeuk Kim
-1 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-05-12 15:26 UTC (permalink / raw)
To: Chao Yu, g; +Cc: linux-kernel, linux-f2fs-devel
On 05/12, Chao Yu wrote:
> Add f2fs_bug_on() to check whether memory preallocation will fail or
> not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).
Are we getting a bug?
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fs/f2fs/checkpoint.c | 4 +++-
> fs/f2fs/node.c | 7 +++++--
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index e7907858eb70..3f223bade520 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
> {
> struct inode_management *im = &sbi->im[type];
> struct ino_entry *e = NULL, *new = NULL;
> + int ret;
>
> if (type == FLUSH_INO) {
> rcu_read_lock();
> @@ -516,7 +517,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
> new = f2fs_kmem_cache_alloc(ino_entry_slab,
> GFP_NOFS, true, NULL);
>
> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + f2fs_bug_on(sbi, ret);
>
> spin_lock(&im->ino_lock);
> e = radix_tree_lookup(&im->ino_root, ino);
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 3f6b8037d25f..88d3032236cb 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
> struct f2fs_nm_info *nm_i = NM_I(sbi);
> struct free_nid *i, *e;
> struct nat_entry *ne;
> - int err = -EINVAL;
> + int err;
> bool ret = false;
>
> /* 0 nid should not be used */
> @@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
> i->nid = nid;
> i->state = FREE_NID;
>
> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + f2fs_bug_on(sbi, err);
> +
> + err = -EINVAL;
>
> spin_lock(&nm_i->nid_list_lock);
>
> --
> 2.49.0
_______________________________________________
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] 14+ messages in thread* Re: [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
@ 2025-05-12 15:26 ` Jaegeuk Kim
0 siblings, 0 replies; 14+ messages in thread
From: Jaegeuk Kim @ 2025-05-12 15:26 UTC (permalink / raw)
To: Chao Yu, g; +Cc: linux-f2fs-devel, linux-kernel
On 05/12, Chao Yu wrote:
> Add f2fs_bug_on() to check whether memory preallocation will fail or
> not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).
Are we getting a bug?
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fs/f2fs/checkpoint.c | 4 +++-
> fs/f2fs/node.c | 7 +++++--
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index e7907858eb70..3f223bade520 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
> {
> struct inode_management *im = &sbi->im[type];
> struct ino_entry *e = NULL, *new = NULL;
> + int ret;
>
> if (type == FLUSH_INO) {
> rcu_read_lock();
> @@ -516,7 +517,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
> new = f2fs_kmem_cache_alloc(ino_entry_slab,
> GFP_NOFS, true, NULL);
>
> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + f2fs_bug_on(sbi, ret);
>
> spin_lock(&im->ino_lock);
> e = radix_tree_lookup(&im->ino_root, ino);
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 3f6b8037d25f..88d3032236cb 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
> struct f2fs_nm_info *nm_i = NM_I(sbi);
> struct free_nid *i, *e;
> struct nat_entry *ne;
> - int err = -EINVAL;
> + int err;
> bool ret = false;
>
> /* 0 nid should not be used */
> @@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
> i->nid = nid;
> i->state = FREE_NID;
>
> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
> + f2fs_bug_on(sbi, err);
> +
> + err = -EINVAL;
>
> spin_lock(&nm_i->nid_list_lock);
>
> --
> 2.49.0
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [f2fs-dev] [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
2025-05-12 15:26 ` Jaegeuk Kim
@ 2025-05-13 2:44 ` Chao Yu
-1 siblings, 0 replies; 14+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-05-13 2:44 UTC (permalink / raw)
To: Jaegeuk Kim, g; +Cc: linux-kernel, linux-f2fs-devel
On 5/12/25 23:26, Jaegeuk Kim wrote:
> On 05/12, Chao Yu wrote:
>> Add f2fs_bug_on() to check whether memory preallocation will fail or
>> not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).
>
> Are we getting a bug?
No, I'm worried about potential issue from add_free_nid() can cause
node footer corruption issue, so I want to use f2fs_bug_on() to check
whether there is caused by any bug from MM from now on.
Thanks,
>
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> fs/f2fs/checkpoint.c | 4 +++-
>> fs/f2fs/node.c | 7 +++++--
>> 2 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>> index e7907858eb70..3f223bade520 100644
>> --- a/fs/f2fs/checkpoint.c
>> +++ b/fs/f2fs/checkpoint.c
>> @@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
>> {
>> struct inode_management *im = &sbi->im[type];
>> struct ino_entry *e = NULL, *new = NULL;
>> + int ret;
>>
>> if (type == FLUSH_INO) {
>> rcu_read_lock();
>> @@ -516,7 +517,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
>> new = f2fs_kmem_cache_alloc(ino_entry_slab,
>> GFP_NOFS, true, NULL);
>>
>> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + f2fs_bug_on(sbi, ret);
>>
>> spin_lock(&im->ino_lock);
>> e = radix_tree_lookup(&im->ino_root, ino);
>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>> index 3f6b8037d25f..88d3032236cb 100644
>> --- a/fs/f2fs/node.c
>> +++ b/fs/f2fs/node.c
>> @@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
>> struct f2fs_nm_info *nm_i = NM_I(sbi);
>> struct free_nid *i, *e;
>> struct nat_entry *ne;
>> - int err = -EINVAL;
>> + int err;
>> bool ret = false;
>>
>> /* 0 nid should not be used */
>> @@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
>> i->nid = nid;
>> i->state = FREE_NID;
>>
>> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + f2fs_bug_on(sbi, err);
>> +
>> + err = -EINVAL;
>>
>> spin_lock(&nm_i->nid_list_lock);
>>
>> --
>> 2.49.0
_______________________________________________
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] 14+ messages in thread* Re: [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
@ 2025-05-13 2:44 ` Chao Yu
0 siblings, 0 replies; 14+ messages in thread
From: Chao Yu @ 2025-05-13 2:44 UTC (permalink / raw)
To: Jaegeuk Kim, g; +Cc: chao, linux-f2fs-devel, linux-kernel
On 5/12/25 23:26, Jaegeuk Kim wrote:
> On 05/12, Chao Yu wrote:
>> Add f2fs_bug_on() to check whether memory preallocation will fail or
>> not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).
>
> Are we getting a bug?
No, I'm worried about potential issue from add_free_nid() can cause
node footer corruption issue, so I want to use f2fs_bug_on() to check
whether there is caused by any bug from MM from now on.
Thanks,
>
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> fs/f2fs/checkpoint.c | 4 +++-
>> fs/f2fs/node.c | 7 +++++--
>> 2 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>> index e7907858eb70..3f223bade520 100644
>> --- a/fs/f2fs/checkpoint.c
>> +++ b/fs/f2fs/checkpoint.c
>> @@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
>> {
>> struct inode_management *im = &sbi->im[type];
>> struct ino_entry *e = NULL, *new = NULL;
>> + int ret;
>>
>> if (type == FLUSH_INO) {
>> rcu_read_lock();
>> @@ -516,7 +517,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
>> new = f2fs_kmem_cache_alloc(ino_entry_slab,
>> GFP_NOFS, true, NULL);
>>
>> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + f2fs_bug_on(sbi, ret);
>>
>> spin_lock(&im->ino_lock);
>> e = radix_tree_lookup(&im->ino_root, ino);
>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>> index 3f6b8037d25f..88d3032236cb 100644
>> --- a/fs/f2fs/node.c
>> +++ b/fs/f2fs/node.c
>> @@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
>> struct f2fs_nm_info *nm_i = NM_I(sbi);
>> struct free_nid *i, *e;
>> struct nat_entry *ne;
>> - int err = -EINVAL;
>> + int err;
>> bool ret = false;
>>
>> /* 0 nid should not be used */
>> @@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
>> i->nid = nid;
>> i->state = FREE_NID;
>>
>> - radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
>> + f2fs_bug_on(sbi, err);
>> +
>> + err = -EINVAL;
>>
>> spin_lock(&nm_i->nid_list_lock);
>>
>> --
>> 2.49.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
2025-05-12 11:54 ` Chao Yu
@ 2025-05-14 15:40 ` patchwork-bot+f2fs
-1 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2025-05-14 15:40 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Mon, 12 May 2025 19:54:41 +0800 you wrote:
> Add f2fs_bug_on() to check whether memory preallocation will fail or
> not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fs/f2fs/checkpoint.c | 4 +++-
> fs/f2fs/node.c | 7 +++++--
> 2 files changed, 8 insertions(+), 3 deletions(-)
Here is the summary with links:
- [f2fs-dev,1/2] f2fs: add f2fs_bug_on() to detect potential bug
https://git.kernel.org/jaegeuk/f2fs/c/0e799933a4e8
- [f2fs-dev,2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
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] 14+ messages in thread* Re: [f2fs-dev] [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
@ 2025-05-14 15:40 ` patchwork-bot+f2fs
0 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+f2fs @ 2025-05-14 15:40 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Mon, 12 May 2025 19:54:41 +0800 you wrote:
> Add f2fs_bug_on() to check whether memory preallocation will fail or
> not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fs/f2fs/checkpoint.c | 4 +++-
> fs/f2fs/node.c | 7 +++++--
> 2 files changed, 8 insertions(+), 3 deletions(-)
Here is the summary with links:
- [f2fs-dev,1/2] f2fs: add f2fs_bug_on() to detect potential bug
https://git.kernel.org/jaegeuk/f2fs/c/0e799933a4e8
- [f2fs-dev,2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read()
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 14+ messages in thread