static int after_copied_inodes(void *p)
{
- struct task_ctx *priv = p;
-
printf("\n");
- task_period_stop(priv->info);
+ fflush(stdout);
return 0;
}
}
static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes,
- u64 hint_byte, struct btrfs_key *ins)
+ u64 hint_byte, struct btrfs_key *ins,
+ int metadata)
{
u64 start;
u64 end;
continue;
}
+ if (metadata) {
+ BUG_ON(num_bytes != root->nodesize);
+ if (check_crossing_stripes(start, num_bytes)) {
+ last = round_down(start + num_bytes,
+ BTRFS_STRIPE_LEN);
+ continue;
+ }
+ }
clear_extent_dirty(&root->fs_info->free_space_cache,
start, start + num_bytes - 1, 0);
struct ext2_inode *src, u32 blocksize)
{
btrfs_set_stack_inode_generation(dst, 1);
+ btrfs_set_stack_inode_sequence(dst, 0);
+ btrfs_set_stack_inode_transid(dst, 1);
btrfs_set_stack_inode_size(dst, src->i_size);
btrfs_set_stack_inode_nbytes(dst, 0);
btrfs_set_stack_inode_block_group(dst, 0);
new_decode_dev(src->i_block[1]));
}
}
+ memset(&dst->reserved, 0, sizeof(dst->reserved));
+
return 0;
}
}
ret = btrfs_commit_transaction(trans, root);
BUG_ON(ret);
+ ext2fs_close_inode_scan(ext2_scan);
return ret;
}
* special, we can't rely on relocate_extents_range to relocate it.
*/
for (last_byte = 0; last_byte < first_free; last_byte += sectorsize) {
- ret = custom_alloc_extent(root, sectorsize, 0, &key);
+ ret = custom_alloc_extent(root, sectorsize, 0, &key, 0);
if (ret)
goto fail;
ret = copy_disk_extent(root, key.objectid, last_byte,
ret = get_state_private(reloc_tree, bytenr, &new_pos);
BUG_ON(ret);
} else {
- ret = custom_alloc_extent(root, sectorsize, 0, &key);
+ ret = custom_alloc_extent(root, sectorsize, 0, &key, 0);
if (ret)
goto fail;
new_pos = key.objectid;
struct btrfs_root *image_root;
struct task_ctx ctx;
char features_buf[64];
+ struct btrfs_mkfs_config mkfs_cfg;
ret = open_ext2fs(devname, &ext2_fs);
if (ret) {
fprintf(stderr, "filetype feature is missing\n");
goto fail;
}
- if (btrfs_check_nodesize(nodesize, blocksize))
+ if (btrfs_check_nodesize(nodesize, blocksize, features))
goto fail;
blocks_per_node = nodesize / blocksize;
ret = -blocks_per_node;
printf("\tblocksize: %u\n", blocksize);
printf("\tnodesize: %u\n", nodesize);
printf("\tfeatures: %s\n", features_buf);
- ret = make_btrfs(fd, devname, ext2_fs->super->s_volume_name,
- NULL, blocks, total_bytes, nodesize,
- blocksize, blocksize, features);
+
+ mkfs_cfg.label = ext2_fs->super->s_volume_name;
+ mkfs_cfg.fs_uuid = NULL;
+ memcpy(mkfs_cfg.blocks, blocks, sizeof(blocks));
+ mkfs_cfg.num_bytes = total_bytes;
+ mkfs_cfg.nodesize = nodesize;
+ mkfs_cfg.sectorsize = blocksize;
+ mkfs_cfg.stripesize = blocksize;
+ mkfs_cfg.features = features;
+
+ ret = make_btrfs(fd, &mkfs_cfg);
if (ret) {
fprintf(stderr, "unable to create initial ctree: %s\n",
strerror(-ret));
fprintf(stderr, "copy label '%s'\n",
root->fs_info->super_copy->label);
} else if (copylabel == -1) {
- strncpy(root->fs_info->super_copy->label, fslabel, BTRFS_LABEL_SIZE);
+ strcpy(root->fs_info->super_copy->label, fslabel);
fprintf(stderr, "set label to '%s'\n", fslabel);
}
int usage_error = 0;
int progress = 1;
char *file;
- char *fslabel = NULL;
+ char fslabel[BTRFS_LABEL_SIZE];
u64 features = BTRFS_MKFS_DEFAULT_FEATURES;
while(1) {
break;
case 'l':
copylabel = -1;
- fslabel = strdup(optarg);
- if (strlen(fslabel) > BTRFS_LABEL_SIZE) {
+ if (strlen(optarg) >= BTRFS_LABEL_SIZE) {
fprintf(stderr,
- "warning: label too long, trimmed to %d bytes\n",
- BTRFS_LABEL_SIZE);
- fslabel[BTRFS_LABEL_SIZE] = 0;
+ "WARNING: label too long, trimmed to %d bytes\n",
+ BTRFS_LABEL_SIZE - 1);
}
+ strncpy(fslabel, optarg, BTRFS_LABEL_SIZE - 1);
+ fslabel[BTRFS_LABEL_SIZE - 1] = 0;
break;
case 'L':
copylabel = 1;