bcachefs: Fix nocow write path closure bug
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 19 Mar 2023 17:01:06 +0000 (13:01 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:58 +0000 (17:09 -0400)
With regular waitlists, we need to ensure we always call finish_wait().
With closures, the equivalent is that we need to call closure_sync()
before returning with a stack-allocated closure.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/io.c

index ad22557197a666b3f648d7e4c3e6f532855a0111..cc2dfcf16deee36ec4c80413f908afc80fa40e1e 100644 (file)
@@ -453,13 +453,13 @@ retry:
                                opts.data_replicas,
                                opts.data_replicas,
                                RESERVE_none, 0, &cl, &wp);
-               if (bch2_err_matches(ret, BCH_ERR_operation_blocked)) {
+               if (ret) {
                        bch2_trans_unlock(trans);
                        closure_sync(&cl);
-                       goto retry;
-               }
-               if (ret)
+                       if (bch2_err_matches(ret, BCH_ERR_operation_blocked))
+                               goto retry;
                        return ret;
+               }
 
                sectors = min(sectors, wp->sectors_free);
                sectors_allocated = sectors;