[sheepdog] [PATCH] dog: fix to calculate a resizable max VDI size appropriately
Liu Yuan
namei.unix at gmail.com
Thu Feb 12 02:36:43 CET 2015
On Tue, Feb 10, 2015 at 05:53:44PM +0900, Teruaki Ishizaki wrote:
> A resizable max VDI size was fixed value, 4TB.
>
> So, when block_size_shift was specified more than 22,
> resizing VDI size over 4TB caused error.
>
> This patch enables to calculate a resizable max VDI properly.
>
> Signed-off-by: Teruaki Ishizaki <ishizaki.teruaki at lab.ntt.co.jp>
> ---
> dog/vdi.c | 24 +++++++++++++++---------
> 1 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/dog/vdi.c b/dog/vdi.c
> index 6cb813e..8e5ab13 100644
> --- a/dog/vdi.c
> +++ b/dog/vdi.c
> @@ -845,8 +845,8 @@ out:
> static int vdi_resize(int argc, char **argv)
> {
> const char *vdiname = argv[optind++];
> - uint64_t new_size;
> - uint32_t vid;
> + uint64_t new_size, old_max_total_size;
> + uint32_t vid, object_size;
> int ret;
> char buf[SD_INODE_HEADER_SIZE];
> struct sd_inode *inode = (struct sd_inode *)buf;
> @@ -863,13 +863,19 @@ static int vdi_resize(int argc, char **argv)
> if (ret != EXIT_SUCCESS)
> return ret;
>
> - if (new_size > SD_OLD_MAX_VDI_SIZE && 0 == inode->store_policy) {
> - sd_err("New VDI size is too large");
> - return EXIT_USAGE;
> - }
> -
> - if (new_size > SD_MAX_VDI_SIZE) {
> - sd_err("New VDI size is too large");
> + object_size = (UINT32_C(1) << inode->block_size_shift);
> + old_max_total_size = object_size * OLD_MAX_DATA_OBJS;
> + if (0 == inode->store_policy) {
> + if (new_size > old_max_total_size) {
> + sd_err("New VDI size is too large."
> + " This volume's max size is %"PRIu64,
> + old_max_total_size);
> + return EXIT_USAGE;
> + }
> + } else if (new_size > SD_MAX_VDI_SIZE) {
> + sd_err("New VDI size is too large"
> + " This volume's max size is %llu",
> + SD_MAX_VDI_SIZE);
> return EXIT_USAGE;
> }
>
Applied thanks. BTW, we don't reach how we make use this additional field yet.
I don't think we should expose block_size_shift to plain users. For users,
object size is much more direct and simple to understand. There is no reason
we can't expose object size as option to users, no?
Thanks
Yuan
More information about the sheepdog
mailing list