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 +++++++- docs/gluster-block.8 | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) 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 */ diff --git a/docs/gluster-block.8 b/docs/gluster-block.8 index a23598f..39345a5 100644 --- a/docs/gluster-block.8 +++ b/docs/gluster-block.8 @@ -41,7 +41,7 @@ authentication setting (default: disable) servers in the pool where targets will be exported. .TP -size in KiB|MiB|GiB|TiB|PiB ... +size in B|KiB|MiB|GiB|TiB|PiB ... (default: bytes) .PP .SS -- cgit