summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-07-11 17:15:36 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2017-10-09 13:54:57 +0000
commit258f30c6d7d6a9aead90ff6bac851dd0f9db8fff (patch)
treeebce716db75a769dd7bd2d588f5fa4609a33b1cc
parente6ed5b53cf33b4315ee2846a9f773cd672a5de8c (diff)
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 <prasanna.kalever@redhat.com>
-rw-r--r--cli/gluster-block.c8
-rw-r--r--docs/gluster-block.82
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 <enable|disable>]\n"
" [prealloc <full|no>]\n"
" <host1[,host2,...]> <size>\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 <volname>\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
<BYTES>
-size in KiB|MiB|GiB|TiB|PiB ...
+size in B|KiB|MiB|GiB|TiB|PiB ... (default: bytes)
.PP
.SS