Lines Matching full:c

37 void bch2_btree_lost_data(struct bch_fs *c, enum btree_id btree)  in bch2_btree_lost_data()  argument
44 if (!(c->sb.btrees_lost_data & b)) { in bch2_btree_lost_data()
45 bch_err(c, "flagging btree %s lost data", bch2_btree_id_str(btree)); in bch2_btree_lost_data()
47 mutex_lock(&c->sb_lock); in bch2_btree_lost_data()
48 bch2_sb_field_get(c->disk_sb.sb, ext)->btrees_lost_data |= cpu_to_le64(b); in bch2_btree_lost_data()
49 bch2_write_super(c); in bch2_btree_lost_data()
50 mutex_unlock(&c->sb_lock); in bch2_btree_lost_data()
55 static void bch2_reconstruct_alloc(struct bch_fs *c) in bch2_reconstruct_alloc() argument
57 bch2_journal_log_msg(c, "dropping alloc info"); in bch2_reconstruct_alloc()
58 bch_info(c, "dropping and reconstructing all alloc info"); in bch2_reconstruct_alloc()
60 mutex_lock(&c->sb_lock); in bch2_reconstruct_alloc()
61 struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext); in bch2_reconstruct_alloc()
95 c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info); in bch2_reconstruct_alloc()
97c->opts.recovery_passes |= bch2_recovery_passes_from_stable(le64_to_cpu(ext->recovery_passes_requi… in bch2_reconstruct_alloc()
99 bch2_write_super(c); in bch2_reconstruct_alloc()
100 mutex_unlock(&c->sb_lock); in bch2_reconstruct_alloc()
102 bch2_shoot_down_journal_keys(c, BTREE_ID_alloc, in bch2_reconstruct_alloc()
104 bch2_shoot_down_journal_keys(c, BTREE_ID_backpointers, in bch2_reconstruct_alloc()
106 bch2_shoot_down_journal_keys(c, BTREE_ID_need_discard, in bch2_reconstruct_alloc()
108 bch2_shoot_down_journal_keys(c, BTREE_ID_freespace, in bch2_reconstruct_alloc()
110 bch2_shoot_down_journal_keys(c, BTREE_ID_bucket_gens, in bch2_reconstruct_alloc()
252 int bch2_journal_replay(struct bch_fs *c) in bch2_journal_replay() argument
254 struct journal_keys *keys = &c->journal_keys; in bch2_journal_replay()
256 struct journal *j = &c->journal; in bch2_journal_replay()
257 u64 start_seq = c->journal_replay_seq_start; in bch2_journal_replay()
258 u64 end_seq = c->journal_replay_seq_start; in bch2_journal_replay()
264 ret = bch2_journal_log_msg(c, "Starting journal replay (%zu keys in entries %llu-%llu)", in bch2_journal_replay()
273 trans = bch2_trans_get(c); in bch2_journal_replay()
292 if (bch2_fs_fatal_err_on(ret, c, "error replaying accounting; %s", bch2_err_str(ret))) in bch2_journal_replay()
298 set_bit(BCH_FS_accounting_replay_done, &c->flags); in bch2_journal_replay()
316 ret = c->journal.watermark ? -1 : in bch2_journal_replay()
357 bch_err_msg(c, ret, "while replaying key at btree %s level %u:", in bch2_journal_replay()
372 if (!c->opts.retain_recovery_info && in bch2_journal_replay()
373 c->recovery_pass_done >= BCH_RECOVERY_PASS_journal_replay) in bch2_journal_replay()
374 bch2_journal_keys_put_initial(c); in bch2_journal_replay()
383 bch2_journal_flush_all_pins(&c->journal); in bch2_journal_replay()
384 ret = bch2_journal_meta(&c->journal); in bch2_journal_replay()
388 bch2_journal_log_msg(c, "journal replay finished"); in bch2_journal_replay()
393 bch_err_fn(c, ret); in bch2_journal_replay()
399 static int journal_replay_entry_early(struct bch_fs *c, in journal_replay_entry_early() argument
409 c, invalid_btree_id, in journal_replay_entry_early()
414 while (entry->btree_id >= c->btree_roots_extra.nr + BTREE_ID_NR) { in journal_replay_entry_early()
415 ret = darray_push(&c->btree_roots_extra, (struct btree_root) { NULL }); in journal_replay_entry_early()
420 r = bch2_btree_id_root(c, entry->btree_id); in journal_replay_entry_early()
438 atomic64_set(&c->key_version, le64_to_cpu(u->v)); in journal_replay_entry_early()
447 ret = bch2_journal_seq_blacklist_add(c, in journal_replay_entry_early()
456 ret = bch2_journal_seq_blacklist_add(c, in journal_replay_entry_early()
465 atomic64_set(&c->io_clock[clock->rw].now, le64_to_cpu(clock->time)); in journal_replay_entry_early()
472 static int journal_replay_early(struct bch_fs *c, in journal_replay_early() argument
479 int ret = journal_replay_entry_early(c, entry); in journal_replay_early()
487 genradix_for_each(&c->journal_entries, iter, _i) { in journal_replay_early()
494 int ret = journal_replay_entry_early(c, entry); in journal_replay_early()
506 static int read_btree_roots(struct bch_fs *c) in read_btree_roots() argument
510 for (unsigned i = 0; i < btree_id_nr_alive(c); i++) { in read_btree_roots()
511 struct btree_root *r = bch2_btree_id_root(c, i); in read_btree_roots()
516 if (btree_id_is_alloc(i) && c->opts.reconstruct_alloc) in read_btree_roots()
520 c, btree_root_bkey_invalid, in read_btree_roots()
523 mustfix_fsck_err_on((ret = r->error = bch2_btree_root_read(c, i, &r->key, r->level)), in read_btree_roots()
524 c, btree_root_read_error, in read_btree_roots()
528 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_check_allocations); in read_btree_roots()
529 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_check_alloc_info); in read_btree_roots()
530 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_check_lrus); in read_btree_roots()
531 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_check_extents_to_backpointers); in read_btree_roots()
532 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_check_alloc_to_lru_refs); in read_btree_roots()
533 c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info); in read_btree_roots()
535 } else if (!(c->opts.recovery_passes & BIT_ULL(BCH_RECOVERY_PASS_scan_for_btree_nodes))) { in read_btree_roots()
536 bch_info(c, "will run btree node scan"); in read_btree_roots()
537 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_scan_for_btree_nodes); in read_btree_roots()
538 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_check_topology); in read_btree_roots()
542 bch2_btree_lost_data(c, i); in read_btree_roots()
547 struct btree_root *r = bch2_btree_id_root(c, i); in read_btree_roots()
552 bch2_btree_root_alloc_fake(c, i, 0); in read_btree_roots()
559 static bool check_version_upgrade(struct bch_fs *c) in check_version_upgrade() argument
563 bch2_latest_compatible_version(c->sb.version)); in check_version_upgrade()
564 unsigned old_version = c->sb.version_upgrade_complete ?: c->sb.version; in check_version_upgrade()
568 if (c->opts.version_upgrade == BCH_VERSION_UPGRADE_incompatible || in check_version_upgrade()
574 switch (c->opts.version_upgrade) { in check_version_upgrade()
593 if (old_version != c->sb.version) { in check_version_upgrade()
595 bch2_version_to_text(&buf, c->sb.version_upgrade_complete); in check_version_upgrade()
597 bch2_version_to_text(&buf, c->sb.version); in check_version_upgrade()
609 struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext); in check_version_upgrade()
611 bch2_sb_set_upgrade(c, old_version, new_version); in check_version_upgrade()
620 bch_info(c, "%s", buf.buf); in check_version_upgrade()
622 bch2_sb_upgrade(c, new_version); in check_version_upgrade()
631 int bch2_fs_recovery(struct bch_fs *c) in bch2_fs_recovery() argument
638 if (c->sb.clean) { in bch2_fs_recovery()
639 clean = bch2_read_superblock_clean(c); in bch2_fs_recovery()
644 bch_info(c, "recovering from clean shutdown, journal seq %llu", in bch2_fs_recovery()
647 bch_info(c, "recovering from unclean shutdown"); in bch2_fs_recovery()
650 if (!(c->sb.features & (1ULL << BCH_FEATURE_new_extent_overwrite))) { in bch2_fs_recovery()
651 bch_err(c, "feature new_extent_overwrite not set, filesystem no longer supported"); in bch2_fs_recovery()
656 if (!c->sb.clean && in bch2_fs_recovery()
657 !(c->sb.features & (1ULL << BCH_FEATURE_extents_above_btree_updates))) { in bch2_fs_recovery()
658 …bch_err(c, "filesystem needs recovery from older version; run fsck from older bcachefs-tools to fi… in bch2_fs_recovery()
663 if (c->opts.norecovery) in bch2_fs_recovery()
664 c->opts.recovery_pass_last = BCH_RECOVERY_PASS_journal_replay - 1; in bch2_fs_recovery()
666 mutex_lock(&c->sb_lock); in bch2_fs_recovery()
667 struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext); in bch2_fs_recovery()
670 if (BCH_SB_HAS_TOPOLOGY_ERRORS(c->disk_sb.sb)) { in bch2_fs_recovery()
681 bch_info(c, "%s", buf.buf); in bch2_fs_recovery()
685 if (bch2_check_version_downgrade(c)) { in bch2_fs_recovery()
691 bch2_sb_set_downgrade(c, in bch2_fs_recovery()
693 BCH_VERSION_MINOR(c->sb.version)); in bch2_fs_recovery()
701 bch_info(c, "%s", buf.buf); in bch2_fs_recovery()
706 if (check_version_upgrade(c)) in bch2_fs_recovery()
709c->opts.recovery_passes |= bch2_recovery_passes_from_stable(le64_to_cpu(ext->recovery_passes_requi… in bch2_fs_recovery()
712 bch2_write_super(c); in bch2_fs_recovery()
713 mutex_unlock(&c->sb_lock); in bch2_fs_recovery()
715 if (c->opts.fsck && IS_ENABLED(CONFIG_BCACHEFS_DEBUG)) in bch2_fs_recovery()
716 c->opts.recovery_passes |= BIT_ULL(BCH_RECOVERY_PASS_check_topology); in bch2_fs_recovery()
718 if (c->opts.fsck) in bch2_fs_recovery()
719 set_bit(BCH_FS_fsck_running, &c->flags); in bch2_fs_recovery()
720 if (c->sb.clean) in bch2_fs_recovery()
721 set_bit(BCH_FS_clean_recovery, &c->flags); in bch2_fs_recovery()
723 ret = bch2_blacklist_table_initialize(c); in bch2_fs_recovery()
725 bch_err(c, "error initializing blacklist table"); in bch2_fs_recovery()
729 bch2_journal_pos_from_member_info_resume(c); in bch2_fs_recovery()
731 if (!c->sb.clean || c->opts.retain_recovery_info) { in bch2_fs_recovery()
735 bch_verbose(c, "starting journal read"); in bch2_fs_recovery()
736 ret = bch2_journal_read(c, &last_seq, &blacklist_seq, &journal_seq); in bch2_fs_recovery()
744 if (c->opts.read_journal_only) in bch2_fs_recovery()
747 genradix_for_each_reverse(&c->journal_entries, iter, i) in bch2_fs_recovery()
753 if (mustfix_fsck_err_on(c->sb.clean && in bch2_fs_recovery()
755 !journal_entry_empty(last_journal_entry), c, in bch2_fs_recovery()
758 c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info); in bch2_fs_recovery()
759 SET_BCH_SB_CLEAN(c->disk_sb.sb, false); in bch2_fs_recovery()
760 c->sb.clean = false; in bch2_fs_recovery()
764 fsck_err_on(!c->sb.clean, c, in bch2_fs_recovery()
770 genradix_for_each_reverse(&c->journal_entries, iter, i) in bch2_fs_recovery()
786 ret = bch2_journal_keys_sort(c); in bch2_fs_recovery()
790 if (c->sb.clean && last_journal_entry) { in bch2_fs_recovery()
791 ret = bch2_verify_superblock_clean(c, &clean, in bch2_fs_recovery()
799 bch_err(c, "no superblock clean section found"); in bch2_fs_recovery()
807 c->journal_replay_seq_start = last_seq; in bch2_fs_recovery()
808 c->journal_replay_seq_end = blacklist_seq - 1; in bch2_fs_recovery()
810 if (c->opts.reconstruct_alloc) in bch2_fs_recovery()
811 bch2_reconstruct_alloc(c); in bch2_fs_recovery()
813 zero_out_btree_mem_ptr(&c->journal_keys); in bch2_fs_recovery()
815 ret = journal_replay_early(c, clean); in bch2_fs_recovery()
826 if (!c->sb.clean) in bch2_fs_recovery()
830 ret = bch2_journal_log_msg(c, "blacklisting entries %llu-%llu", in bch2_fs_recovery()
832 bch2_journal_seq_blacklist_add(c, in bch2_fs_recovery()
835 bch_err_msg(c, ret, "error creating new journal seq blacklist entry"); in bch2_fs_recovery()
840 ret = bch2_journal_log_msg(c, "starting journal at entry %llu, replaying %llu-%llu", in bch2_fs_recovery()
842 bch2_fs_journal_start(&c->journal, journal_seq); in bch2_fs_recovery()
850 if (c->sb.encryption_type && !c->sb.clean) in bch2_fs_recovery()
851 atomic64_add(1 << 16, &c->key_version); in bch2_fs_recovery()
853 ret = read_btree_roots(c); in bch2_fs_recovery()
857 set_bit(BCH_FS_btree_running, &c->flags); in bch2_fs_recovery()
859 ret = bch2_sb_set_upgrade_extra(c); in bch2_fs_recovery()
861 ret = bch2_run_recovery_passes(c); in bch2_fs_recovery()
871 set_bit(BCH_FS_may_go_rw, &c->flags); in bch2_fs_recovery()
872 clear_bit(BCH_FS_fsck_running, &c->flags); in bch2_fs_recovery()
875 set_bit(BCH_FS_accounting_replay_done, &c->flags); in bch2_fs_recovery()
878 if (test_bit(BCH_FS_errors_fixed, &c->flags) && in bch2_fs_recovery()
879 bch2_write_ref_tryget(c, BCH_WRITE_REF_fsync)) { in bch2_fs_recovery()
880 bch2_journal_flush_all_pins(&c->journal); in bch2_fs_recovery()
881 bch2_journal_meta(&c->journal); in bch2_fs_recovery()
882 bch2_write_ref_put(c, BCH_WRITE_REF_fsync); in bch2_fs_recovery()
887 test_bit(BCH_FS_errors_fixed, &c->flags) && in bch2_fs_recovery()
888 !test_bit(BCH_FS_errors_not_fixed, &c->flags) && in bch2_fs_recovery()
889 !test_bit(BCH_FS_error, &c->flags)) { in bch2_fs_recovery()
890 bch2_flush_fsck_errs(c); in bch2_fs_recovery()
892 bch_info(c, "Fixed errors, running fsck a second time to verify fs is clean"); in bch2_fs_recovery()
893 clear_bit(BCH_FS_errors_fixed, &c->flags); in bch2_fs_recovery()
895 c->curr_recovery_pass = BCH_RECOVERY_PASS_check_alloc_info; in bch2_fs_recovery()
897 ret = bch2_run_recovery_passes(c); in bch2_fs_recovery()
901 if (test_bit(BCH_FS_errors_fixed, &c->flags) || in bch2_fs_recovery()
902 test_bit(BCH_FS_errors_not_fixed, &c->flags)) { in bch2_fs_recovery()
903 bch_err(c, "Second fsck run was not clean"); in bch2_fs_recovery()
904 set_bit(BCH_FS_errors_not_fixed, &c->flags); in bch2_fs_recovery()
907 set_bit(BCH_FS_errors_fixed, &c->flags); in bch2_fs_recovery()
910 if (enabled_qtypes(c)) { in bch2_fs_recovery()
911 bch_verbose(c, "reading quotas"); in bch2_fs_recovery()
912 ret = bch2_fs_quota_read(c); in bch2_fs_recovery()
915 bch_verbose(c, "quotas done"); in bch2_fs_recovery()
918 mutex_lock(&c->sb_lock); in bch2_fs_recovery()
919 ext = bch2_sb_field_get(c->disk_sb.sb, ext); in bch2_fs_recovery()
922 if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) != le16_to_cpu(c->disk_sb.sb->version)) { in bch2_fs_recovery()
923 SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, le16_to_cpu(c->disk_sb.sb->version)); in bch2_fs_recovery()
927 if (!test_bit(BCH_FS_error, &c->flags) && in bch2_fs_recovery()
928 !(c->disk_sb.sb->compat[0] & cpu_to_le64(1ULL << BCH_COMPAT_alloc_info))) { in bch2_fs_recovery()
929 c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_alloc_info); in bch2_fs_recovery()
933 if (!test_bit(BCH_FS_error, &c->flags) && in bch2_fs_recovery()
939 if (c->opts.fsck && in bch2_fs_recovery()
940 !test_bit(BCH_FS_error, &c->flags) && in bch2_fs_recovery()
941 c->recovery_pass_done == BCH_RECOVERY_PASS_NR - 1 && in bch2_fs_recovery()
947 if (c->opts.fsck && in bch2_fs_recovery()
948 !test_bit(BCH_FS_error, &c->flags) && in bch2_fs_recovery()
949 !test_bit(BCH_FS_errors_not_fixed, &c->flags)) { in bch2_fs_recovery()
950 SET_BCH_SB_HAS_ERRORS(c->disk_sb.sb, 0); in bch2_fs_recovery()
951 SET_BCH_SB_HAS_TOPOLOGY_ERRORS(c->disk_sb.sb, 0); in bch2_fs_recovery()
955 if (bch2_blacklist_entries_gc(c)) in bch2_fs_recovery()
959 bch2_write_super(c); in bch2_fs_recovery()
960 mutex_unlock(&c->sb_lock); in bch2_fs_recovery()
962 if (!(c->sb.compat & (1ULL << BCH_COMPAT_extents_above_btree_updates_done)) || in bch2_fs_recovery()
963 c->sb.version_min < bcachefs_metadata_version_btree_ptr_sectors_written) { in bch2_fs_recovery()
969 bch2_version_to_text(&buf, c->sb.version_min); in bch2_fs_recovery()
970 bch_info(c, "scanning for old btree nodes: min_version %s", buf.buf); in bch2_fs_recovery()
973 ret = bch2_fs_read_write_early(c) ?: in bch2_fs_recovery()
974 bch2_scan_old_btree_nodes(c, &stats); in bch2_fs_recovery()
977 bch_info(c, "scanning for old btree nodes done"); in bch2_fs_recovery()
982 bch2_flush_fsck_errs(c); in bch2_fs_recovery()
984 if (!c->opts.retain_recovery_info) { in bch2_fs_recovery()
985 bch2_journal_keys_put_initial(c); in bch2_fs_recovery()
986 bch2_find_btree_nodes_exit(&c->found_btree_nodes); in bch2_fs_recovery()
992 test_bit(BCH_FS_need_delete_dead_snapshots, &c->flags) && in bch2_fs_recovery()
993 !c->opts.nochanges) { in bch2_fs_recovery()
994 bch2_fs_read_write_early(c); in bch2_fs_recovery()
995 bch2_delete_dead_snapshots_async(c); in bch2_fs_recovery()
998 bch_err_fn(c, ret); in bch2_fs_recovery()
1002 bch2_fs_emergency_read_only(c); in bch2_fs_recovery()
1006 int bch2_fs_initialize(struct bch_fs *c) in bch2_fs_initialize() argument
1014 bch_notice(c, "initializing new filesystem"); in bch2_fs_initialize()
1015 set_bit(BCH_FS_new_fs, &c->flags); in bch2_fs_initialize()
1017 mutex_lock(&c->sb_lock); in bch2_fs_initialize()
1018 c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_extents_above_btree_updates_done); in bch2_fs_initialize()
1019 c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_bformat_overflow_done); in bch2_fs_initialize()
1021 bch2_check_version_downgrade(c); in bch2_fs_initialize()
1023 if (c->opts.version_upgrade != BCH_VERSION_UPGRADE_none) { in bch2_fs_initialize()
1024 bch2_sb_upgrade(c, bcachefs_metadata_version_current); in bch2_fs_initialize()
1025 SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, bcachefs_metadata_version_current); in bch2_fs_initialize()
1026 bch2_write_super(c); in bch2_fs_initialize()
1029 for_each_member_device(c, ca) { in bch2_fs_initialize()
1030 m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); in bch2_fs_initialize()
1035 bch2_write_super(c); in bch2_fs_initialize()
1036 mutex_unlock(&c->sb_lock); in bch2_fs_initialize()
1038 c->curr_recovery_pass = BCH_RECOVERY_PASS_NR; in bch2_fs_initialize()
1039 set_bit(BCH_FS_btree_running, &c->flags); in bch2_fs_initialize()
1040 set_bit(BCH_FS_may_go_rw, &c->flags); in bch2_fs_initialize()
1043 bch2_btree_root_alloc_fake(c, i, 0); in bch2_fs_initialize()
1045 ret = bch2_fs_journal_alloc(c); in bch2_fs_initialize()
1053 bch2_fs_journal_start(&c->journal, 1); in bch2_fs_initialize()
1054 set_bit(BCH_FS_accounting_replay_done, &c->flags); in bch2_fs_initialize()
1055 bch2_journal_set_replay_done(&c->journal); in bch2_fs_initialize()
1057 ret = bch2_fs_read_write_early(c); in bch2_fs_initialize()
1061 for_each_member_device(c, ca) { in bch2_fs_initialize()
1073 bch_verbose(c, "marking superblocks"); in bch2_fs_initialize()
1074 ret = bch2_trans_mark_dev_sbs(c); in bch2_fs_initialize()
1075 bch_err_msg(c, ret, "marking superblocks"); in bch2_fs_initialize()
1079 for_each_online_member(c, ca) in bch2_fs_initialize()
1082 ret = bch2_fs_freespace_init(c); in bch2_fs_initialize()
1086 ret = bch2_initialize_subvolumes(c); in bch2_fs_initialize()
1090 bch_verbose(c, "reading snapshots table"); in bch2_fs_initialize()
1091 ret = bch2_snapshots_read(c); in bch2_fs_initialize()
1094 bch_verbose(c, "reading snapshots done"); in bch2_fs_initialize()
1096 bch2_inode_init(c, &root_inode, 0, 0, S_IFDIR|0755, 0, NULL); in bch2_fs_initialize()
1102 ret = bch2_btree_insert(c, BTREE_ID_inodes, &packed_inode.inode.k_i, NULL, 0, 0); in bch2_fs_initialize()
1103 bch_err_msg(c, ret, "creating root directory"); in bch2_fs_initialize()
1107 bch2_inode_init_early(c, &lostfound_inode); in bch2_fs_initialize()
1109 ret = bch2_trans_commit_do(c, NULL, NULL, 0, in bch2_fs_initialize()
1116 bch_err_msg(c, ret, "creating lost+found"); in bch2_fs_initialize()
1120 c->recovery_pass_done = BCH_RECOVERY_PASS_NR - 1; in bch2_fs_initialize()
1122 if (enabled_qtypes(c)) { in bch2_fs_initialize()
1123 ret = bch2_fs_quota_read(c); in bch2_fs_initialize()
1128 ret = bch2_journal_flush(&c->journal); in bch2_fs_initialize()
1129 bch_err_msg(c, ret, "writing first journal entry"); in bch2_fs_initialize()
1133 mutex_lock(&c->sb_lock); in bch2_fs_initialize()
1134 SET_BCH_SB_INITIALIZED(c->disk_sb.sb, true); in bch2_fs_initialize()
1135 SET_BCH_SB_CLEAN(c->disk_sb.sb, false); in bch2_fs_initialize()
1137 bch2_write_super(c); in bch2_fs_initialize()
1138 mutex_unlock(&c->sb_lock); in bch2_fs_initialize()
1142 bch_err_fn(c, ret); in bch2_fs_initialize()