}
if (device->writeable) {
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
list_del_init(&device->dev_alloc_list);
device->fs_devices->rw_devices--;
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
clear_super = true;
}
error_undo:
if (device->writeable) {
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
list_add(&device->dev_alloc_list,
&fs_info->fs_devices->alloc_list);
device->fs_devices->rw_devices++;
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
}
goto out;
}
list_for_each_entry(device, &seed_devices->devices, dev_list)
device->fs_devices = seed_devices;
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
list_splice_init(&fs_devices->alloc_list, &seed_devices->alloc_list);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
fs_devices->seeding = 0;
fs_devices->num_devices = 0;
device->fs_devices = fs_info->fs_devices;
mutex_lock(&fs_info->fs_devices->device_list_mutex);
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
list_add_rcu(&device->dev_list, &fs_info->fs_devices->devices);
list_add(&device->dev_alloc_list,
&fs_info->fs_devices->alloc_list);
*/
btrfs_clear_space_info_full(fs_info);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
if (seeding_dev) {
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
ret = init_first_rw_device(trans, fs_info, device);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto error_trans;
if (!device->writeable)
return -EACCES;
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
old_total = btrfs_super_total_bytes(super_copy);
diff = new_size - device->total_bytes;
if (new_size <= device->total_bytes ||
device->is_tgtdev_for_dev_replace) {
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
return -EINVAL;
}
if (list_empty(&device->resized_list))
list_add_tail(&device->resized_list,
&fs_devices->resized_devices);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
return btrfs_update_device(trans, device);
}
u32 cur;
struct btrfs_key key;
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
array_size = btrfs_super_sys_array_size(super_copy);
ptr = super_copy->sys_chunk_array;
cur += len;
}
}
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
return ret;
}
return -EINVAL;
}
map = em->map_lookup;
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
check_system_chunk(trans, fs_info, map->type);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
/*
* Take the device list mutex to prevent races with the final phase of
}
if (device->bytes_used > 0) {
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
btrfs_device_set_bytes_used(device,
device->bytes_used - dev_extent_len);
spin_lock(&fs_info->free_chunk_lock);
fs_info->free_chunk_space += dev_extent_len;
spin_unlock(&fs_info->free_chunk_lock);
btrfs_clear_space_info_full(fs_info);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
}
if (map->stripes[i].dev) {
path->reada = READA_FORWARD;
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
btrfs_device_set_total_bytes(device, new_size);
if (device->writeable) {
fs_info->free_chunk_space -= diff;
spin_unlock(&fs_info->free_chunk_lock);
}
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
again:
key.objectid = device->devid;
goto done;
}
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
/*
* We checked in the above loop all device extents that were already in
if (contains_pending_extent(trans->transaction, device,
&start, len)) {
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
checked_pending_chunks = true;
failed = 0;
retried = false;
WARN_ON(diff > old_total);
btrfs_set_super_total_bytes(super_copy, old_total - diff);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
/* Now btrfs_update_device() will change the on-disk size. */
ret = btrfs_update_device(trans, device);
done:
btrfs_free_path(path);
if (ret) {
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
btrfs_device_set_total_bytes(device, old_size);
if (device->writeable)
device->fs_devices->total_rw_bytes += diff;
spin_lock(&fs_info->free_chunk_lock);
fs_info->free_chunk_space += diff;
spin_unlock(&fs_info->free_chunk_lock);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
}
return ret;
}
u32 array_size;
u8 *ptr;
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
array_size = btrfs_super_sys_array_size(super_copy);
if (array_size + item_size + sizeof(disk_key)
> BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) {
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
return -EFBIG;
}
memcpy(ptr, chunk, item_size);
item_size += sizeof(disk_key);
btrfs_set_super_sys_array_size(super_copy, array_size + item_size);
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
return 0;
}
return -ENOMEM;
mutex_lock(&uuid_mutex);
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
/*
* Read all device items, and then all the chunk items. All
}
ret = 0;
error:
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
mutex_unlock(&uuid_mutex);
btrfs_free_path(path);
return;
mutex_lock(&fs_devices->device_list_mutex);
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
list_for_each_entry_safe(curr, next, &fs_devices->resized_devices,
resized_list) {
list_del_init(&curr->resized_list);
curr->commit_total_bytes = curr->disk_total_bytes;
}
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
mutex_unlock(&fs_devices->device_list_mutex);
}
return;
/* In order to kick the device replace finish process */
- lock_chunks(fs_info);
+ mutex_lock(&fs_info->chunk_mutex);
list_for_each_entry(em, &transaction->pending_chunks, list) {
map = em->map_lookup;
dev->commit_bytes_used = dev->bytes_used;
}
}
- unlock_chunks(fs_info);
+ mutex_unlock(&fs_info->chunk_mutex);
}
void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info)