Prep work for automatically running recovery passes asynchronously.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
/* never rewinds version of curr_recovery_pass */
enum bch_recovery_pass recovery_pass_done;
spinlock_t recovery_pass_lock;
- struct semaphore online_fsck_mutex;
+ struct semaphore run_recovery_passes_lock;
/* DEBUG JUNK */
struct dentry *fs_debug_dir;
c->stdio_filter = NULL;
c->opts.fix_errors = old_fix_errors;
- up(&c->online_fsck_mutex);
+ up(&c->run_recovery_passes_lock);
bch2_ro_ref_put(c);
return ret;
}
if (!bch2_ro_ref_tryget(c))
return -EROFS;
- if (down_trylock(&c->online_fsck_mutex)) {
+ if (down_trylock(&c->run_recovery_passes_lock)) {
bch2_ro_ref_put(c);
return -EAGAIN;
}
bch_err_fn(c, ret);
if (thr)
bch2_fsck_thread_exit(&thr->thr);
- up(&c->online_fsck_mutex);
+ up(&c->run_recovery_passes_lock);
bch2_ro_ref_put(c);
}
return ret;
*/
c->opts.recovery_passes_exclude &= ~BCH_RECOVERY_PASS_set_may_go_rw;
+ down(&c->run_recovery_passes_lock);
spin_lock_irq(&c->recovery_pass_lock);
while (c->curr_recovery_pass < ARRAY_SIZE(recovery_pass_fns) && !ret) {
}
spin_unlock_irq(&c->recovery_pass_lock);
+ up(&c->run_recovery_passes_lock);
return ret;
}
+
+void bch2_fs_recovery_passes_init(struct bch_fs *c)
+{
+ spin_lock_init(&c->recovery_pass_lock);
+ sema_init(&c->run_recovery_passes_lock, 1);
+}
int bch2_run_online_recovery_passes(struct bch_fs *);
int bch2_run_recovery_passes(struct bch_fs *);
+void bch2_fs_recovery_passes_init(struct bch_fs *);
+
#endif /* _BCACHEFS_RECOVERY_PASSES_H */
#include "quota.h"
#include "rebalance.h"
#include "recovery.h"
+#include "recovery_passes.h"
#include "replicas.h"
#include "sb-clean.h"
#include "sb-counters.h"
refcount_set(&c->ro_ref, 1);
init_waitqueue_head(&c->ro_ref_wait);
- spin_lock_init(&c->recovery_pass_lock);
- sema_init(&c->online_fsck_mutex, 1);
for (i = 0; i < BCH_TIME_STAT_NR; i++)
bch2_time_stats_init(&c->times[i]);
bch2_fs_move_init(c);
bch2_fs_nocow_locking_init_early(c);
bch2_fs_quota_init(c);
+ bch2_fs_recovery_passes_init(c);
bch2_fs_sb_errors_init_early(c);
bch2_fs_snapshots_init_early(c);
bch2_fs_subvolumes_init_early(c);