bcachefs: Always flush write buffer in delete_dead_inodes()
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 11 Mar 2024 03:00:23 +0000 (23:00 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 14 Mar 2024 01:22:26 +0000 (21:22 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/inode.c

index a3139bb66f77e280d76e88e0bb61c9f732eccc7c..2b5e06770ab39ea0844342d6298b5ab37f26667d 100644 (file)
@@ -1181,6 +1181,15 @@ int bch2_delete_dead_inodes(struct bch_fs *c)
        bool need_another_pass;
        int ret;
 again:
+       /*
+        * if we ran check_inodes() unlinked inodes will have already been
+        * cleaned up but the write buffer will be out of sync; therefore we
+        * alway need a write buffer flush
+        */
+       ret = bch2_btree_write_buffer_flush_sync(trans);
+       if (ret)
+               goto err;
+
        need_another_pass = false;
 
        /*
@@ -1213,12 +1222,8 @@ again:
                ret;
        }));
 
-       if (!ret && need_another_pass) {
-               ret = bch2_btree_write_buffer_flush_sync(trans);
-               if (ret)
-                       goto err;
+       if (!ret && need_another_pass)
                goto again;
-       }
 err:
        bch2_trans_put(trans);
        return ret;