]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/super-io.c
Update bcachefs sources to 1ff261b014 bcachefs: Fix CPU usage in journal read path
[bcachefs-tools-debian] / libbcachefs / super-io.c
index 71abf87114dfc41a20fb408a049ce27bd77fdfe4..1aaae1400633a73db6bd044c34c96816c92f35c4 100644 (file)
@@ -21,6 +21,8 @@
 #include <linux/backing-dev.h>
 #include <linux/sort.h>
 
+#include <trace/events/bcachefs.h>
+
 const char * const bch2_sb_fields[] = {
 #define x(name, nr)    #name,
        BCH_SB_FIELDS()
@@ -797,6 +799,8 @@ int bch2_write_super(struct bch_fs *c)
        unsigned degraded_flags = BCH_FORCE_IF_DEGRADED;
        int ret = 0;
 
+       trace_write_super(c, _RET_IP_);
+
        if (c->opts.very_degraded)
                degraded_flags |= BCH_FORCE_IF_LOST;
 
@@ -831,6 +835,13 @@ int bch2_write_super(struct bch_fs *c)
        if (c->opts.nochanges)
                goto out;
 
+       /*
+        * Defer writing the superblock until filesystem initialization is
+        * complete - don't write out a partly initialized superblock:
+        */
+       if (!BCH_SB_INITIALIZED(c->disk_sb.sb))
+               goto out;
+
        for_each_online_member(ca, c, i) {
                __set_bit(ca->dev_idx, sb_written.d);
                ca->sb_write_error = 0;
@@ -1262,7 +1273,6 @@ void bch2_journal_super_entries_add_common(struct bch_fs *c,
                u->entry.type = BCH_JSET_ENTRY_dev_usage;
                u->dev = cpu_to_le32(dev);
                u->buckets_ec           = cpu_to_le64(ca->usage_base->buckets_ec);
-               u->buckets_unavailable  = cpu_to_le64(ca->usage_base->buckets_unavailable);
 
                for (i = 0; i < BCH_DATA_NR; i++) {
                        u->d[i].buckets = cpu_to_le64(ca->usage_base->d[i].buckets);