]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/super.c
Update bcachefs sources to fd381c355c bcachefs: Fix a null ptr deref in fsck check_ex...
[bcachefs-tools-debian] / libbcachefs / super.c
index 3a7f4e295cbd2840ca27fddcf9f8ccb983f15778..613d09f5b8e6c90774ce95db6aa02442f6cfb42c 100644 (file)
@@ -494,6 +494,8 @@ static void __bch2_fs_free(struct bch_fs *c)
        kfree(c->journal_seq_blacklist_table);
        kfree(c->unused_inode_hints);
 
+       if (c->write_ref_wq)
+               destroy_workqueue(c->write_ref_wq);
        if (c->io_complete_wq)
                destroy_workqueue(c->io_complete_wq);
        if (c->copygc_wq)
@@ -647,7 +649,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
 
        c = kvpmalloc(sizeof(struct bch_fs), GFP_KERNEL|__GFP_ZERO);
        if (!c) {
-               c = ERR_PTR(-ENOMEM);
+               c = ERR_PTR(-BCH_ERR_ENOMEM_fs_alloc);
                goto out;
        }
 
@@ -709,6 +711,9 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
 
        sema_init(&c->io_in_flight, 128);
 
+       INIT_LIST_HEAD(&c->vfs_inodes_list);
+       mutex_init(&c->vfs_inodes_lock);
+
        c->copy_gc_enabled              = 1;
        c->rebalance.enabled            = 1;
        c->promote_whole_extents        = true;
@@ -737,7 +742,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
        strscpy(c->name, name.buf, sizeof(c->name));
        printbuf_exit(&name);
 
-       ret = name.allocation_failure ? -ENOMEM : 0;
+       ret = name.allocation_failure ? -BCH_ERR_ENOMEM_fs_name_alloc : 0;
        if (ret)
                goto err;
 
@@ -784,6 +789,8 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
                                WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE, 1)) ||
            !(c->io_complete_wq = alloc_workqueue("bcachefs_io",
                                WQ_FREEZABLE|WQ_HIGHPRI|WQ_MEM_RECLAIM, 1)) ||
+           !(c->write_ref_wq = alloc_workqueue("bcachefs_write_ref",
+                               WQ_FREEZABLE, 0)) ||
 #ifndef BCH_WRITE_REF_DEBUG
            percpu_ref_init(&c->writes, bch2_writes_disabled,
                            PERCPU_REF_INIT_DEAD, GFP_KERNEL) ||
@@ -801,7 +808,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
            mempool_init_kmalloc_pool(&c->large_bkey_pool, 1, 2048) ||
            !(c->unused_inode_hints = kcalloc(1U << c->inode_shard_bits,
                                              sizeof(u64), GFP_KERNEL))) {
-               ret = -ENOMEM;
+               ret = -BCH_ERR_ENOMEM_fs_other_alloc;
                goto err;
        }
 
@@ -1182,7 +1189,7 @@ out:
 err:
        if (ca)
                bch2_dev_free(ca);
-       ret = -ENOMEM;
+       ret = -BCH_ERR_ENOMEM_dev_alloc;
        goto out;
 }
 
@@ -1738,6 +1745,10 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
        bch2_write_super(c);
        mutex_unlock(&c->sb_lock);
 
+       ret = bch2_fs_freespace_init(c);
+       if (ret)
+               bch_err(c, "device add error: error initializing free space: %s", bch2_err_str(ret));
+
        up_write(&c->state_lock);
        return 0;
 err: