[sheepdog] [PATCH] dog: fix to calculate a resizable max VDI size appropriately
Teruaki Ishizaki
ishizaki.teruaki at lab.ntt.co.jp
Tue Feb 10 09:53:44 CET 2015
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;
}
--
1.7.1
More information about the sheepdog
mailing list