summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-01-04 07:39:42 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:52 +0300
commit46eea9cb9ec14684d1b6e90c17db1ac896f26a5b (patch)
treef5c97d1335afb29309f659b1eb5715e81d4e555d /fs
parent7ffb6a7ec6712eb1ba84a80137c2f712e67c4171 (diff)
downloadlinux-46eea9cb9ec14684d1b6e90c17db1ac896f26a5b.tar.xz
bcachefs: Fix move_ctxt_wait_event()
We shouldn't be evaluating cond again if it already returned true. This fixes a bug when this helper is used for taking nocow locks. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/move.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/bcachefs/move.h b/fs/bcachefs/move.h
index a2822d4a4afb..34b9cadef6b5 100644
--- a/fs/bcachefs/move.h
+++ b/fs/bcachefs/move.h
@@ -28,14 +28,18 @@ struct moving_context {
wait_queue_head_t wait;
};
-#define move_ctxt_wait_event(_ctxt, _trans, _cond) \
-do { \
- bch2_moving_ctxt_do_pending_writes(_ctxt, _trans); \
- \
- if (_cond) \
- break; \
- __wait_event((_ctxt)->wait, \
- bch2_moving_ctxt_next_pending_write(_ctxt) || (_cond));\
+#define move_ctxt_wait_event(_ctxt, _trans, _cond) \
+do { \
+ bool cond_finished = false; \
+ bch2_moving_ctxt_do_pending_writes(_ctxt, _trans); \
+ \
+ if (_cond) \
+ break; \
+ __wait_event((_ctxt)->wait, \
+ bch2_moving_ctxt_next_pending_write(_ctxt) || \
+ (cond_finished = (_cond))); \
+ if (cond_finished) \
+ break; \
} while (1)
typedef bool (*move_pred_fn)(struct bch_fs *, void *, struct bkey_s_c,