f2fs:Fix error handling for calls to the function add_free_nid in the file node.c
PATCH RESEND 1/1 f2fs:Fix error handling for calls to the function add_free_nid in the file node.c
This fixes error handling for calls to the function add_free_nid in the functions __flush_nat_entry_set and build_free_nids to properly check if their call to this particular function return a error code and if so break out these function's for loops as we cannot continue these loops if these function calls fail in
--- fs/f2fs/node.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/f2fs/node.c +8 -4
@@ -1545,8 +1545,10 @@ static void build_free_nids(struct f2fs_sb_info *sbi)for (i =0 ; i <nats_in_cursum (sum); i++) {block_t addr =le32_to_cpu (nat_in_journal (sum, i).block_addr); nid =le32_to_cpu (nid_in_journal (sum, i)); -if (addr ==NULL_ADDR ) -add_free_nid (sbi, nid, true); +if (addr ==NULL_ADDR ) { +if (add_free_nid (sbi, nid, true) <0 ) +break ; + }else remove_free_nid (nm_i, nid); }
@@ -1879,8 +1881,10 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,__clear_nat_cache_dirty (NM_I (sbi), ne);up_write (&NM_I (sbi)->nat_tree_lock); -if (nat_get_blkaddr (ne) ==NULL_ADDR ) -add_free_nid (sbi, nid, false); +if (nat_get_blkaddr (ne) ==NULL_ADDR ) { +if (add_free_nid (sbi, nid, false) <0 ) +break ; + } }if (to_journal)
Signature · 4 lines
2.1.4 ------------------------------------------------------------------------------
Jaegeuk Kim
maintainerHello,
Quoted 16 lines · Nicholas Krause
This fixes error handling for calls to the function
add_free_nidin the functions__flush_nat_entry_setandbuild_free_nidsto properly check if their call to this particular function return a error code and if so break out these function's for loops as we cannot continue these loops if these function calls fail inSigned-off-by Nicholas Krause <[email protected]>--- fs/f2fs/node.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)fs/f2fs/node.c +0
-0
fs/f2fs/node.c static void build_free_nids(struct f2fs_sb_info *sbi) · line 1550
Quoted 8 lines
fs/f2fs/node.c +3
-2@@ -1545,8 +1545,10 @@ static void build_free_nids(struct f2fs_sb_info *sbi)for (i =0 ; i <nats_in_cursum (sum); i++) {block_t addr =le32_to_cpu (nat_in_journal (sum, i).block_addr); nid =le32_to_cpu (nid_in_journal (sum, i)); -if (addr ==NULL_ADDR ) -add_free_nid (sbi, nid, true); +if (addr ==NULL_ADDR ) { +if (add_free_nid (sbi, nid, true) <0 ) +break ;
This is not an error case, which we must not break here.
fs/f2fs/node.c static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, · line 1886
Quoted 13 lines
fs/f2fs/node.c +4
-2+ }else remove_free_nid (nm_i, nid); }@@ -1879,8 +1881,10 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,__clear_nat_cache_dirty (NM_I (sbi), ne);up_write (&NM_I (sbi)->nat_tree_lock); -if (nat_get_blkaddr (ne) ==NULL_ADDR ) -add_free_nid (sbi, nid, false); +if (nat_get_blkaddr (ne) ==NULL_ADDR ) { +if (add_free_nid (sbi, nid, false) <0 ) +break ;
ditto.
Thanks,
Quoted 6 lines
fs/f2fs/node.c +1
-0+ } }if (to_journal)Signature · 1 line
2.1.4