Lines Matching full:c

92 void bch2_print_str(struct bch_fs *c, const char *str)  in bch2_print_str()  argument
95 struct stdio_redirect *stdio = bch2_fs_stdio_redirect(c); in bch2_print_str()
130 void __bch2_print(struct bch_fs *c, const char *fmt, ...) in __bch2_print() argument
132 struct stdio_redirect *stdio = bch2_fs_stdio_redirect(c); in __bch2_print()
195 struct bch_fs *c; in bch2_dev_to_fs() local
200 list_for_each_entry(c, &bch_fs_list, list) in bch2_dev_to_fs()
201 for_each_member_device_rcu(c, ca, NULL) in bch2_dev_to_fs()
203 closure_get(&c->cl); in bch2_dev_to_fs()
206 c = NULL; in bch2_dev_to_fs()
211 return c; in bch2_dev_to_fs()
216 struct bch_fs *c; in __bch2_uuid_to_fs() local
220 list_for_each_entry(c, &bch_fs_list, list) in __bch2_uuid_to_fs()
221 if (!memcmp(&c->disk_sb.sb->uuid, &uuid, sizeof(uuid))) in __bch2_uuid_to_fs()
222 return c; in __bch2_uuid_to_fs()
229 struct bch_fs *c; in bch2_uuid_to_fs() local
232 c = __bch2_uuid_to_fs(uuid); in bch2_uuid_to_fs()
233 if (c) in bch2_uuid_to_fs()
234 closure_get(&c->cl); in bch2_uuid_to_fs()
237 return c; in bch2_uuid_to_fs()
257 static void __bch2_fs_read_only(struct bch_fs *c) in __bch2_fs_read_only() argument
262 bch2_fs_ec_stop(c); in __bch2_fs_read_only()
263 bch2_open_buckets_stop(c, NULL, true); in __bch2_fs_read_only()
264 bch2_rebalance_stop(c); in __bch2_fs_read_only()
265 bch2_copygc_stop(c); in __bch2_fs_read_only()
266 bch2_fs_ec_flush(c); in __bch2_fs_read_only()
268 bch_verbose(c, "flushing journal and stopping allocators, journal seq %llu", in __bch2_fs_read_only()
269 journal_cur_seq(&c->journal)); in __bch2_fs_read_only()
274 if (bch2_btree_interior_updates_flush(c) || in __bch2_fs_read_only()
275 bch2_btree_write_buffer_flush_going_ro(c) || in __bch2_fs_read_only()
276 bch2_journal_flush_all_pins(&c->journal) || in __bch2_fs_read_only()
277 bch2_btree_flush_all_writes(c) || in __bch2_fs_read_only()
278 seq != atomic64_read(&c->journal.seq)) { in __bch2_fs_read_only()
279 seq = atomic64_read(&c->journal.seq); in __bch2_fs_read_only()
284 bch_verbose(c, "flushing journal and stopping allocators complete, journal seq %llu", in __bch2_fs_read_only()
285 journal_cur_seq(&c->journal)); in __bch2_fs_read_only()
287 if (test_bit(JOURNAL_replay_done, &c->journal.flags) && in __bch2_fs_read_only()
288 !test_bit(BCH_FS_emergency_ro, &c->flags)) in __bch2_fs_read_only()
289 set_bit(BCH_FS_clean_shutdown, &c->flags); in __bch2_fs_read_only()
291 bch2_fs_journal_stop(&c->journal); in __bch2_fs_read_only()
293 bch_info(c, "%sshutdown complete, journal seq %llu", in __bch2_fs_read_only()
294 test_bit(BCH_FS_clean_shutdown, &c->flags) ? "" : "un", in __bch2_fs_read_only()
295 c->journal.seq_ondisk); in __bch2_fs_read_only()
300 for_each_member_device(c, ca) in __bch2_fs_read_only()
301 bch2_dev_allocator_remove(c, ca); in __bch2_fs_read_only()
307 struct bch_fs *c = container_of(writes, struct bch_fs, writes); in bch2_writes_disabled() local
309 set_bit(BCH_FS_write_disable_complete, &c->flags); in bch2_writes_disabled()
314 void bch2_fs_read_only(struct bch_fs *c) in bch2_fs_read_only() argument
316 if (!test_bit(BCH_FS_rw, &c->flags)) { in bch2_fs_read_only()
317 bch2_journal_reclaim_stop(&c->journal); in bch2_fs_read_only()
321 BUG_ON(test_bit(BCH_FS_write_disable_complete, &c->flags)); in bch2_fs_read_only()
323 bch_verbose(c, "going read-only"); in bch2_fs_read_only()
329 set_bit(BCH_FS_going_ro, &c->flags); in bch2_fs_read_only()
331 percpu_ref_kill(&c->writes); in bch2_fs_read_only()
334 bch2_write_ref_put(c, i); in bch2_fs_read_only()
349 test_bit(BCH_FS_write_disable_complete, &c->flags) || in bch2_fs_read_only()
350 test_bit(BCH_FS_emergency_ro, &c->flags)); in bch2_fs_read_only()
352 bool writes_disabled = test_bit(BCH_FS_write_disable_complete, &c->flags); in bch2_fs_read_only()
354 bch_verbose(c, "finished waiting for writes to stop"); in bch2_fs_read_only()
356 __bch2_fs_read_only(c); in bch2_fs_read_only()
359 test_bit(BCH_FS_write_disable_complete, &c->flags)); in bch2_fs_read_only()
362 bch_verbose(c, "finished waiting for writes to stop"); in bch2_fs_read_only()
364 clear_bit(BCH_FS_write_disable_complete, &c->flags); in bch2_fs_read_only()
365 clear_bit(BCH_FS_going_ro, &c->flags); in bch2_fs_read_only()
366 clear_bit(BCH_FS_rw, &c->flags); in bch2_fs_read_only()
368 if (!bch2_journal_error(&c->journal) && in bch2_fs_read_only()
369 !test_bit(BCH_FS_error, &c->flags) && in bch2_fs_read_only()
370 !test_bit(BCH_FS_emergency_ro, &c->flags) && in bch2_fs_read_only()
371 test_bit(BCH_FS_started, &c->flags) && in bch2_fs_read_only()
372 test_bit(BCH_FS_clean_shutdown, &c->flags) && in bch2_fs_read_only()
373 c->recovery_pass_done >= BCH_RECOVERY_PASS_journal_replay) { in bch2_fs_read_only()
374 BUG_ON(c->journal.last_empty_seq != journal_cur_seq(&c->journal)); in bch2_fs_read_only()
375 BUG_ON(atomic_long_read(&c->btree_cache.nr_dirty)); in bch2_fs_read_only()
376 BUG_ON(atomic_long_read(&c->btree_key_cache.nr_dirty)); in bch2_fs_read_only()
377 BUG_ON(c->btree_write_buffer.inc.keys.nr); in bch2_fs_read_only()
378 BUG_ON(c->btree_write_buffer.flushing.keys.nr); in bch2_fs_read_only()
379 bch2_verify_accounting_clean(c); in bch2_fs_read_only()
381 bch_verbose(c, "marking filesystem clean"); in bch2_fs_read_only()
382 bch2_fs_mark_clean(c); in bch2_fs_read_only()
384 bch_verbose(c, "done going read-only, filesystem not clean"); in bch2_fs_read_only()
390 struct bch_fs *c = in bch2_fs_read_only_work() local
393 down_write(&c->state_lock); in bch2_fs_read_only_work()
394 bch2_fs_read_only(c); in bch2_fs_read_only_work()
395 up_write(&c->state_lock); in bch2_fs_read_only_work()
398 static void bch2_fs_read_only_async(struct bch_fs *c) in bch2_fs_read_only_async() argument
400 queue_work(system_long_wq, &c->read_only_work); in bch2_fs_read_only_async()
403 bool bch2_fs_emergency_read_only(struct bch_fs *c) in bch2_fs_emergency_read_only() argument
405 bool ret = !test_and_set_bit(BCH_FS_emergency_ro, &c->flags); in bch2_fs_emergency_read_only()
407 bch2_journal_halt(&c->journal); in bch2_fs_emergency_read_only()
408 bch2_fs_read_only_async(c); in bch2_fs_emergency_read_only()
414 static int bch2_fs_read_write_late(struct bch_fs *c) in bch2_fs_read_write_late() argument
425 ret = bch2_copygc_start(c); in bch2_fs_read_write_late()
427 bch_err(c, "error starting copygc thread"); in bch2_fs_read_write_late()
431 ret = bch2_rebalance_start(c); in bch2_fs_read_write_late()
433 bch_err(c, "error starting rebalance thread"); in bch2_fs_read_write_late()
440 static int __bch2_fs_read_write(struct bch_fs *c, bool early) in __bch2_fs_read_write() argument
444 if (test_bit(BCH_FS_initial_gc_unfixed, &c->flags)) { in __bch2_fs_read_write()
445 bch_err(c, "cannot go rw, unfixed btree errors"); in __bch2_fs_read_write()
449 if (test_bit(BCH_FS_rw, &c->flags)) in __bch2_fs_read_write()
452 bch_info(c, "going read-write"); in __bch2_fs_read_write()
454 ret = bch2_sb_members_v2_init(c); in __bch2_fs_read_write()
458 ret = bch2_fs_mark_dirty(c); in __bch2_fs_read_write()
462 clear_bit(BCH_FS_clean_shutdown, &c->flags); in __bch2_fs_read_write()
470 set_bit(JOURNAL_need_flush_write, &c->journal.flags); in __bch2_fs_read_write()
471 set_bit(JOURNAL_running, &c->journal.flags); in __bch2_fs_read_write()
473 for_each_rw_member(c, ca) in __bch2_fs_read_write()
474 bch2_dev_allocator_add(c, ca); in __bch2_fs_read_write()
475 bch2_recalc_capacity(c); in __bch2_fs_read_write()
477 set_bit(BCH_FS_rw, &c->flags); in __bch2_fs_read_write()
478 set_bit(BCH_FS_was_rw, &c->flags); in __bch2_fs_read_write()
481 percpu_ref_reinit(&c->writes); in __bch2_fs_read_write()
484 BUG_ON(atomic_long_read(&c->writes[i])); in __bch2_fs_read_write()
485 atomic_long_inc(&c->writes[i]); in __bch2_fs_read_write()
489 ret = bch2_journal_reclaim_start(&c->journal); in __bch2_fs_read_write()
494 ret = bch2_fs_read_write_late(c); in __bch2_fs_read_write()
499 bch2_do_discards(c); in __bch2_fs_read_write()
500 bch2_do_invalidates(c); in __bch2_fs_read_write()
501 bch2_do_stripe_deletes(c); in __bch2_fs_read_write()
502 bch2_do_pending_node_rewrites(c); in __bch2_fs_read_write()
505 if (test_bit(BCH_FS_rw, &c->flags)) in __bch2_fs_read_write()
506 bch2_fs_read_only(c); in __bch2_fs_read_write()
508 __bch2_fs_read_only(c); in __bch2_fs_read_write()
512 int bch2_fs_read_write(struct bch_fs *c) in bch2_fs_read_write() argument
514 if (c->opts.recovery_pass_last && in bch2_fs_read_write()
515 c->opts.recovery_pass_last < BCH_RECOVERY_PASS_journal_replay) in bch2_fs_read_write()
518 if (c->opts.nochanges) in bch2_fs_read_write()
521 return __bch2_fs_read_write(c, false); in bch2_fs_read_write()
524 int bch2_fs_read_write_early(struct bch_fs *c) in bch2_fs_read_write_early() argument
526 lockdep_assert_held(&c->state_lock); in bch2_fs_read_write_early()
528 return __bch2_fs_read_write(c, true); in bch2_fs_read_write_early()
533 static void __bch2_fs_free(struct bch_fs *c) in __bch2_fs_free() argument
536 bch2_time_stats_exit(&c->times[i]); in __bch2_fs_free()
538 bch2_find_btree_nodes_exit(&c->found_btree_nodes); in __bch2_fs_free()
539 bch2_free_pending_node_rewrites(c); in __bch2_fs_free()
540 bch2_fs_accounting_exit(c); in __bch2_fs_free()
541 bch2_fs_sb_errors_exit(c); in __bch2_fs_free()
542 bch2_fs_counters_exit(c); in __bch2_fs_free()
543 bch2_fs_snapshots_exit(c); in __bch2_fs_free()
544 bch2_fs_quota_exit(c); in __bch2_fs_free()
545 bch2_fs_fs_io_direct_exit(c); in __bch2_fs_free()
546 bch2_fs_fs_io_buffered_exit(c); in __bch2_fs_free()
547 bch2_fs_fsio_exit(c); in __bch2_fs_free()
548 bch2_fs_vfs_exit(c); in __bch2_fs_free()
549 bch2_fs_ec_exit(c); in __bch2_fs_free()
550 bch2_fs_encryption_exit(c); in __bch2_fs_free()
551 bch2_fs_nocow_locking_exit(c); in __bch2_fs_free()
552 bch2_fs_io_write_exit(c); in __bch2_fs_free()
553 bch2_fs_io_read_exit(c); in __bch2_fs_free()
554 bch2_fs_buckets_waiting_for_journal_exit(c); in __bch2_fs_free()
555 bch2_fs_btree_interior_update_exit(c); in __bch2_fs_free()
556 bch2_fs_btree_key_cache_exit(&c->btree_key_cache); in __bch2_fs_free()
557 bch2_fs_btree_cache_exit(c); in __bch2_fs_free()
558 bch2_fs_btree_iter_exit(c); in __bch2_fs_free()
559 bch2_fs_replicas_exit(c); in __bch2_fs_free()
560 bch2_fs_journal_exit(&c->journal); in __bch2_fs_free()
561 bch2_io_clock_exit(&c->io_clock[WRITE]); in __bch2_fs_free()
562 bch2_io_clock_exit(&c->io_clock[READ]); in __bch2_fs_free()
563 bch2_fs_compress_exit(c); in __bch2_fs_free()
564 bch2_journal_keys_put_initial(c); in __bch2_fs_free()
565 bch2_find_btree_nodes_exit(&c->found_btree_nodes); in __bch2_fs_free()
566 BUG_ON(atomic_read(&c->journal_keys.ref)); in __bch2_fs_free()
567 bch2_fs_btree_write_buffer_exit(c); in __bch2_fs_free()
568 percpu_free_rwsem(&c->mark_lock); in __bch2_fs_free()
569 if (c->online_reserved) { in __bch2_fs_free()
570 u64 v = percpu_u64_get(c->online_reserved); in __bch2_fs_free()
572 free_percpu(c->online_reserved); in __bch2_fs_free()
575 darray_exit(&c->btree_roots_extra); in __bch2_fs_free()
576 free_percpu(c->pcpu); in __bch2_fs_free()
577 free_percpu(c->usage); in __bch2_fs_free()
578 mempool_exit(&c->large_bkey_pool); in __bch2_fs_free()
579 mempool_exit(&c->btree_bounce_pool); in __bch2_fs_free()
580 bioset_exit(&c->btree_bio); in __bch2_fs_free()
581 mempool_exit(&c->fill_iter); in __bch2_fs_free()
583 percpu_ref_exit(&c->writes); in __bch2_fs_free()
585 kfree(rcu_dereference_protected(c->disk_groups, 1)); in __bch2_fs_free()
586 kfree(c->journal_seq_blacklist_table); in __bch2_fs_free()
587 kfree(c->unused_inode_hints); in __bch2_fs_free()
589 if (c->write_ref_wq) in __bch2_fs_free()
590 destroy_workqueue(c->write_ref_wq); in __bch2_fs_free()
591 if (c->btree_write_submit_wq) in __bch2_fs_free()
592 destroy_workqueue(c->btree_write_submit_wq); in __bch2_fs_free()
593 if (c->btree_read_complete_wq) in __bch2_fs_free()
594 destroy_workqueue(c->btree_read_complete_wq); in __bch2_fs_free()
595 if (c->copygc_wq) in __bch2_fs_free()
596 destroy_workqueue(c->copygc_wq); in __bch2_fs_free()
597 if (c->btree_io_complete_wq) in __bch2_fs_free()
598 destroy_workqueue(c->btree_io_complete_wq); in __bch2_fs_free()
599 if (c->btree_update_wq) in __bch2_fs_free()
600 destroy_workqueue(c->btree_update_wq); in __bch2_fs_free()
602 bch2_free_super(&c->disk_sb); in __bch2_fs_free()
603 kvfree(c); in __bch2_fs_free()
609 struct bch_fs *c = container_of(kobj, struct bch_fs, kobj); in bch2_fs_release() local
611 __bch2_fs_free(c); in bch2_fs_release()
614 void __bch2_fs_stop(struct bch_fs *c) in __bch2_fs_stop() argument
616 bch_verbose(c, "shutting down"); in __bch2_fs_stop()
618 set_bit(BCH_FS_stopping, &c->flags); in __bch2_fs_stop()
620 down_write(&c->state_lock); in __bch2_fs_stop()
621 bch2_fs_read_only(c); in __bch2_fs_stop()
622 up_write(&c->state_lock); in __bch2_fs_stop()
624 for_each_member_device(c, ca) in __bch2_fs_stop()
627 if (c->kobj.state_in_sysfs) in __bch2_fs_stop()
628 kobject_del(&c->kobj); in __bch2_fs_stop()
630 bch2_fs_debug_exit(c); in __bch2_fs_stop()
631 bch2_fs_chardev_exit(c); in __bch2_fs_stop()
633 bch2_ro_ref_put(c); in __bch2_fs_stop()
634 wait_event(c->ro_ref_wait, !refcount_read(&c->ro_ref)); in __bch2_fs_stop()
636 kobject_put(&c->counters_kobj); in __bch2_fs_stop()
637 kobject_put(&c->time_stats); in __bch2_fs_stop()
638 kobject_put(&c->opts_dir); in __bch2_fs_stop()
639 kobject_put(&c->internal); in __bch2_fs_stop()
642 bch2_btree_flush_all_reads(c); in __bch2_fs_stop()
644 for_each_member_device(c, ca) in __bch2_fs_stop()
647 cancel_work_sync(&c->read_only_work); in __bch2_fs_stop()
650 void bch2_fs_free(struct bch_fs *c) in bch2_fs_free() argument
655 list_del(&c->list); in bch2_fs_free()
658 closure_sync(&c->cl); in bch2_fs_free()
659 closure_debug_destroy(&c->cl); in bch2_fs_free()
661 for (i = 0; i < c->sb.nr_devices; i++) { in bch2_fs_free()
662 struct bch_dev *ca = rcu_dereference_protected(c->devs[i], true); in bch2_fs_free()
671 bch_verbose(c, "shutdown complete"); in bch2_fs_free()
673 kobject_put(&c->kobj); in bch2_fs_free()
676 void bch2_fs_stop(struct bch_fs *c) in bch2_fs_stop() argument
678 __bch2_fs_stop(c); in bch2_fs_stop()
679 bch2_fs_free(c); in bch2_fs_stop()
682 static int bch2_fs_online(struct bch_fs *c) in bch2_fs_online() argument
688 if (__bch2_uuid_to_fs(c->sb.uuid)) { in bch2_fs_online()
689 bch_err(c, "filesystem UUID already open"); in bch2_fs_online()
693 ret = bch2_fs_chardev_init(c); in bch2_fs_online()
695 bch_err(c, "error creating character device"); in bch2_fs_online()
699 bch2_fs_debug_init(c); in bch2_fs_online()
701 ret = kobject_add(&c->kobj, NULL, "%pU", c->sb.user_uuid.b) ?: in bch2_fs_online()
702 kobject_add(&c->internal, &c->kobj, "internal") ?: in bch2_fs_online()
703 kobject_add(&c->opts_dir, &c->kobj, "options") ?: in bch2_fs_online()
705 kobject_add(&c->time_stats, &c->kobj, "time_stats") ?: in bch2_fs_online()
707 kobject_add(&c->counters_kobj, &c->kobj, "counters") ?: in bch2_fs_online()
708 bch2_opts_create_sysfs_files(&c->opts_dir); in bch2_fs_online()
710 bch_err(c, "error creating sysfs objects"); in bch2_fs_online()
714 down_write(&c->state_lock); in bch2_fs_online()
716 for_each_member_device(c, ca) { in bch2_fs_online()
717 ret = bch2_dev_sysfs_online(c, ca); in bch2_fs_online()
719 bch_err(c, "error creating sysfs objects"); in bch2_fs_online()
725 BUG_ON(!list_empty(&c->list)); in bch2_fs_online()
726 list_add(&c->list, &bch_fs_list); in bch2_fs_online()
728 up_write(&c->state_lock); in bch2_fs_online()
734 struct bch_fs *c; in bch2_fs_alloc() local
739 c = kvmalloc(sizeof(struct bch_fs), GFP_KERNEL|__GFP_ZERO); in bch2_fs_alloc()
740 if (!c) { in bch2_fs_alloc()
741 c = ERR_PTR(-BCH_ERR_ENOMEM_fs_alloc); in bch2_fs_alloc()
745 c->stdio = (void *)(unsigned long) opts.stdio; in bch2_fs_alloc()
749 closure_init(&c->cl, NULL); in bch2_fs_alloc()
751 c->kobj.kset = bcachefs_kset; in bch2_fs_alloc()
752 kobject_init(&c->kobj, &bch2_fs_ktype); in bch2_fs_alloc()
753 kobject_init(&c->internal, &bch2_fs_internal_ktype); in bch2_fs_alloc()
754 kobject_init(&c->opts_dir, &bch2_fs_opts_dir_ktype); in bch2_fs_alloc()
755 kobject_init(&c->time_stats, &bch2_fs_time_stats_ktype); in bch2_fs_alloc()
756 kobject_init(&c->counters_kobj, &bch2_fs_counters_ktype); in bch2_fs_alloc()
758 c->minor = -1; in bch2_fs_alloc()
759 c->disk_sb.fs_sb = true; in bch2_fs_alloc()
761 init_rwsem(&c->state_lock); in bch2_fs_alloc()
762 mutex_init(&c->sb_lock); in bch2_fs_alloc()
763 mutex_init(&c->replicas_gc_lock); in bch2_fs_alloc()
764 mutex_init(&c->btree_root_lock); in bch2_fs_alloc()
765 INIT_WORK(&c->read_only_work, bch2_fs_read_only_work); in bch2_fs_alloc()
767 refcount_set(&c->ro_ref, 1); in bch2_fs_alloc()
768 init_waitqueue_head(&c->ro_ref_wait); in bch2_fs_alloc()
769 sema_init(&c->online_fsck_mutex, 1); in bch2_fs_alloc()
771 init_rwsem(&c->gc_lock); in bch2_fs_alloc()
772 mutex_init(&c->gc_gens_lock); in bch2_fs_alloc()
773 atomic_set(&c->journal_keys.ref, 1); in bch2_fs_alloc()
774 c->journal_keys.initial_ref_held = true; in bch2_fs_alloc()
777 bch2_time_stats_init(&c->times[i]); in bch2_fs_alloc()
779 bch2_fs_gc_init(c); in bch2_fs_alloc()
780 bch2_fs_copygc_init(c); in bch2_fs_alloc()
781 bch2_fs_btree_key_cache_init_early(&c->btree_key_cache); in bch2_fs_alloc()
782 bch2_fs_btree_iter_init_early(c); in bch2_fs_alloc()
783 bch2_fs_btree_interior_update_init_early(c); in bch2_fs_alloc()
784 bch2_fs_allocator_background_init(c); in bch2_fs_alloc()
785 bch2_fs_allocator_foreground_init(c); in bch2_fs_alloc()
786 bch2_fs_rebalance_init(c); in bch2_fs_alloc()
787 bch2_fs_quota_init(c); in bch2_fs_alloc()
788 bch2_fs_ec_init_early(c); in bch2_fs_alloc()
789 bch2_fs_move_init(c); in bch2_fs_alloc()
790 bch2_fs_sb_errors_init_early(c); in bch2_fs_alloc()
792 INIT_LIST_HEAD(&c->list); in bch2_fs_alloc()
794 mutex_init(&c->bio_bounce_pages_lock); in bch2_fs_alloc()
795 mutex_init(&c->snapshot_table_lock); in bch2_fs_alloc()
796 init_rwsem(&c->snapshot_create_lock); in bch2_fs_alloc()
798 spin_lock_init(&c->btree_write_error_lock); in bch2_fs_alloc()
800 INIT_LIST_HEAD(&c->journal_iters); in bch2_fs_alloc()
802 INIT_LIST_HEAD(&c->fsck_error_msgs); in bch2_fs_alloc()
803 mutex_init(&c->fsck_error_msgs_lock); in bch2_fs_alloc()
805 seqcount_init(&c->usage_lock); in bch2_fs_alloc()
807 sema_init(&c->io_in_flight, 128); in bch2_fs_alloc()
809 INIT_LIST_HEAD(&c->vfs_inodes_list); in bch2_fs_alloc()
810 mutex_init(&c->vfs_inodes_lock); in bch2_fs_alloc()
812 c->copy_gc_enabled = 1; in bch2_fs_alloc()
813 c->rebalance.enabled = 1; in bch2_fs_alloc()
815 c->journal.flush_write_time = &c->times[BCH_TIME_journal_flush_write]; in bch2_fs_alloc()
816 c->journal.noflush_write_time = &c->times[BCH_TIME_journal_noflush_write]; in bch2_fs_alloc()
817 c->journal.flush_seq_time = &c->times[BCH_TIME_journal_flush_seq]; in bch2_fs_alloc()
819 bch2_fs_btree_cache_init_early(&c->btree_cache); in bch2_fs_alloc()
821 mutex_init(&c->sectors_available_lock); in bch2_fs_alloc()
823 ret = percpu_init_rwsem(&c->mark_lock); in bch2_fs_alloc()
827 mutex_lock(&c->sb_lock); in bch2_fs_alloc()
828 ret = bch2_sb_to_fs(c, sb); in bch2_fs_alloc()
829 mutex_unlock(&c->sb_lock); in bch2_fs_alloc()
834 pr_uuid(&name, c->sb.user_uuid.b); in bch2_fs_alloc()
839 strscpy(c->name, name.buf, sizeof(c->name)); in bch2_fs_alloc()
851 c->opts = bch2_opts_default; in bch2_fs_alloc()
852 ret = bch2_opts_from_sb(&c->opts, sb); in bch2_fs_alloc()
856 bch2_opts_apply(&c->opts, opts); in bch2_fs_alloc()
858 c->btree_key_cache_btrees |= 1U << BTREE_ID_alloc; in bch2_fs_alloc()
859 if (c->opts.inodes_use_key_cache) in bch2_fs_alloc()
860 c->btree_key_cache_btrees |= 1U << BTREE_ID_inodes; in bch2_fs_alloc()
861 c->btree_key_cache_btrees |= 1U << BTREE_ID_logged_ops; in bch2_fs_alloc()
863 c->block_bits = ilog2(block_sectors(c)); in bch2_fs_alloc()
864 c->btree_foreground_merge_threshold = BTREE_FOREGROUND_MERGE_THRESHOLD(c); in bch2_fs_alloc()
867 bch_err(c, "fs_alloc fault injected"); in bch2_fs_alloc()
873 (btree_blocks(c) + 1) * 2 * in bch2_fs_alloc()
876 c->inode_shard_bits = ilog2(roundup_pow_of_two(num_possible_cpus())); in bch2_fs_alloc()
878 if (!(c->btree_update_wq = alloc_workqueue("bcachefs", in bch2_fs_alloc()
880 !(c->btree_io_complete_wq = alloc_workqueue("bcachefs_btree_io", in bch2_fs_alloc()
882 !(c->copygc_wq = alloc_workqueue("bcachefs_copygc", in bch2_fs_alloc()
884 !(c->btree_read_complete_wq = alloc_workqueue("bcachefs_btree_read_complete", in bch2_fs_alloc()
886 !(c->btree_write_submit_wq = alloc_workqueue("bcachefs_btree_write_sumit", in bch2_fs_alloc()
888 !(c->write_ref_wq = alloc_workqueue("bcachefs_write_ref", in bch2_fs_alloc()
891 percpu_ref_init(&c->writes, bch2_writes_disabled, in bch2_fs_alloc()
894 mempool_init_kmalloc_pool(&c->fill_iter, 1, iter_size) || in bch2_fs_alloc()
895 bioset_init(&c->btree_bio, 1, in bch2_fs_alloc()
899 !(c->pcpu = alloc_percpu(struct bch_fs_pcpu)) || in bch2_fs_alloc()
900 !(c->usage = alloc_percpu(struct bch_fs_usage_base)) || in bch2_fs_alloc()
901 !(c->online_reserved = alloc_percpu(u64)) || in bch2_fs_alloc()
902 mempool_init_kvmalloc_pool(&c->btree_bounce_pool, 1, in bch2_fs_alloc()
903 c->opts.btree_node_size) || in bch2_fs_alloc()
904 mempool_init_kmalloc_pool(&c->large_bkey_pool, 1, 2048) || in bch2_fs_alloc()
905 !(c->unused_inode_hints = kcalloc(1U << c->inode_shard_bits, in bch2_fs_alloc()
911 ret = bch2_fs_counters_init(c) ?: in bch2_fs_alloc()
912 bch2_fs_sb_errors_init(c) ?: in bch2_fs_alloc()
913 bch2_io_clock_init(&c->io_clock[READ]) ?: in bch2_fs_alloc()
914 bch2_io_clock_init(&c->io_clock[WRITE]) ?: in bch2_fs_alloc()
915 bch2_fs_journal_init(&c->journal) ?: in bch2_fs_alloc()
916 bch2_fs_btree_iter_init(c) ?: in bch2_fs_alloc()
917 bch2_fs_btree_cache_init(c) ?: in bch2_fs_alloc()
918 bch2_fs_btree_key_cache_init(&c->btree_key_cache) ?: in bch2_fs_alloc()
919 bch2_fs_btree_interior_update_init(c) ?: in bch2_fs_alloc()
920 bch2_fs_buckets_waiting_for_journal_init(c) ?: in bch2_fs_alloc()
921 bch2_fs_btree_write_buffer_init(c) ?: in bch2_fs_alloc()
922 bch2_fs_subvolumes_init(c) ?: in bch2_fs_alloc()
923 bch2_fs_io_read_init(c) ?: in bch2_fs_alloc()
924 bch2_fs_io_write_init(c) ?: in bch2_fs_alloc()
925 bch2_fs_nocow_locking_init(c) ?: in bch2_fs_alloc()
926 bch2_fs_encryption_init(c) ?: in bch2_fs_alloc()
927 bch2_fs_compress_init(c) ?: in bch2_fs_alloc()
928 bch2_fs_ec_init(c) ?: in bch2_fs_alloc()
929 bch2_fs_vfs_init(c) ?: in bch2_fs_alloc()
930 bch2_fs_fsio_init(c) ?: in bch2_fs_alloc()
931 bch2_fs_fs_io_buffered_init(c) ?: in bch2_fs_alloc()
932 bch2_fs_fs_io_direct_init(c); in bch2_fs_alloc()
936 for (i = 0; i < c->sb.nr_devices; i++) { in bch2_fs_alloc()
937 if (!bch2_member_exists(c->disk_sb.sb, i)) in bch2_fs_alloc()
939 ret = bch2_dev_alloc(c, i); in bch2_fs_alloc()
944 bch2_journal_entry_res_resize(&c->journal, in bch2_fs_alloc()
945 &c->btree_root_journal_res, in bch2_fs_alloc()
947 bch2_journal_entry_res_resize(&c->journal, in bch2_fs_alloc()
948 &c->clock_journal_res, in bch2_fs_alloc()
952 ret = bch2_fs_online(c); in bch2_fs_alloc()
958 return c; in bch2_fs_alloc()
960 bch2_fs_free(c); in bch2_fs_alloc()
961 c = ERR_PTR(ret); in bch2_fs_alloc()
966 static void print_mount_opts(struct bch_fs *c) in print_mount_opts() argument
973 bch2_version_to_text(&p, c->sb.version); in print_mount_opts()
975 if (c->opts.read_only) { in print_mount_opts()
983 u64 v = bch2_opt_get_by_id(&c->opts, i); in print_mount_opts()
993 bch2_opt_to_text(&p, c, c->disk_sb.sb, opt, v, OPT_SHOW_MOUNT_STYLE); in print_mount_opts()
996 bch_info(c, "%s", p.buf); in print_mount_opts()
1000 int bch2_fs_start(struct bch_fs *c) in bch2_fs_start() argument
1005 print_mount_opts(c); in bch2_fs_start()
1007 down_write(&c->state_lock); in bch2_fs_start()
1009 BUG_ON(test_bit(BCH_FS_started, &c->flags)); in bch2_fs_start()
1011 mutex_lock(&c->sb_lock); in bch2_fs_start()
1013 ret = bch2_sb_members_v2_init(c); in bch2_fs_start()
1015 mutex_unlock(&c->sb_lock); in bch2_fs_start()
1019 for_each_online_member(c, ca) in bch2_fs_start()
1020 bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx)->last_mount = cpu_to_le64(now); in bch2_fs_start()
1023 bch2_sb_field_get_minsize(&c->disk_sb, ext, sizeof(*ext) / sizeof(u64)); in bch2_fs_start()
1024 mutex_unlock(&c->sb_lock); in bch2_fs_start()
1027 bch_err(c, "insufficient space in superblock for sb_field_ext"); in bch2_fs_start()
1032 for_each_rw_member(c, ca) in bch2_fs_start()
1033 bch2_dev_allocator_add(c, ca); in bch2_fs_start()
1034 bch2_recalc_capacity(c); in bch2_fs_start()
1036 ret = BCH_SB_INITIALIZED(c->disk_sb.sb) in bch2_fs_start()
1037 ? bch2_fs_recovery(c) in bch2_fs_start()
1038 : bch2_fs_initialize(c); in bch2_fs_start()
1042 ret = bch2_opts_check_may_set(c); in bch2_fs_start()
1047 bch_err(c, "fs_start fault injected"); in bch2_fs_start()
1052 set_bit(BCH_FS_started, &c->flags); in bch2_fs_start()
1054 if (c->opts.read_only) { in bch2_fs_start()
1055 bch2_fs_read_only(c); in bch2_fs_start()
1057 ret = !test_bit(BCH_FS_rw, &c->flags) in bch2_fs_start()
1058 ? bch2_fs_read_write(c) in bch2_fs_start()
1059 : bch2_fs_read_write_late(c); in bch2_fs_start()
1067 bch_err_msg(c, ret, "starting filesystem"); in bch2_fs_start()
1069 bch_verbose(c, "done starting filesystem"); in bch2_fs_start()
1070 up_write(&c->state_lock); in bch2_fs_start()
1074 static int bch2_dev_may_add(struct bch_sb *sb, struct bch_fs *c) in bch2_dev_may_add() argument
1078 if (le16_to_cpu(sb->block_size) != block_sectors(c)) in bch2_dev_may_add()
1082 BCH_SB_BTREE_NODE_SIZE(c->disk_sb.sb)) in bch2_dev_may_add()
1213 static void __bch2_dev_offline(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_offline() argument
1216 lockdep_assert_held(&c->state_lock); in __bch2_dev_offline()
1221 __bch2_dev_read_only(c, ca); in __bch2_dev_offline()
1258 * code doesn't appear to provide a good method and block/holder.c is in bch2_dev_unlink()
1269 static int bch2_dev_sysfs_online(struct bch_fs *c, struct bch_dev *ca) in bch2_dev_sysfs_online() argument
1273 if (!c->kobj.state_in_sysfs) in bch2_dev_sysfs_online()
1277 ret = kobject_add(&ca->kobj, &c->kobj, in bch2_dev_sysfs_online()
1298 static struct bch_dev *__bch2_dev_alloc(struct bch_fs *c, in __bch2_dev_alloc() argument
1327 ca->mi.bucket_size / btree_sectors(c)); in __bch2_dev_alloc()
1341 bch2_dev_buckets_alloc(c, ca) || in __bch2_dev_alloc()
1351 static void bch2_dev_attach(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_attach() argument
1358 ca->fs = c; in bch2_dev_attach()
1359 rcu_assign_pointer(c->devs[ca->dev_idx], ca); in bch2_dev_attach()
1361 if (bch2_dev_sysfs_online(c, ca)) in bch2_dev_attach()
1365 static int bch2_dev_alloc(struct bch_fs *c, unsigned dev_idx) in bch2_dev_alloc() argument
1367 struct bch_member member = bch2_sb_member_get(c->disk_sb.sb, dev_idx); in bch2_dev_alloc()
1374 ca = __bch2_dev_alloc(c, &member); in bch2_dev_alloc()
1378 ca->fs = c; in bch2_dev_alloc()
1380 bch2_dev_attach(c, ca, dev_idx); in bch2_dev_alloc()
1421 static int bch2_dev_attach_bdev(struct bch_fs *c, struct bch_sb_handle *sb) in bch2_dev_attach_bdev() argument
1426 lockdep_assert_held(&c->state_lock); in bch2_dev_attach_bdev()
1429 le64_to_cpu(c->disk_sb.sb->seq)) in bch2_dev_attach_bdev()
1430 bch2_sb_to_fs(c, sb->sb); in bch2_dev_attach_bdev()
1432 BUG_ON(!bch2_dev_exists(c, sb->sb->dev_idx)); in bch2_dev_attach_bdev()
1434 ca = bch2_dev_locked(c, sb->sb->dev_idx); in bch2_dev_attach_bdev()
1440 bch2_dev_sysfs_online(c, ca); in bch2_dev_attach_bdev()
1445 if (c->sb.nr_devices == 1) in bch2_dev_attach_bdev()
1446 strscpy(c->name, name.buf, sizeof(c->name)); in bch2_dev_attach_bdev()
1451 rebalance_wakeup(c); in bch2_dev_attach_bdev()
1466 bool bch2_dev_state_allowed(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_state_allowed() argument
1472 lockdep_assert_held(&c->state_lock); in bch2_dev_state_allowed()
1482 for_each_member_device(c, ca2) in bch2_dev_state_allowed()
1487 ? c->opts.metadata_replicas in bch2_dev_state_allowed()
1488 : metadata_replicas_required(c), in bch2_dev_state_allowed()
1490 ? c->opts.data_replicas in bch2_dev_state_allowed()
1491 : data_replicas_required(c)); in bch2_dev_state_allowed()
1501 new_online_devs = bch2_online_devs(c); in bch2_dev_state_allowed()
1504 return bch2_have_enough_devs(c, new_online_devs, flags, false); in bch2_dev_state_allowed()
1510 static bool bch2_fs_may_start(struct bch_fs *c) in bch2_fs_may_start() argument
1515 if (c->opts.very_degraded) in bch2_fs_may_start()
1518 if (c->opts.degraded) in bch2_fs_may_start()
1521 if (!c->opts.degraded && in bch2_fs_may_start()
1522 !c->opts.very_degraded) { in bch2_fs_may_start()
1523 mutex_lock(&c->sb_lock); in bch2_fs_may_start()
1525 for (i = 0; i < c->disk_sb.sb->nr_devices; i++) { in bch2_fs_may_start()
1526 if (!bch2_member_exists(c->disk_sb.sb, i)) in bch2_fs_may_start()
1529 ca = bch2_dev_locked(c, i); in bch2_fs_may_start()
1534 mutex_unlock(&c->sb_lock); in bch2_fs_may_start()
1538 mutex_unlock(&c->sb_lock); in bch2_fs_may_start()
1541 return bch2_have_enough_devs(c, bch2_online_devs(c), flags, true); in bch2_fs_may_start()
1544 static void __bch2_dev_read_only(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_read_only() argument
1549 bch2_dev_allocator_remove(c, ca); in __bch2_dev_read_only()
1550 bch2_recalc_capacity(c); in __bch2_dev_read_only()
1551 bch2_dev_journal_stop(&c->journal, ca); in __bch2_dev_read_only()
1554 static void __bch2_dev_read_write(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_read_write() argument
1556 lockdep_assert_held(&c->state_lock); in __bch2_dev_read_write()
1560 bch2_dev_allocator_add(c, ca); in __bch2_dev_read_write()
1561 bch2_recalc_capacity(c); in __bch2_dev_read_write()
1565 int __bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca, in __bch2_dev_set_state() argument
1574 if (!bch2_dev_state_allowed(c, ca, new_state, flags)) in __bch2_dev_set_state()
1578 __bch2_dev_read_only(c, ca); in __bch2_dev_set_state()
1582 mutex_lock(&c->sb_lock); in __bch2_dev_set_state()
1583 m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); in __bch2_dev_set_state()
1585 bch2_write_super(c); in __bch2_dev_set_state()
1586 mutex_unlock(&c->sb_lock); in __bch2_dev_set_state()
1589 __bch2_dev_read_write(c, ca); in __bch2_dev_set_state()
1591 rebalance_wakeup(c); in __bch2_dev_set_state()
1596 int bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_set_state() argument
1601 down_write(&c->state_lock); in bch2_dev_set_state()
1602 ret = __bch2_dev_set_state(c, ca, new_state, flags); in bch2_dev_set_state()
1603 up_write(&c->state_lock); in bch2_dev_set_state()
1610 int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) in bch2_dev_remove() argument
1616 down_write(&c->state_lock); in bch2_dev_remove()
1624 if (!bch2_dev_state_allowed(c, ca, BCH_MEMBER_STATE_failed, flags)) { in bch2_dev_remove()
1630 __bch2_dev_read_only(c, ca); in bch2_dev_remove()
1632 ret = bch2_dev_data_drop(c, ca->dev_idx, flags); in bch2_dev_remove()
1637 ret = bch2_dev_remove_alloc(c, ca); in bch2_dev_remove()
1646 bch2_journal_flush_all_pins(&c->journal); in bch2_dev_remove()
1652 ret = bch2_journal_flush_device_pins(&c->journal, ca->dev_idx); in bch2_dev_remove()
1657 ret = bch2_journal_flush(&c->journal); in bch2_dev_remove()
1662 ret = bch2_replicas_gc2(c); in bch2_dev_remove()
1667 data = bch2_dev_has_data(c, ca); in bch2_dev_remove()
1678 __bch2_dev_offline(c, ca); in bch2_dev_remove()
1680 mutex_lock(&c->sb_lock); in bch2_dev_remove()
1681 rcu_assign_pointer(c->devs[ca->dev_idx], NULL); in bch2_dev_remove()
1682 mutex_unlock(&c->sb_lock); in bch2_dev_remove()
1698 mutex_lock(&c->sb_lock); in bch2_dev_remove()
1699 m = bch2_members_v2_get_mut(c->disk_sb.sb, dev_idx); in bch2_dev_remove()
1702 bch2_write_super(c); in bch2_dev_remove()
1704 mutex_unlock(&c->sb_lock); in bch2_dev_remove()
1705 up_write(&c->state_lock); in bch2_dev_remove()
1710 __bch2_dev_read_write(c, ca); in bch2_dev_remove()
1711 up_write(&c->state_lock); in bch2_dev_remove()
1716 int bch2_dev_add(struct bch_fs *c, const char *path) in bch2_dev_add() argument
1726 bch_err_msg(c, ret, "reading super"); in bch2_dev_add()
1740 ret = bch2_dev_may_add(sb.sb, c); in bch2_dev_add()
1744 ca = __bch2_dev_alloc(c, &dev_mi); in bch2_dev_add()
1755 bch_err_msg(c, ret, "allocating journal"); in bch2_dev_add()
1759 down_write(&c->state_lock); in bch2_dev_add()
1760 mutex_lock(&c->sb_lock); in bch2_dev_add()
1762 ret = bch2_sb_from_fs(c, ca); in bch2_dev_add()
1763 bch_err_msg(c, ret, "setting up new superblock"); in bch2_dev_add()
1770 ret = bch2_sb_member_alloc(c); in bch2_dev_add()
1772 bch_err_msg(c, ret, "setting up new superblock"); in bch2_dev_add()
1780 *bch2_members_v2_get_mut(c->disk_sb.sb, dev_idx) = dev_mi; in bch2_dev_add()
1783 bch2_dev_attach(c, ca, dev_idx); in bch2_dev_add()
1786 ret = __bch2_dev_group_set(c, ca, label.buf); in bch2_dev_add()
1787 bch_err_msg(c, ret, "creating new label"); in bch2_dev_add()
1792 bch2_write_super(c); in bch2_dev_add()
1793 mutex_unlock(&c->sb_lock); in bch2_dev_add()
1799 ret = bch2_trans_mark_dev_sb(c, ca, BTREE_TRIGGER_transactional); in bch2_dev_add()
1804 ret = bch2_fs_freespace_init(c); in bch2_dev_add()
1812 __bch2_dev_read_write(c, ca); in bch2_dev_add()
1814 up_write(&c->state_lock); in bch2_dev_add()
1818 mutex_unlock(&c->sb_lock); in bch2_dev_add()
1819 up_write(&c->state_lock); in bch2_dev_add()
1826 bch_err_fn(c, ret); in bch2_dev_add()
1829 up_write(&c->state_lock); in bch2_dev_add()
1835 int bch2_dev_online(struct bch_fs *c, const char *path) in bch2_dev_online() argument
1843 down_write(&c->state_lock); in bch2_dev_online()
1847 up_write(&c->state_lock); in bch2_dev_online()
1853 ret = bch2_dev_in_fs(&c->disk_sb, &sb, &c->opts); in bch2_dev_online()
1854 bch_err_msg(c, ret, "bringing %s online", path); in bch2_dev_online()
1858 ret = bch2_dev_attach_bdev(c, &sb); in bch2_dev_online()
1862 ca = bch2_dev_locked(c, dev_idx); in bch2_dev_online()
1864 ret = bch2_trans_mark_dev_sb(c, ca, BTREE_TRIGGER_transactional); in bch2_dev_online()
1865 bch_err_msg(c, ret, "bringing %s online: error from bch2_trans_mark_dev_sb", path); in bch2_dev_online()
1870 __bch2_dev_read_write(c, ca); in bch2_dev_online()
1873 ret = bch2_dev_freespace_init(c, ca, 0, ca->mi.nbuckets); in bch2_dev_online()
1886 mutex_lock(&c->sb_lock); in bch2_dev_online()
1887 bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx)->last_mount = in bch2_dev_online()
1889 bch2_write_super(c); in bch2_dev_online()
1890 mutex_unlock(&c->sb_lock); in bch2_dev_online()
1892 up_write(&c->state_lock); in bch2_dev_online()
1895 up_write(&c->state_lock); in bch2_dev_online()
1900 int bch2_dev_offline(struct bch_fs *c, struct bch_dev *ca, int flags) in bch2_dev_offline() argument
1902 down_write(&c->state_lock); in bch2_dev_offline()
1906 up_write(&c->state_lock); in bch2_dev_offline()
1910 if (!bch2_dev_state_allowed(c, ca, BCH_MEMBER_STATE_failed, flags)) { in bch2_dev_offline()
1912 up_write(&c->state_lock); in bch2_dev_offline()
1916 __bch2_dev_offline(c, ca); in bch2_dev_offline()
1918 up_write(&c->state_lock); in bch2_dev_offline()
1922 int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) in bch2_dev_resize() argument
1928 down_write(&c->state_lock); in bch2_dev_resize()
1952 ret = bch2_dev_buckets_resize(c, ca, nbuckets); in bch2_dev_resize()
1957 ret = bch2_trans_mark_dev_sb(c, ca, BTREE_TRIGGER_transactional); in bch2_dev_resize()
1961 mutex_lock(&c->sb_lock); in bch2_dev_resize()
1962 m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); in bch2_dev_resize()
1965 bch2_write_super(c); in bch2_dev_resize()
1966 mutex_unlock(&c->sb_lock); in bch2_dev_resize()
1978 bch2_dev_freespace_init(c, ca, old_nbuckets, nbuckets); in bch2_dev_resize()
1983 bch2_recalc_capacity(c); in bch2_dev_resize()
1985 up_write(&c->state_lock); in bch2_dev_resize()
1990 struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *name) in bch2_dev_lookup() argument
1995 for_each_member_device(c, ca) in bch2_dev_lookup()
2013 struct bch_fs *c = NULL; in bch2_fs_open() local
2065 c = bch2_fs_alloc(best->sb, opts); in bch2_fs_open()
2066 ret = PTR_ERR_OR_ZERO(c); in bch2_fs_open()
2070 down_write(&c->state_lock); in bch2_fs_open()
2072 ret = bch2_dev_attach_bdev(c, sb); in bch2_fs_open()
2074 up_write(&c->state_lock); in bch2_fs_open()
2078 up_write(&c->state_lock); in bch2_fs_open()
2080 if (!bch2_fs_may_start(c)) { in bch2_fs_open()
2085 if (!c->opts.nostart) { in bch2_fs_open()
2086 ret = bch2_fs_start(c); in bch2_fs_open()
2096 return c; in bch2_fs_open()
2101 if (!IS_ERR_OR_NULL(c)) in bch2_fs_open()
2102 bch2_fs_stop(c); in bch2_fs_open()
2103 c = ERR_PTR(ret); in bch2_fs_open()