From 258f30c6d7d6a9aead90ff6bac851dd0f9db8fff Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Tue, 11 Jul 2017 17:15:36 +0530 Subject: cli: defend on minimum block size From, $ targetcli /backstores/user:glfs/block get attribute ATTRIBUTE CONFIG GROUP ====================== hw_block_size=512 [ro] ---------------------- Hence making the min acceptable size to be 1 sector/block i.e. 512 bytes This patch also, explicitly mention in docs about bytes as default size units. Change-Id: Iec8797082d02cc9ad51fc17e11f2ba3073aaeda0 Fixes: #35 Signed-off-by: Prasanna Kumar Kalever --- cli/gluster-block.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cli') diff --git a/cli/gluster-block.c b/cli/gluster-block.c index aca7de5..0196437 100644 --- a/cli/gluster-block.c +++ b/cli/gluster-block.c @@ -35,6 +35,7 @@ } \ } while(0) +# define GB_DEFAULT_SECTOR_SIZE 512 extern const char *argp_program_version; @@ -190,7 +191,7 @@ glusterBlockHelp(void) " [auth ]\n" " [prealloc ]\n" " \n" - " create block device [defaults: ha 1, auth disable, prealloc no]\n" + " create block device [defaults: ha 1, auth disable, prealloc no, size in bytes]\n" "\n" " list \n" " list available block devices.\n" @@ -408,6 +409,11 @@ glusterBlockCreate(int argcount, char **options, int json) LOG("cli", GB_LOG_ERROR, "failed while parsing size for block <%s/%s>", cobj.volume, cobj.block_name); goto out; + } else if (sparse_ret < GB_DEFAULT_SECTOR_SIZE) { + MSG("minimum acceptable block size is %d bytes\n", GB_DEFAULT_SECTOR_SIZE); + LOG("cli", GB_LOG_ERROR, "minimum acceptable block size is %d bytes <%s/%s>", + GB_DEFAULT_SECTOR_SIZE, cobj.volume, cobj.block_name); + goto out; } cobj.size = sparse_ret; /* size is unsigned long long */ -- cgit