btrfs-progs: don't clobber errno in close_file_or_dir
[platform/upstream/btrfs-progs.git] / volumes.c
index 1fda594..fea60b2 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -309,9 +309,9 @@ int btrfs_scan_one_device(int fd, const char *path,
  * But if we don't find suitable free space, it is used to store the size of
  * the max free space.
  */
-static int find_free_dev_extent_start(struct btrfs_trans_handle *trans,
-                              struct btrfs_device *device, u64 num_bytes,
-                              u64 search_start, u64 *start, u64 *len)
+static int find_free_dev_extent_start(struct btrfs_device *device,
+                                     u64 num_bytes, u64 search_start,
+                                     u64 *start, u64 *len)
 {
        struct btrfs_key key;
        struct btrfs_root *root = device->dev_root;
@@ -450,20 +450,17 @@ out:
        return ret;
 }
 
-static int find_free_dev_extent(struct btrfs_trans_handle *trans,
-                        struct btrfs_device *device, u64 num_bytes,
-                        u64 *start)
+static int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,
+                               u64 *start)
 {
        /* FIXME use last free of some kind */
-       return find_free_dev_extent_start(trans, device,
-                                         num_bytes, 0, start, NULL);
+       return find_free_dev_extent_start(device, num_bytes, 0, start, NULL);
 }
 
 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;
@@ -481,8 +478,7 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
         * is responsible to make sure it's free.
         */
        if (!convert) {
-               ret = find_free_dev_extent(trans, device, num_bytes,
-                                          start);
+               ret = find_free_dev_extent(device, num_bytes, start);
                if (ret)
                        goto err;
        }
@@ -497,8 +493,9 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
        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,
@@ -1035,9 +1032,7 @@ again:
                    (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;
@@ -1172,9 +1167,7 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans,
        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);