|
12 | 12 | #include "journal.h" |
13 | 13 | #include "lru.h" |
14 | 14 | #include "logged_ops.h" |
| 15 | +#include "movinggc.h" |
15 | 16 | #include "rebalance.h" |
16 | 17 | #include "recovery.h" |
17 | 18 | #include "recovery_passes.h" |
@@ -262,49 +263,45 @@ int bch2_run_recovery_passes(struct bch_fs *c) |
262 | 263 | */ |
263 | 264 | c->opts.recovery_passes_exclude &= ~BCH_RECOVERY_PASS_set_may_go_rw; |
264 | 265 |
|
265 | | - while (c->curr_recovery_pass < ARRAY_SIZE(recovery_pass_fns) && !ret) { |
266 | | - c->next_recovery_pass = c->curr_recovery_pass + 1; |
| 266 | + spin_lock_irq(&c->recovery_pass_lock); |
267 | 267 |
|
268 | | - spin_lock_irq(&c->recovery_pass_lock); |
| 268 | + while (c->curr_recovery_pass < ARRAY_SIZE(recovery_pass_fns) && !ret) { |
269 | 269 | unsigned pass = c->curr_recovery_pass; |
270 | 270 |
|
| 271 | + c->next_recovery_pass = pass + 1; |
| 272 | + |
271 | 273 | if (c->opts.recovery_pass_last && |
272 | | - c->curr_recovery_pass > c->opts.recovery_pass_last) { |
273 | | - spin_unlock_irq(&c->recovery_pass_lock); |
| 274 | + c->curr_recovery_pass > c->opts.recovery_pass_last) |
274 | 275 | break; |
275 | | - } |
276 | 276 |
|
277 | | - if (!should_run_recovery_pass(c, pass)) { |
278 | | - c->curr_recovery_pass++; |
279 | | - c->recovery_pass_done = max(c->recovery_pass_done, pass); |
| 277 | + if (should_run_recovery_pass(c, pass)) { |
280 | 278 | spin_unlock_irq(&c->recovery_pass_lock); |
281 | | - continue; |
282 | | - } |
283 | | - spin_unlock_irq(&c->recovery_pass_lock); |
284 | | - |
285 | | - ret = bch2_run_recovery_pass(c, pass) ?: |
286 | | - bch2_journal_flush(&c->journal); |
287 | | - |
288 | | - if (!ret && !test_bit(BCH_FS_error, &c->flags)) |
289 | | - bch2_clear_recovery_pass_required(c, pass); |
290 | | - |
291 | | - spin_lock_irq(&c->recovery_pass_lock); |
292 | | - if (c->next_recovery_pass < c->curr_recovery_pass) { |
293 | | - /* |
294 | | - * bch2_run_explicit_recovery_pass() was called: we |
295 | | - * can't always catch -BCH_ERR_restart_recovery because |
296 | | - * it may have been called from another thread (btree |
297 | | - * node read completion) |
298 | | - */ |
299 | | - ret = 0; |
300 | | - c->recovery_passes_complete &= ~(~0ULL << c->curr_recovery_pass); |
301 | | - } else { |
302 | | - c->recovery_passes_complete |= BIT_ULL(pass); |
303 | | - c->recovery_pass_done = max(c->recovery_pass_done, pass); |
| 279 | + ret = bch2_run_recovery_pass(c, pass) ?: |
| 280 | + bch2_journal_flush(&c->journal); |
| 281 | + |
| 282 | + if (!ret && !test_bit(BCH_FS_error, &c->flags)) |
| 283 | + bch2_clear_recovery_pass_required(c, pass); |
| 284 | + spin_lock_irq(&c->recovery_pass_lock); |
| 285 | + |
| 286 | + if (c->next_recovery_pass < c->curr_recovery_pass) { |
| 287 | + /* |
| 288 | + * bch2_run_explicit_recovery_pass() was called: we |
| 289 | + * can't always catch -BCH_ERR_restart_recovery because |
| 290 | + * it may have been called from another thread (btree |
| 291 | + * node read completion) |
| 292 | + */ |
| 293 | + ret = 0; |
| 294 | + c->recovery_passes_complete &= ~(~0ULL << c->curr_recovery_pass); |
| 295 | + } else { |
| 296 | + c->recovery_passes_complete |= BIT_ULL(pass); |
| 297 | + c->recovery_pass_done = max(c->recovery_pass_done, pass); |
| 298 | + } |
304 | 299 | } |
| 300 | + |
305 | 301 | c->curr_recovery_pass = c->next_recovery_pass; |
306 | | - spin_unlock_irq(&c->recovery_pass_lock); |
307 | 302 | } |
308 | 303 |
|
| 304 | + spin_unlock_irq(&c->recovery_pass_lock); |
| 305 | + |
309 | 306 | return ret; |
310 | 307 | } |
0 commit comments