diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2018-12-11 10:30:30 +1100 |
---|---|---|
committer | Dimitri John Ledkov <xnox@ubuntu.com> | 2018-12-11 10:30:30 +1100 |
commit | 59d2f4ec0b9dff7b56da34541dffd3e676adf584 (patch) | |
tree | 0f982d10b206f248f13de6ba48617e9bdae5e5f5 /convert | |
parent | 3b9cf4c8cda0818e4d3f9892ece9f7d99de13b03 (diff) | |
parent | 5b162a39be9dec46a22c815f43fc337b920b4252 (diff) |
Update upstream source from tag 'upstream/4.19.1'
Update to upstream version '4.19.1'
with Debian dir 171bf4d92c150acf94e8e0a7633c4349c4e39ad6
Diffstat (limited to 'convert')
-rw-r--r-- | convert/common.c | 4 | ||||
-rw-r--r-- | convert/main.c | 87 | ||||
-rw-r--r-- | convert/source-ext2.c | 4 | ||||
-rw-r--r-- | convert/source-fs.c | 2 | ||||
-rw-r--r-- | convert/source-fs.h | 2 | ||||
-rw-r--r-- | convert/source-reiserfs.c | 10 |
6 files changed, 71 insertions, 38 deletions
diff --git a/convert/common.c b/convert/common.c index 6ddf4a46..a9b24043 100644 --- a/convert/common.c +++ b/convert/common.c @@ -76,7 +76,7 @@ static inline int write_temp_super(int fd, struct btrfs_super_block *sb, } /* - * Setup temporary superblock at cfg->super_bynter + * Setup temporary superblock at cfg->super_bytenr * Needed info are extracted from cfg, and root_bytenr, chunk_bytenr * * For now sys chunk array will be empty and dev_item is empty too. @@ -98,7 +98,7 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg, if (*cfg->fs_uuid) { if (uuid_parse(cfg->fs_uuid, super->fsid) != 0) { - error("cound not parse UUID: %s", cfg->fs_uuid); + error("could not parse UUID: %s", cfg->fs_uuid); ret = -EINVAL; goto out; } diff --git a/convert/main.c b/convert/main.c index 7077fcba..68f76f71 100644 --- a/convert/main.c +++ b/convert/main.c @@ -66,7 +66,7 @@ * c. Doesn't cover any data chunks in 1.1 * * 2) Create basic btrfs filesystem structure - * Initial metadata and sys chunks are inserted in the first availabe + * Initial metadata and sys chunks are inserted in the first available * space found in step 1.3 * Then insert all data chunks into the basic btrfs * @@ -290,10 +290,16 @@ static int create_image_file_range(struct btrfs_trans_handle *trans, if (disk_bytenr) { /* Check if the range is in a data block group */ bg_cache = btrfs_lookup_block_group(root->fs_info, bytenr); - if (!bg_cache) + if (!bg_cache) { + error("missing data block for bytenr %llu", bytenr); return -ENOENT; - if (!(bg_cache->flags & BTRFS_BLOCK_GROUP_DATA)) + } + if (!(bg_cache->flags & BTRFS_BLOCK_GROUP_DATA)) { + error( + "data bytenr %llu is covered by non-data block group %llu flags 0x%llu", + bytenr, bg_cache->key.objectid, bg_cache->flags); return -EINVAL; + } /* The extent should never cross block group boundary */ len = min_t(u64, len, bg_cache->key.objectid + @@ -310,8 +316,15 @@ static int create_image_file_range(struct btrfs_trans_handle *trans, if (ret < 0) return ret; - if (datacsum) + if (datacsum) { ret = csum_disk_extent(trans, root, bytenr, len); + if (ret < 0) { + errno = -ret; + error( + "failed to calculate csum for bytenr %llu len %llu: %m", + bytenr, len); + } + } *ret_len = len; return ret; } @@ -669,7 +682,7 @@ static int calculate_available_space(struct btrfs_convert_context *cctx) cur_off = 0; /* * Calculate free space - * Always round up the start bytenr, to avoid metadata extent corss + * Always round up the start bytenr, to avoid metadata extent cross * stripe boundary, as later mkfs_convert() won't have all the extent * allocation check */ @@ -711,7 +724,7 @@ out: /* * Read used space, and since we have the used space, - * calcuate data_chunks and free for later mkfs + * calculate data_chunks and free for later mkfs */ static int convert_read_used_space(struct btrfs_convert_context *cctx) { @@ -759,18 +772,34 @@ static int create_image(struct btrfs_root *root, ret = btrfs_find_free_objectid(trans, root, BTRFS_FIRST_FREE_OBJECTID, &ino); - if (ret < 0) + if (ret < 0) { + errno = -ret; + error("failed to find free objectid for root %llu: %m", + root->root_key.objectid); goto out; + } ret = btrfs_new_inode(trans, root, ino, 0400 | S_IFREG); - if (ret < 0) + if (ret < 0) { + errno = -ret; + error("failed to create new inode for root %llu: %m", + root->root_key.objectid); goto out; + } ret = btrfs_change_inode_flags(trans, root, ino, flags); - if (ret < 0) + if (ret < 0) { + errno = -ret; + error("failed to change inode flag for ino %llu root %llu: %m", + ino, root->root_key.objectid); goto out; + } ret = btrfs_add_link(trans, root, ino, BTRFS_FIRST_FREE_OBJECTID, name, strlen(name), BTRFS_FT_REG_FILE, NULL, 1, 0); - if (ret < 0) + if (ret < 0) { + errno = -ret; + error("failed to link ino %llu to '/%s' in root %llu: %m", + ino, name, root->root_key.objectid); goto out; + } key.objectid = ino; key.type = BTRFS_INODE_ITEM_KEY; @@ -946,7 +975,7 @@ static int init_btrfs(struct btrfs_mkfs_config *cfg, struct btrfs_root *root, /* * Don't alloc any metadata/system chunk, as we don't want - * any meta/sys chunk allcated before all data chunks are inserted. + * any meta/sys chunk allocated before all data chunks are inserted. * Or we screw up the chunk layout just like the old implement. */ fs_info->avoid_sys_chunk_alloc = 1; @@ -1135,7 +1164,8 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, ret = make_convert_btrfs(fd, &mkfs_cfg, &cctx); if (ret) { - error("unable to create initial ctree: %s", strerror(-ret)); + errno = -ret; + error("unable to create initial ctree: %m"); goto fail; } @@ -1182,7 +1212,7 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, if (progress) { ctx.info = task_init(print_copied_inodes, after_copied_inodes, &ctx); - task_start(ctx.info); + task_start(ctx.info, NULL, NULL); } ret = copy_inodes(&cctx, root, convert_flags, &ctx); if (ret) { @@ -1314,7 +1344,7 @@ static bool is_chunk_direct_mapped(struct btrfs_fs_info *fs_info, u64 start) if (map->num_stripes != 1) goto out; - /* Chunk's logical doesn't match with phisical, not 1:1 mapped */ + /* Chunk's logical doesn't match with physical, not 1:1 mapped */ if (map->ce.start != map->stripes[0].physical) goto out; ret = true; @@ -1326,7 +1356,7 @@ out: * Iterate all file extents of the convert image. * * All file extents except ones in btrfs_reserved_ranges must be mapped 1:1 - * on disk. (Means thier file_offset must match their on disk bytenr) + * on disk. (Means their file_offset must match their on disk bytenr) * * File extents in reserved ranges can be relocated to other place, and in * that case we will read them out for later use. @@ -1353,8 +1383,8 @@ static int check_convert_image(struct btrfs_root *image_root, u64 ino, * So we only need to check if ret < 0 */ if (ret < 0) { - error("failed to iterate file extents at offset 0: %s", - strerror(-ret)); + errno = -ret; + error("failed to iterate file extents at offset 0: %m"); btrfs_release_path(&path); return ret; } @@ -1558,8 +1588,8 @@ static int do_rollback(const char *devname) ret = -ENOENT; goto close_fs; } else if (ret < 0) { - error("failed to find source fs image subvolume: %s", - strerror(-ret)); + errno = -ret; + error("failed to find source fs image subvolume: %m"); goto close_fs; } @@ -1570,8 +1600,8 @@ static int do_rollback(const char *devname) image_root = btrfs_read_fs_root(fs_info, &key); if (IS_ERR(image_root)) { ret = PTR_ERR(image_root); - error("failed to open convert image subvolume: %s", - strerror(-ret)); + errno = -ret; + error("failed to open convert image subvolume: %m"); goto close_fs; } @@ -1586,8 +1616,8 @@ static int do_rollback(const char *devname) ret = PTR_ERR(dir); else ret = -ENOENT; - error("failed to locate file %s: %s", image_name, - strerror(-ret)); + errno = -ret; + error("failed to locate file %s: %m", image_name); goto close_fs; } btrfs_dir_item_key_to_cpu(path.nodes[0], dir, &key); @@ -1600,7 +1630,8 @@ static int do_rollback(const char *devname) if (ret < 0) { btrfs_release_path(&path); - error("unable to find inode %llu: %s", ino, strerror(-ret)); + errno = -ret; + error("unable to find inode %llu: %m", ino); goto close_fs; } inode_item = btrfs_item_ptr(path.nodes[0], path.slots[0], @@ -1642,8 +1673,9 @@ close_fs: ret = -errno; else ret = -EIO; - error("failed to recover range [%llu, %llu): %s", - range->start, real_size, strerror(-ret)); + errno = -ret; + error("failed to recover range [%llu, %llu): %m", + range->start, real_size); goto free_mem; } ret = 0; @@ -1805,7 +1837,8 @@ int main(int argc, char *argv[]) file = argv[optind]; ret = check_mounted(file); if (ret < 0) { - error("could not check mount status: %s", strerror(-ret)); + errno = -ret; + error("could not check mount status: %m"); return 1; } else if (ret) { error("%s is mounted", file); diff --git a/convert/source-ext2.c b/convert/source-ext2.c index a2af1212..a136e565 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -162,8 +162,8 @@ static int ext2_read_used_space(struct btrfs_convert_context *cctx) } ret = __ext2_add_one_block(fs, block_bitmap, i, used_tree); if (ret < 0) { - error("fail to build used space tree, %s", - strerror(-ret)); + errno = -ret; + error("fail to build used space tree, %m"); break; } blk_itr += EXT2_CLUSTERS_PER_GROUP(fs->super); diff --git a/convert/source-fs.c b/convert/source-fs.c index b6d08370..5660a22c 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -201,7 +201,7 @@ int read_disk_extent(struct btrfs_root *root, u64 bytenr, ret = 0; fail: if (ret > 0) - ret = -1; + ret = -EIO; return ret; } diff --git a/convert/source-fs.h b/convert/source-fs.h index f5314aff..7cf587d9 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -26,7 +26,7 @@ #define CONV_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID /* - * Reresents a simple contiguous range. + * Represents a simple contiguous range. * * For multiple or non-contiguous ranges, use extent_cache_tree from * extent-cache.c diff --git a/convert/source-reiserfs.c b/convert/source-reiserfs.c index e0b3b685..cc592f19 100644 --- a/convert/source-reiserfs.c +++ b/convert/source-reiserfs.c @@ -301,7 +301,7 @@ static int reiserfs_record_indirect_extent(reiserfs_filsys_t fs, u64 position, /* * Unlike btrfs inline extents, reiserfs can have multiple inline extents. - * This handles concatanating multiple tails into one inline extent + * This handles concatenating multiple tails into one inline extent * for insertion. */ static int reiserfs_record_direct_extent(reiserfs_filsys_t fs, __u64 position, @@ -493,10 +493,10 @@ static int reiserfs_copy_dirent(reiserfs_filsys_t fs, ret = reiserfs_copy_meta(fs, root, dirent_data->convert_flags, deh_dirid, deh_objectid, &type); if (ret) { + errno = -ret; error( - "an error occured while converting \"%.*s\", reiserfs key [%u %u]: %s", - (int)len, name, deh_dirid, deh_objectid, - strerror(-ret)); + "an error occured while converting \"%.*s\", reiserfs key [%u %u]: %m", + (int)len, name, deh_dirid, deh_objectid); return ret; } trans = btrfs_start_transaction(root, 1); @@ -564,7 +564,7 @@ static int reiserfs_copy_meta(reiserfs_filsys_t fs, struct btrfs_root *root, }; /* The root directory's dirid in reiserfs points to an object - * that does't exist. In btrfs it's self-referential. + * that doens't exist. In btrfs it's self-referential. */ if (deh_dirid == REISERFS_ROOT_PARENT_OBJECTID) parent = objectid; |