Message ID | 20200602090905.63899-6-wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Introduce per-profile available space array to avoid over-confident can_overcommit() | expand |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index fec2a62cbcf9..6a0850ce5f37 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -5282,6 +5282,15 @@ static int create_chunk(struct btrfs_trans_handle *trans, &trans->transaction->dev_update_list); } ret = calc_per_profile_avail(info); + if (ret < 0) { + for (i = 0; i < map->num_stripes; i++) { + struct btrfs_device *dev = map->stripes[i].dev; + + btrfs_device_set_bytes_used(dev, + dev->bytes_used - ctl->stripe_size); + } + goto error_del_extent; + } atomic64_sub(ctl->stripe_size * map->num_stripes, &info->free_chunk_space);
In __btrfs_alloc_chunk(), if calc_per_profile_avail() failed, it will not update the per-profile available space array. However since device used space is already updated, this would cause a mismatch between them. To fix this problem, this patch will revert device used bytes when calc_per_profile_avail() failed, and remove the newly allocated chunk. Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/volumes.c | 9 +++++++++ 1 file changed, 9 insertions(+)