]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - cmd_migrate.c
Update bcachefs sources to 7958ebe324 bcachefs: Fix alloc_v4_backpointers()
[bcachefs-tools-debian] / cmd_migrate.c
index 4772b3bdb624a159befa8ac59e2741b9025b733b..707f13e1ca1248d59b32c15cfda06a86cc155847 100644 (file)
@@ -122,7 +122,7 @@ static void update_inode(struct bch_fs *c,
        struct bkey_inode_buf packed;
        int ret;
 
-       bch2_inode_pack(c, &packed, inode);
+       bch2_inode_pack(&packed, inode);
        packed.inode.k.p.snapshot = U32_MAX;
        ret = bch2_btree_insert(c, BTREE_ID_inodes, &packed.inode.k_i,
                                NULL, NULL, 0);
@@ -257,7 +257,7 @@ static void write_data(struct bch_fs *c,
 
        closure_init_stack(&cl);
 
-       bio_init(&op.wbio.bio, bv, ARRAY_SIZE(bv));
+       bio_init(&op.wbio.bio, NULL, bv, ARRAY_SIZE(bv), 0);
        bch2_bio_map(&op.wbio.bio, buf, len);
 
        bch2_write_op_init(&op, c, bch2_opts_to_inode_opts(c->opts));
@@ -265,6 +265,7 @@ static void write_data(struct bch_fs *c,
        op.nr_replicas  = 1;
        op.subvol       = 1;
        op.pos          = SPOS(dst_inode->bi_inum, dst_offset >> 9, U32_MAX);
+       op.flags |= BCH_WRITE_SYNC;
 
        int ret = bch2_disk_reservation_get(c, &op.res, len >> 9,
                                            c->opts.data_replicas, 0);
@@ -272,7 +273,6 @@ static void write_data(struct bch_fs *c,
                die("error reserving space in new filesystem: %s", strerror(-ret));
 
        closure_call(&op.cl, bch2_write, NULL, &cl);
-       closure_sync(&cl);
 
        dst_inode->bi_sectors += len >> 9;
 }
@@ -530,7 +530,7 @@ static ranges reserve_new_fs_space(const char *file_path, unsigned block_size,
 
        struct fiemap_iter iter;
        struct fiemap_extent e;
-       ranges extents = { NULL };
+       ranges extents = { 0 };
 
        fiemap_for_each(fd, iter, e) {
                if (e.fe_flags & (FIEMAP_EXTENT_UNKNOWN|
@@ -603,7 +603,7 @@ static void copy_fs(struct bch_fs *c, int src_fd, const char *src_path,
 
        update_inode(c, &root_inode);
 
-       darray_free(s.extents);
+       darray_exit(&s.extents);
        genradix_free(&s.hardlinks);
 }
 
@@ -613,7 +613,7 @@ static void find_superblock_space(ranges extents,
 {
        struct range *i;
 
-       darray_foreach(i, extents) {
+       darray_for_each(extents, i) {
                u64 start = round_up(max(256ULL << 10, i->start),
                                     dev->bucket_size << 9);
                u64 end = round_down(i->end,
@@ -641,7 +641,7 @@ static void migrate_usage(void)
             "      --no_passphrase    Don't encrypt master encryption key\n"
             "  -F                     Force, even if metadata file already exists\n"
             "  -h                     Display this help and exit\n"
-            "Report bugs to <linux-bcache@vger.kernel.org>");
+            "Report bugs to <linux-bcachefs@vger.kernel.org>");
 }
 
 static const struct option migrate_opts[] = {
@@ -691,7 +691,7 @@ static int migrate_fs(const char            *fs_path,
        u64 sb_offset = le64_to_cpu(sb->layout.sb_offset[0]);
 
        if (format_opts.passphrase)
-               bch2_add_key(sb, format_opts.passphrase);
+               bch2_add_key(sb, "user", "user", format_opts.passphrase);
 
        free(sb);
 
@@ -702,6 +702,7 @@ static int migrate_fs(const char            *fs_path,
        opt_set(opts, sb,       sb_offset);
        opt_set(opts, nostart,  true);
        opt_set(opts, noexcl,   true);
+       opt_set(opts, buckets_nouse, true);
 
        c = bch2_fs_open(path, 1, opts);
        if (IS_ERR(c))
@@ -798,7 +799,7 @@ static void migrate_superblock_usage(void)
             "  -d device     Device to create superblock for\n"
             "  -o offset     Offset of existing superblock\n"
             "  -h            Display this help and exit\n"
-            "Report bugs to <linux-bcache@vger.kernel.org>");
+            "Report bugs to <linux-bcachefs@vger.kernel.org>");
 }
 
 int cmd_migrate_superblock(int argc, char *argv[])