struct btrfs_device, dev_list);
if (device->fd != -1) {
if (fsync(device->fd) == -1) {
- warning("fsync on device %llu failed: %s",
- device->devid, strerror(errno));
+ warning("fsync on device %llu failed: %m",
+ device->devid);
ret = -errno;
}
if (posix_fadvise(device->fd, 0, 0, POSIX_FADV_DONTNEED))
fd = open(device->name, flags);
if (fd < 0) {
ret = -errno;
- error("cannot open device '%s': %s", device->name,
- strerror(errno));
+ error("cannot open device '%s': %m", device->name);
goto fail;
}
static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
struct btrfs_device *device,
- u64 chunk_tree, u64 chunk_objectid,
- u64 chunk_offset,
- u64 num_bytes, u64 *start, int convert)
+ u64 chunk_offset, u64 num_bytes, u64 *start,
+ int convert)
{
int ret;
struct btrfs_path *path;
leaf = path->nodes[0];
extent = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_dev_extent);
- btrfs_set_dev_extent_chunk_tree(leaf, extent, chunk_tree);
- btrfs_set_dev_extent_chunk_objectid(leaf, extent, chunk_objectid);
+ btrfs_set_dev_extent_chunk_tree(leaf, extent, BTRFS_CHUNK_TREE_OBJECTID);
+ btrfs_set_dev_extent_chunk_objectid(leaf, extent,
+ BTRFS_FIRST_CHUNK_TREE_OBJECTID);
btrfs_set_dev_extent_chunk_offset(leaf, extent, chunk_offset);
write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid,
return ret;
}
-#define BTRFS_MAX_DEVS(r) ((BTRFS_LEAF_DATA_SIZE(r) \
+#define BTRFS_MAX_DEVS(r) ((BTRFS_LEAF_DATA_SIZE(r->fs_info) \
- sizeof(struct btrfs_item) \
- sizeof(struct btrfs_chunk)) \
/ sizeof(struct btrfs_stripe) + 1)
(index == num_stripes - 1))
list_move_tail(&device->dev_list, dev_list);
- ret = btrfs_alloc_dev_extent(trans, device,
- info->chunk_root->root_key.objectid,
- BTRFS_FIRST_CHUNK_TREE_OBJECTID, key.offset,
+ ret = btrfs_alloc_dev_extent(trans, device, key.offset,
calc_size, &dev_offset, 0);
if (ret < 0)
goto out_chunk_map;
while (index < num_stripes) {
struct btrfs_stripe *stripe;
- ret = btrfs_alloc_dev_extent(trans, device,
- info->chunk_root->root_key.objectid,
- BTRFS_FIRST_CHUNK_TREE_OBJECTID, key.offset,
+ ret = btrfs_alloc_dev_extent(trans, device, key.offset,
calc_size, &dev_offset, convert);
BUG_ON(ret);