On 2024/2/20 13:34, Zhiguo Niu wrote:
On Tue, Feb 20, 2024 at 10:36 AM Chao Yu <c...@kernel.org> wrote:

On 2024/2/19 22:36, Chao Yu wrote:
Please think about how to optimize this, which is really ugly now
---
   fs/f2fs/checkpoint.c | 12 ++++++++----
   1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 87b7c988c8ca..089c26b80be3 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -135,7 +135,7 @@ struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, 
pgoff_t index)
   }

   static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
-                                                       int type)
+                                               int type, bool *record_error)
   {
         struct seg_entry *se;
         unsigned int segno, offset;
@@ -160,6 +160,7 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, 
block_t blkaddr,
                          blkaddr, exist);
                 set_sbi_flag(sbi, SBI_NEED_FSCK);
                 dump_stack();
+               *record_error = true;
         }

         return exist;
@@ -209,10 +210,13 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info 
*sbi,
                         dump_stack();
                         goto err;
                 } else {
-                       valid = __is_bitmap_valid(sbi, blkaddr, type);
-                       if ((!valid && type != DATA_GENERIC_ENHANCE_UPDATE) ||
-                               (valid && type == DATA_GENERIC_ENHANCE_UPDATE))
+                       bool record_error = false;
+
+                       valid = __is_bitmap_valid(sbi, blkaddr, type,
+                                                       &record_error);
+                       if (!valid || record_error)
if   type == DATA_GENERIC_ENHANCE_UPDATE && bitmap check invalid,  it
is a OK case, but !valid
will goto do error handling.

Yes, it looks we need to remove !valid condition to avoid error handling,
and assign record_error correctly inside __is_bitmap_valid() for all the
cases.

I think do f2fs_handle_error in __is_bitmap_valid is a good way.

Let me revise the diff patch for comments.

Thanks,


                                 goto err;
+                       return valid;
                 }
                 break;
         case META_GENERIC:
--
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to