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, "%sclean shutdown 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 bool bch2_fs_emergency_read_only_locked(struct bch_fs *c) in bch2_fs_emergency_read_only_locked() argument
416 bool ret = !test_and_set_bit(BCH_FS_emergency_ro, &c->flags); in bch2_fs_emergency_read_only_locked()
418 bch2_journal_halt_locked(&c->journal); in bch2_fs_emergency_read_only_locked()
419 bch2_fs_read_only_async(c); in bch2_fs_emergency_read_only_locked()
425 static int bch2_fs_read_write_late(struct bch_fs *c) in bch2_fs_read_write_late() argument
436 ret = bch2_copygc_start(c); in bch2_fs_read_write_late()
438 bch_err(c, "error starting copygc thread"); in bch2_fs_read_write_late()
442 ret = bch2_rebalance_start(c); in bch2_fs_read_write_late()
444 bch_err(c, "error starting rebalance thread"); in bch2_fs_read_write_late()
451 static int __bch2_fs_read_write(struct bch_fs *c, bool early) in __bch2_fs_read_write() argument
455 BUG_ON(!test_bit(BCH_FS_may_go_rw, &c->flags)); in __bch2_fs_read_write()
457 if (test_bit(BCH_FS_initial_gc_unfixed, &c->flags)) { in __bch2_fs_read_write()
458 bch_err(c, "cannot go rw, unfixed btree errors"); in __bch2_fs_read_write()
462 if (test_bit(BCH_FS_rw, &c->flags)) in __bch2_fs_read_write()
465 bch_info(c, "going read-write"); in __bch2_fs_read_write()
467 ret = bch2_sb_members_v2_init(c); in __bch2_fs_read_write()
471 ret = bch2_fs_mark_dirty(c); in __bch2_fs_read_write()
475 clear_bit(BCH_FS_clean_shutdown, &c->flags); in __bch2_fs_read_write()
483 set_bit(JOURNAL_need_flush_write, &c->journal.flags); in __bch2_fs_read_write()
484 set_bit(JOURNAL_running, &c->journal.flags); in __bch2_fs_read_write()
486 for_each_rw_member(c, ca) in __bch2_fs_read_write()
487 bch2_dev_allocator_add(c, ca); in __bch2_fs_read_write()
488 bch2_recalc_capacity(c); in __bch2_fs_read_write()
490 set_bit(BCH_FS_rw, &c->flags); in __bch2_fs_read_write()
491 set_bit(BCH_FS_was_rw, &c->flags); in __bch2_fs_read_write()
494 percpu_ref_reinit(&c->writes); in __bch2_fs_read_write()
497 BUG_ON(atomic_long_read(&c->writes[i])); in __bch2_fs_read_write()
498 atomic_long_inc(&c->writes[i]); in __bch2_fs_read_write()
502 ret = bch2_journal_reclaim_start(&c->journal); in __bch2_fs_read_write()
507 ret = bch2_fs_read_write_late(c); in __bch2_fs_read_write()
512 bch2_do_discards(c); in __bch2_fs_read_write()
513 bch2_do_invalidates(c); in __bch2_fs_read_write()
514 bch2_do_stripe_deletes(c); in __bch2_fs_read_write()
515 bch2_do_pending_node_rewrites(c); in __bch2_fs_read_write()
518 if (test_bit(BCH_FS_rw, &c->flags)) in __bch2_fs_read_write()
519 bch2_fs_read_only(c); in __bch2_fs_read_write()
521 __bch2_fs_read_only(c); in __bch2_fs_read_write()
525 int bch2_fs_read_write(struct bch_fs *c) in bch2_fs_read_write() argument
527 if (c->opts.recovery_pass_last && in bch2_fs_read_write()
528 c->opts.recovery_pass_last < BCH_RECOVERY_PASS_journal_replay) in bch2_fs_read_write()
531 if (c->opts.nochanges) in bch2_fs_read_write()
534 return __bch2_fs_read_write(c, false); in bch2_fs_read_write()
537 int bch2_fs_read_write_early(struct bch_fs *c) in bch2_fs_read_write_early() argument
539 lockdep_assert_held(&c->state_lock); in bch2_fs_read_write_early()
541 return __bch2_fs_read_write(c, true); in bch2_fs_read_write_early()
546 static void __bch2_fs_free(struct bch_fs *c) in __bch2_fs_free() argument
549 bch2_time_stats_exit(&c->times[i]); in __bch2_fs_free()
551 bch2_find_btree_nodes_exit(&c->found_btree_nodes); in __bch2_fs_free()
552 bch2_free_pending_node_rewrites(c); in __bch2_fs_free()
553 bch2_fs_accounting_exit(c); in __bch2_fs_free()
554 bch2_fs_sb_errors_exit(c); in __bch2_fs_free()
555 bch2_fs_counters_exit(c); in __bch2_fs_free()
556 bch2_fs_snapshots_exit(c); in __bch2_fs_free()
557 bch2_fs_quota_exit(c); in __bch2_fs_free()
558 bch2_fs_fs_io_direct_exit(c); in __bch2_fs_free()
559 bch2_fs_fs_io_buffered_exit(c); in __bch2_fs_free()
560 bch2_fs_fsio_exit(c); in __bch2_fs_free()
561 bch2_fs_vfs_exit(c); in __bch2_fs_free()
562 bch2_fs_ec_exit(c); in __bch2_fs_free()
563 bch2_fs_encryption_exit(c); in __bch2_fs_free()
564 bch2_fs_nocow_locking_exit(c); in __bch2_fs_free()
565 bch2_fs_io_write_exit(c); in __bch2_fs_free()
566 bch2_fs_io_read_exit(c); in __bch2_fs_free()
567 bch2_fs_buckets_waiting_for_journal_exit(c); in __bch2_fs_free()
568 bch2_fs_btree_interior_update_exit(c); in __bch2_fs_free()
569 bch2_fs_btree_key_cache_exit(&c->btree_key_cache); in __bch2_fs_free()
570 bch2_fs_btree_cache_exit(c); in __bch2_fs_free()
571 bch2_fs_btree_iter_exit(c); in __bch2_fs_free()
572 bch2_fs_replicas_exit(c); in __bch2_fs_free()
573 bch2_fs_journal_exit(&c->journal); in __bch2_fs_free()
574 bch2_io_clock_exit(&c->io_clock[WRITE]); in __bch2_fs_free()
575 bch2_io_clock_exit(&c->io_clock[READ]); in __bch2_fs_free()
576 bch2_fs_compress_exit(c); in __bch2_fs_free()
577 bch2_fs_btree_gc_exit(c); in __bch2_fs_free()
578 bch2_journal_keys_put_initial(c); in __bch2_fs_free()
579 bch2_find_btree_nodes_exit(&c->found_btree_nodes); in __bch2_fs_free()
580 BUG_ON(atomic_read(&c->journal_keys.ref)); in __bch2_fs_free()
581 bch2_fs_btree_write_buffer_exit(c); in __bch2_fs_free()
582 percpu_free_rwsem(&c->mark_lock); in __bch2_fs_free()
583 if (c->online_reserved) { in __bch2_fs_free()
584 u64 v = percpu_u64_get(c->online_reserved); in __bch2_fs_free()
586 free_percpu(c->online_reserved); in __bch2_fs_free()
589 darray_exit(&c->btree_roots_extra); in __bch2_fs_free()
590 free_percpu(c->pcpu); in __bch2_fs_free()
591 free_percpu(c->usage); in __bch2_fs_free()
592 mempool_exit(&c->large_bkey_pool); in __bch2_fs_free()
593 mempool_exit(&c->btree_bounce_pool); in __bch2_fs_free()
594 bioset_exit(&c->btree_bio); in __bch2_fs_free()
595 mempool_exit(&c->fill_iter); in __bch2_fs_free()
597 percpu_ref_exit(&c->writes); in __bch2_fs_free()
599 kfree(rcu_dereference_protected(c->disk_groups, 1)); in __bch2_fs_free()
600 kfree(c->journal_seq_blacklist_table); in __bch2_fs_free()
602 if (c->write_ref_wq) in __bch2_fs_free()
603 destroy_workqueue(c->write_ref_wq); in __bch2_fs_free()
604 if (c->btree_write_submit_wq) in __bch2_fs_free()
605 destroy_workqueue(c->btree_write_submit_wq); in __bch2_fs_free()
606 if (c->btree_read_complete_wq) in __bch2_fs_free()
607 destroy_workqueue(c->btree_read_complete_wq); in __bch2_fs_free()
608 if (c->copygc_wq) in __bch2_fs_free()
609 destroy_workqueue(c->copygc_wq); in __bch2_fs_free()
610 if (c->btree_io_complete_wq) in __bch2_fs_free()
611 destroy_workqueue(c->btree_io_complete_wq); in __bch2_fs_free()
612 if (c->btree_update_wq) in __bch2_fs_free()
613 destroy_workqueue(c->btree_update_wq); in __bch2_fs_free()
615 bch2_free_super(&c->disk_sb); in __bch2_fs_free()
616 kvfree(c); in __bch2_fs_free()
622 struct bch_fs *c = container_of(kobj, struct bch_fs, kobj); in bch2_fs_release() local
624 __bch2_fs_free(c); in bch2_fs_release()
627 void __bch2_fs_stop(struct bch_fs *c) in __bch2_fs_stop() argument
629 bch_verbose(c, "shutting down"); in __bch2_fs_stop()
631 set_bit(BCH_FS_stopping, &c->flags); in __bch2_fs_stop()
633 down_write(&c->state_lock); in __bch2_fs_stop()
634 bch2_fs_read_only(c); in __bch2_fs_stop()
635 up_write(&c->state_lock); in __bch2_fs_stop()
637 for_each_member_device(c, ca) in __bch2_fs_stop()
640 if (c->kobj.state_in_sysfs) in __bch2_fs_stop()
641 kobject_del(&c->kobj); in __bch2_fs_stop()
643 bch2_fs_debug_exit(c); in __bch2_fs_stop()
644 bch2_fs_chardev_exit(c); in __bch2_fs_stop()
646 bch2_ro_ref_put(c); in __bch2_fs_stop()
647 wait_event(c->ro_ref_wait, !refcount_read(&c->ro_ref)); in __bch2_fs_stop()
649 kobject_put(&c->counters_kobj); in __bch2_fs_stop()
650 kobject_put(&c->time_stats); in __bch2_fs_stop()
651 kobject_put(&c->opts_dir); in __bch2_fs_stop()
652 kobject_put(&c->internal); in __bch2_fs_stop()
655 bch2_btree_flush_all_reads(c); in __bch2_fs_stop()
657 for_each_member_device(c, ca) in __bch2_fs_stop()
660 cancel_work_sync(&c->read_only_work); in __bch2_fs_stop()
663 void bch2_fs_free(struct bch_fs *c) in bch2_fs_free() argument
668 list_del(&c->list); in bch2_fs_free()
671 closure_sync(&c->cl); in bch2_fs_free()
672 closure_debug_destroy(&c->cl); in bch2_fs_free()
674 for (i = 0; i < c->sb.nr_devices; i++) { in bch2_fs_free()
675 struct bch_dev *ca = rcu_dereference_protected(c->devs[i], true); in bch2_fs_free()
684 bch_verbose(c, "shutdown complete"); in bch2_fs_free()
686 kobject_put(&c->kobj); in bch2_fs_free()
689 void bch2_fs_stop(struct bch_fs *c) in bch2_fs_stop() argument
691 __bch2_fs_stop(c); in bch2_fs_stop()
692 bch2_fs_free(c); in bch2_fs_stop()
695 static int bch2_fs_online(struct bch_fs *c) in bch2_fs_online() argument
701 if (__bch2_uuid_to_fs(c->sb.uuid)) { in bch2_fs_online()
702 bch_err(c, "filesystem UUID already open"); in bch2_fs_online()
706 ret = bch2_fs_chardev_init(c); in bch2_fs_online()
708 bch_err(c, "error creating character device"); in bch2_fs_online()
712 bch2_fs_debug_init(c); in bch2_fs_online()
714 ret = kobject_add(&c->kobj, NULL, "%pU", c->sb.user_uuid.b) ?: in bch2_fs_online()
715 kobject_add(&c->internal, &c->kobj, "internal") ?: in bch2_fs_online()
716 kobject_add(&c->opts_dir, &c->kobj, "options") ?: in bch2_fs_online()
718 kobject_add(&c->time_stats, &c->kobj, "time_stats") ?: in bch2_fs_online()
720 kobject_add(&c->counters_kobj, &c->kobj, "counters") ?: in bch2_fs_online()
721 bch2_opts_create_sysfs_files(&c->opts_dir); in bch2_fs_online()
723 bch_err(c, "error creating sysfs objects"); in bch2_fs_online()
727 down_write(&c->state_lock); in bch2_fs_online()
729 for_each_member_device(c, ca) { in bch2_fs_online()
730 ret = bch2_dev_sysfs_online(c, ca); in bch2_fs_online()
732 bch_err(c, "error creating sysfs objects"); in bch2_fs_online()
738 BUG_ON(!list_empty(&c->list)); in bch2_fs_online()
739 list_add(&c->list, &bch_fs_list); in bch2_fs_online()
741 up_write(&c->state_lock); in bch2_fs_online()
747 struct bch_fs *c; in bch2_fs_alloc() local
752 c = kvmalloc(sizeof(struct bch_fs), GFP_KERNEL|__GFP_ZERO); in bch2_fs_alloc()
753 if (!c) { in bch2_fs_alloc()
754 c = ERR_PTR(-BCH_ERR_ENOMEM_fs_alloc); in bch2_fs_alloc()
758 c->stdio = (void *)(unsigned long) opts.stdio; in bch2_fs_alloc()
762 closure_init(&c->cl, NULL); in bch2_fs_alloc()
764 c->kobj.kset = bcachefs_kset; in bch2_fs_alloc()
765 kobject_init(&c->kobj, &bch2_fs_ktype); in bch2_fs_alloc()
766 kobject_init(&c->internal, &bch2_fs_internal_ktype); in bch2_fs_alloc()
767 kobject_init(&c->opts_dir, &bch2_fs_opts_dir_ktype); in bch2_fs_alloc()
768 kobject_init(&c->time_stats, &bch2_fs_time_stats_ktype); in bch2_fs_alloc()
769 kobject_init(&c->counters_kobj, &bch2_fs_counters_ktype); in bch2_fs_alloc()
771 c->minor = -1; in bch2_fs_alloc()
772 c->disk_sb.fs_sb = true; in bch2_fs_alloc()
774 init_rwsem(&c->state_lock); in bch2_fs_alloc()
775 mutex_init(&c->sb_lock); in bch2_fs_alloc()
776 mutex_init(&c->replicas_gc_lock); in bch2_fs_alloc()
777 mutex_init(&c->btree_root_lock); in bch2_fs_alloc()
778 INIT_WORK(&c->read_only_work, bch2_fs_read_only_work); in bch2_fs_alloc()
780 refcount_set(&c->ro_ref, 1); in bch2_fs_alloc()
781 init_waitqueue_head(&c->ro_ref_wait); in bch2_fs_alloc()
782 spin_lock_init(&c->recovery_pass_lock); in bch2_fs_alloc()
783 sema_init(&c->online_fsck_mutex, 1); in bch2_fs_alloc()
786 bch2_time_stats_init(&c->times[i]); in bch2_fs_alloc()
788 bch2_fs_copygc_init(c); in bch2_fs_alloc()
789 bch2_fs_btree_key_cache_init_early(&c->btree_key_cache); in bch2_fs_alloc()
790 bch2_fs_btree_iter_init_early(c); in bch2_fs_alloc()
791 bch2_fs_btree_interior_update_init_early(c); in bch2_fs_alloc()
792 bch2_fs_journal_keys_init(c); in bch2_fs_alloc()
793 bch2_fs_allocator_background_init(c); in bch2_fs_alloc()
794 bch2_fs_allocator_foreground_init(c); in bch2_fs_alloc()
795 bch2_fs_rebalance_init(c); in bch2_fs_alloc()
796 bch2_fs_quota_init(c); in bch2_fs_alloc()
797 bch2_fs_ec_init_early(c); in bch2_fs_alloc()
798 bch2_fs_move_init(c); in bch2_fs_alloc()
799 bch2_fs_sb_errors_init_early(c); in bch2_fs_alloc()
801 INIT_LIST_HEAD(&c->list); in bch2_fs_alloc()
803 mutex_init(&c->bio_bounce_pages_lock); in bch2_fs_alloc()
804 mutex_init(&c->snapshot_table_lock); in bch2_fs_alloc()
805 init_rwsem(&c->snapshot_create_lock); in bch2_fs_alloc()
807 spin_lock_init(&c->btree_write_error_lock); in bch2_fs_alloc()
809 INIT_LIST_HEAD(&c->journal_iters); in bch2_fs_alloc()
811 INIT_LIST_HEAD(&c->fsck_error_msgs); in bch2_fs_alloc()
812 mutex_init(&c->fsck_error_msgs_lock); in bch2_fs_alloc()
814 seqcount_init(&c->usage_lock); in bch2_fs_alloc()
816 sema_init(&c->io_in_flight, 128); in bch2_fs_alloc()
818 INIT_LIST_HEAD(&c->vfs_inodes_list); in bch2_fs_alloc()
819 mutex_init(&c->vfs_inodes_lock); in bch2_fs_alloc()
821 c->journal.flush_write_time = &c->times[BCH_TIME_journal_flush_write]; in bch2_fs_alloc()
822 c->journal.noflush_write_time = &c->times[BCH_TIME_journal_noflush_write]; in bch2_fs_alloc()
823 c->journal.flush_seq_time = &c->times[BCH_TIME_journal_flush_seq]; in bch2_fs_alloc()
825 bch2_fs_btree_cache_init_early(&c->btree_cache); in bch2_fs_alloc()
827 mutex_init(&c->sectors_available_lock); in bch2_fs_alloc()
829 ret = percpu_init_rwsem(&c->mark_lock); in bch2_fs_alloc()
833 mutex_lock(&c->sb_lock); in bch2_fs_alloc()
834 ret = bch2_sb_to_fs(c, sb); in bch2_fs_alloc()
835 mutex_unlock(&c->sb_lock); in bch2_fs_alloc()
840 pr_uuid(&name, c->sb.user_uuid.b); in bch2_fs_alloc()
845 strscpy(c->name, name.buf, sizeof(c->name)); in bch2_fs_alloc()
857 c->opts = bch2_opts_default; in bch2_fs_alloc()
858 ret = bch2_opts_from_sb(&c->opts, sb); in bch2_fs_alloc()
862 bch2_opts_apply(&c->opts, opts); in bch2_fs_alloc()
864 c->btree_key_cache_btrees |= 1U << BTREE_ID_alloc; in bch2_fs_alloc()
865 if (c->opts.inodes_use_key_cache) in bch2_fs_alloc()
866 c->btree_key_cache_btrees |= 1U << BTREE_ID_inodes; in bch2_fs_alloc()
867 c->btree_key_cache_btrees |= 1U << BTREE_ID_logged_ops; in bch2_fs_alloc()
869 c->block_bits = ilog2(block_sectors(c)); in bch2_fs_alloc()
870 c->btree_foreground_merge_threshold = BTREE_FOREGROUND_MERGE_THRESHOLD(c); in bch2_fs_alloc()
873 bch_err(c, "fs_alloc fault injected"); in bch2_fs_alloc()
879 (btree_blocks(c) + 1) * 2 * in bch2_fs_alloc()
882 if (!(c->btree_update_wq = alloc_workqueue("bcachefs", in bch2_fs_alloc()
884 !(c->btree_io_complete_wq = alloc_workqueue("bcachefs_btree_io", in bch2_fs_alloc()
886 !(c->copygc_wq = alloc_workqueue("bcachefs_copygc", in bch2_fs_alloc()
888 !(c->btree_read_complete_wq = alloc_workqueue("bcachefs_btree_read_complete", in bch2_fs_alloc()
890 !(c->btree_write_submit_wq = alloc_workqueue("bcachefs_btree_write_sumit", in bch2_fs_alloc()
892 !(c->write_ref_wq = alloc_workqueue("bcachefs_write_ref", in bch2_fs_alloc()
895 percpu_ref_init(&c->writes, bch2_writes_disabled, in bch2_fs_alloc()
898 mempool_init_kmalloc_pool(&c->fill_iter, 1, iter_size) || in bch2_fs_alloc()
899 bioset_init(&c->btree_bio, 1, in bch2_fs_alloc()
903 !(c->pcpu = alloc_percpu(struct bch_fs_pcpu)) || in bch2_fs_alloc()
904 !(c->usage = alloc_percpu(struct bch_fs_usage_base)) || in bch2_fs_alloc()
905 !(c->online_reserved = alloc_percpu(u64)) || in bch2_fs_alloc()
906 mempool_init_kvmalloc_pool(&c->btree_bounce_pool, 1, in bch2_fs_alloc()
907 c->opts.btree_node_size) || in bch2_fs_alloc()
908 mempool_init_kmalloc_pool(&c->large_bkey_pool, 1, 2048)) { in bch2_fs_alloc()
913 ret = bch2_fs_counters_init(c) ?: in bch2_fs_alloc()
914 bch2_fs_sb_errors_init(c) ?: in bch2_fs_alloc()
915 bch2_io_clock_init(&c->io_clock[READ]) ?: in bch2_fs_alloc()
916 bch2_io_clock_init(&c->io_clock[WRITE]) ?: in bch2_fs_alloc()
917 bch2_fs_journal_init(&c->journal) ?: in bch2_fs_alloc()
918 bch2_fs_btree_iter_init(c) ?: in bch2_fs_alloc()
919 bch2_fs_btree_cache_init(c) ?: in bch2_fs_alloc()
920 bch2_fs_btree_key_cache_init(&c->btree_key_cache) ?: in bch2_fs_alloc()
921 bch2_fs_btree_interior_update_init(c) ?: in bch2_fs_alloc()
922 bch2_fs_btree_gc_init(c) ?: in bch2_fs_alloc()
923 bch2_fs_buckets_waiting_for_journal_init(c) ?: in bch2_fs_alloc()
924 bch2_fs_btree_write_buffer_init(c) ?: in bch2_fs_alloc()
925 bch2_fs_subvolumes_init(c) ?: in bch2_fs_alloc()
926 bch2_fs_io_read_init(c) ?: in bch2_fs_alloc()
927 bch2_fs_io_write_init(c) ?: in bch2_fs_alloc()
928 bch2_fs_nocow_locking_init(c) ?: in bch2_fs_alloc()
929 bch2_fs_encryption_init(c) ?: in bch2_fs_alloc()
930 bch2_fs_compress_init(c) ?: in bch2_fs_alloc()
931 bch2_fs_ec_init(c) ?: in bch2_fs_alloc()
932 bch2_fs_vfs_init(c) ?: in bch2_fs_alloc()
933 bch2_fs_fsio_init(c) ?: in bch2_fs_alloc()
934 bch2_fs_fs_io_buffered_init(c) ?: in bch2_fs_alloc()
935 bch2_fs_fs_io_direct_init(c); in bch2_fs_alloc()
939 for (i = 0; i < c->sb.nr_devices; i++) { in bch2_fs_alloc()
940 if (!bch2_member_exists(c->disk_sb.sb, i)) in bch2_fs_alloc()
942 ret = bch2_dev_alloc(c, i); in bch2_fs_alloc()
947 bch2_journal_entry_res_resize(&c->journal, in bch2_fs_alloc()
948 &c->btree_root_journal_res, in bch2_fs_alloc()
950 bch2_journal_entry_res_resize(&c->journal, in bch2_fs_alloc()
951 &c->clock_journal_res, in bch2_fs_alloc()
955 ret = bch2_fs_online(c); in bch2_fs_alloc()
961 return c; in bch2_fs_alloc()
963 bch2_fs_free(c); in bch2_fs_alloc()
964 c = ERR_PTR(ret); in bch2_fs_alloc()
969 static void print_mount_opts(struct bch_fs *c) in print_mount_opts() argument
976 bch2_version_to_text(&p, c->sb.version); in print_mount_opts()
978 if (c->opts.read_only) { in print_mount_opts()
986 u64 v = bch2_opt_get_by_id(&c->opts, i); in print_mount_opts()
996 bch2_opt_to_text(&p, c, c->disk_sb.sb, opt, v, OPT_SHOW_MOUNT_STYLE); in print_mount_opts()
999 bch_info(c, "%s", p.buf); in print_mount_opts()
1003 int bch2_fs_start(struct bch_fs *c) in bch2_fs_start() argument
1008 print_mount_opts(c); in bch2_fs_start()
1010 down_write(&c->state_lock); in bch2_fs_start()
1012 BUG_ON(test_bit(BCH_FS_started, &c->flags)); in bch2_fs_start()
1014 mutex_lock(&c->sb_lock); in bch2_fs_start()
1016 ret = bch2_sb_members_v2_init(c); in bch2_fs_start()
1018 mutex_unlock(&c->sb_lock); in bch2_fs_start()
1022 for_each_online_member(c, ca) in bch2_fs_start()
1023 bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx)->last_mount = cpu_to_le64(now); in bch2_fs_start()
1026 bch2_sb_field_get_minsize(&c->disk_sb, ext, sizeof(*ext) / sizeof(u64)); in bch2_fs_start()
1027 mutex_unlock(&c->sb_lock); in bch2_fs_start()
1030 bch_err(c, "insufficient space in superblock for sb_field_ext"); in bch2_fs_start()
1035 for_each_rw_member(c, ca) in bch2_fs_start()
1036 bch2_dev_allocator_add(c, ca); in bch2_fs_start()
1037 bch2_recalc_capacity(c); in bch2_fs_start()
1039 c->recovery_task = current; in bch2_fs_start()
1040 ret = BCH_SB_INITIALIZED(c->disk_sb.sb) in bch2_fs_start()
1041 ? bch2_fs_recovery(c) in bch2_fs_start()
1042 : bch2_fs_initialize(c); in bch2_fs_start()
1043 c->recovery_task = NULL; in bch2_fs_start()
1048 ret = bch2_opts_check_may_set(c); in bch2_fs_start()
1053 bch_err(c, "fs_start fault injected"); in bch2_fs_start()
1058 set_bit(BCH_FS_started, &c->flags); in bch2_fs_start()
1060 if (c->opts.read_only) { in bch2_fs_start()
1061 bch2_fs_read_only(c); in bch2_fs_start()
1063 ret = !test_bit(BCH_FS_rw, &c->flags) in bch2_fs_start()
1064 ? bch2_fs_read_write(c) in bch2_fs_start()
1065 : bch2_fs_read_write_late(c); in bch2_fs_start()
1073 bch_err_msg(c, ret, "starting filesystem"); in bch2_fs_start()
1075 bch_verbose(c, "done starting filesystem"); in bch2_fs_start()
1076 up_write(&c->state_lock); in bch2_fs_start()
1080 static int bch2_dev_may_add(struct bch_sb *sb, struct bch_fs *c) in bch2_dev_may_add() argument
1084 if (le16_to_cpu(sb->block_size) != block_sectors(c)) in bch2_dev_may_add()
1088 BCH_SB_BTREE_NODE_SIZE(c->disk_sb.sb)) in bch2_dev_may_add()
1219 static void __bch2_dev_offline(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_offline() argument
1222 lockdep_assert_held(&c->state_lock); in __bch2_dev_offline()
1227 __bch2_dev_read_only(c, ca); in __bch2_dev_offline()
1264 * code doesn't appear to provide a good method and block/holder.c is in bch2_dev_unlink()
1275 static int bch2_dev_sysfs_online(struct bch_fs *c, struct bch_dev *ca) in bch2_dev_sysfs_online() argument
1279 if (!c->kobj.state_in_sysfs) in bch2_dev_sysfs_online()
1283 ret = kobject_add(&ca->kobj, &c->kobj, in bch2_dev_sysfs_online()
1304 static struct bch_dev *__bch2_dev_alloc(struct bch_fs *c, in __bch2_dev_alloc() argument
1331 ca->mi.bucket_size / btree_sectors(c)); in __bch2_dev_alloc()
1345 bch2_dev_buckets_alloc(c, ca) || in __bch2_dev_alloc()
1355 static void bch2_dev_attach(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_attach() argument
1362 ca->fs = c; in bch2_dev_attach()
1363 rcu_assign_pointer(c->devs[ca->dev_idx], ca); in bch2_dev_attach()
1365 if (bch2_dev_sysfs_online(c, ca)) in bch2_dev_attach()
1369 static int bch2_dev_alloc(struct bch_fs *c, unsigned dev_idx) in bch2_dev_alloc() argument
1371 struct bch_member member = bch2_sb_member_get(c->disk_sb.sb, dev_idx); in bch2_dev_alloc()
1377 ca = __bch2_dev_alloc(c, &member); in bch2_dev_alloc()
1381 ca->fs = c; in bch2_dev_alloc()
1383 bch2_dev_attach(c, ca, dev_idx); in bch2_dev_alloc()
1422 static int bch2_dev_attach_bdev(struct bch_fs *c, struct bch_sb_handle *sb) in bch2_dev_attach_bdev() argument
1427 lockdep_assert_held(&c->state_lock); in bch2_dev_attach_bdev()
1430 le64_to_cpu(c->disk_sb.sb->seq)) in bch2_dev_attach_bdev()
1431 bch2_sb_to_fs(c, sb->sb); in bch2_dev_attach_bdev()
1433 BUG_ON(!bch2_dev_exists(c, sb->sb->dev_idx)); in bch2_dev_attach_bdev()
1435 ca = bch2_dev_locked(c, sb->sb->dev_idx); in bch2_dev_attach_bdev()
1441 bch2_dev_sysfs_online(c, ca); in bch2_dev_attach_bdev()
1446 if (c->sb.nr_devices == 1) in bch2_dev_attach_bdev()
1447 strscpy(c->name, name.buf, sizeof(c->name)); in bch2_dev_attach_bdev()
1452 rebalance_wakeup(c); in bch2_dev_attach_bdev()
1467 bool bch2_dev_state_allowed(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_state_allowed() argument
1473 lockdep_assert_held(&c->state_lock); in bch2_dev_state_allowed()
1483 for_each_member_device(c, ca2) in bch2_dev_state_allowed()
1488 ? c->opts.metadata_replicas in bch2_dev_state_allowed()
1489 : metadata_replicas_required(c), in bch2_dev_state_allowed()
1491 ? c->opts.data_replicas in bch2_dev_state_allowed()
1492 : data_replicas_required(c)); in bch2_dev_state_allowed()
1502 new_online_devs = bch2_online_devs(c); in bch2_dev_state_allowed()
1505 return bch2_have_enough_devs(c, new_online_devs, flags, false); in bch2_dev_state_allowed()
1511 static bool bch2_fs_may_start(struct bch_fs *c) in bch2_fs_may_start() argument
1516 if (c->opts.very_degraded) in bch2_fs_may_start()
1519 if (c->opts.degraded) in bch2_fs_may_start()
1522 if (!c->opts.degraded && in bch2_fs_may_start()
1523 !c->opts.very_degraded) { in bch2_fs_may_start()
1524 mutex_lock(&c->sb_lock); in bch2_fs_may_start()
1526 for (i = 0; i < c->disk_sb.sb->nr_devices; i++) { in bch2_fs_may_start()
1527 if (!bch2_member_exists(c->disk_sb.sb, i)) in bch2_fs_may_start()
1530 ca = bch2_dev_locked(c, i); in bch2_fs_may_start()
1535 mutex_unlock(&c->sb_lock); in bch2_fs_may_start()
1539 mutex_unlock(&c->sb_lock); in bch2_fs_may_start()
1542 return bch2_have_enough_devs(c, bch2_online_devs(c), flags, true); in bch2_fs_may_start()
1545 static void __bch2_dev_read_only(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_read_only() argument
1550 bch2_dev_allocator_remove(c, ca); in __bch2_dev_read_only()
1551 bch2_recalc_capacity(c); in __bch2_dev_read_only()
1552 bch2_dev_journal_stop(&c->journal, ca); in __bch2_dev_read_only()
1555 static void __bch2_dev_read_write(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_read_write() argument
1557 lockdep_assert_held(&c->state_lock); in __bch2_dev_read_write()
1561 bch2_dev_allocator_add(c, ca); in __bch2_dev_read_write()
1562 bch2_recalc_capacity(c); in __bch2_dev_read_write()
1566 int __bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca, in __bch2_dev_set_state() argument
1575 if (!bch2_dev_state_allowed(c, ca, new_state, flags)) in __bch2_dev_set_state()
1579 __bch2_dev_read_only(c, ca); in __bch2_dev_set_state()
1583 mutex_lock(&c->sb_lock); in __bch2_dev_set_state()
1584 m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); in __bch2_dev_set_state()
1586 bch2_write_super(c); in __bch2_dev_set_state()
1587 mutex_unlock(&c->sb_lock); in __bch2_dev_set_state()
1590 __bch2_dev_read_write(c, ca); in __bch2_dev_set_state()
1592 rebalance_wakeup(c); in __bch2_dev_set_state()
1597 int bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_set_state() argument
1602 down_write(&c->state_lock); in bch2_dev_set_state()
1603 ret = __bch2_dev_set_state(c, ca, new_state, flags); in bch2_dev_set_state()
1604 up_write(&c->state_lock); in bch2_dev_set_state()
1611 int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) in bch2_dev_remove() argument
1617 down_write(&c->state_lock); in bch2_dev_remove()
1625 if (!bch2_dev_state_allowed(c, ca, BCH_MEMBER_STATE_failed, flags)) { in bch2_dev_remove()
1631 __bch2_dev_read_only(c, ca); in bch2_dev_remove()
1633 ret = bch2_dev_data_drop(c, ca->dev_idx, flags); in bch2_dev_remove()
1638 ret = bch2_dev_remove_alloc(c, ca); in bch2_dev_remove()
1647 bch2_journal_flush_all_pins(&c->journal); in bch2_dev_remove()
1653 ret = bch2_journal_flush_device_pins(&c->journal, ca->dev_idx); in bch2_dev_remove()
1658 ret = bch2_journal_flush(&c->journal); in bch2_dev_remove()
1663 ret = bch2_replicas_gc2(c); in bch2_dev_remove()
1668 data = bch2_dev_has_data(c, ca); in bch2_dev_remove()
1679 __bch2_dev_offline(c, ca); in bch2_dev_remove()
1681 mutex_lock(&c->sb_lock); in bch2_dev_remove()
1682 rcu_assign_pointer(c->devs[ca->dev_idx], NULL); in bch2_dev_remove()
1683 mutex_unlock(&c->sb_lock); in bch2_dev_remove()
1699 mutex_lock(&c->sb_lock); in bch2_dev_remove()
1700 m = bch2_members_v2_get_mut(c->disk_sb.sb, dev_idx); in bch2_dev_remove()
1703 bch2_write_super(c); in bch2_dev_remove()
1705 mutex_unlock(&c->sb_lock); in bch2_dev_remove()
1706 up_write(&c->state_lock); in bch2_dev_remove()
1711 __bch2_dev_read_write(c, ca); in bch2_dev_remove()
1712 up_write(&c->state_lock); in bch2_dev_remove()
1717 int bch2_dev_add(struct bch_fs *c, const char *path) in bch2_dev_add() argument
1727 bch_err_msg(c, ret, "reading super"); in bch2_dev_add()
1741 ret = bch2_dev_may_add(sb.sb, c); in bch2_dev_add()
1745 ca = __bch2_dev_alloc(c, &dev_mi); in bch2_dev_add()
1755 down_write(&c->state_lock); in bch2_dev_add()
1756 mutex_lock(&c->sb_lock); in bch2_dev_add()
1758 ret = bch2_sb_from_fs(c, ca); in bch2_dev_add()
1759 bch_err_msg(c, ret, "setting up new superblock"); in bch2_dev_add()
1766 ret = bch2_sb_member_alloc(c); in bch2_dev_add()
1768 bch_err_msg(c, ret, "setting up new superblock"); in bch2_dev_add()
1776 *bch2_members_v2_get_mut(c->disk_sb.sb, dev_idx) = dev_mi; in bch2_dev_add()
1779 bch2_dev_attach(c, ca, dev_idx); in bch2_dev_add()
1782 ret = __bch2_dev_group_set(c, ca, label.buf); in bch2_dev_add()
1783 bch_err_msg(c, ret, "creating new label"); in bch2_dev_add()
1788 bch2_write_super(c); in bch2_dev_add()
1789 mutex_unlock(&c->sb_lock); in bch2_dev_add()
1795 ret = bch2_trans_mark_dev_sb(c, ca, BTREE_TRIGGER_transactional); in bch2_dev_add()
1800 ret = bch2_fs_freespace_init(c); in bch2_dev_add()
1806 __bch2_dev_read_write(c, ca); in bch2_dev_add()
1809 bch_err_msg(c, ret, "allocating journal"); in bch2_dev_add()
1813 up_write(&c->state_lock); in bch2_dev_add()
1817 bch_err_fn(c, ret); in bch2_dev_add()
1821 mutex_unlock(&c->sb_lock); in bch2_dev_add()
1822 up_write(&c->state_lock); 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()