From 94c79620db4451bf804d6ab631c9ca59759dbc21 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Mon, 12 Jun 2017 11:59:13 +0530 Subject: block: add support to prealloc = full | no option currently we allocate sparse files for block backends in the gluster volume, with 'prealloc = full' option introduced by this patch we should be able to fully preallocate the backend block file. Change-Id: Ibf32df5f978f732a3fd248693170463da6d08268 Signed-off-by: Prasanna Kumar Kalever --- cli/gluster-block.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'cli/gluster-block.c') diff --git a/cli/gluster-block.c b/cli/gluster-block.c index 833f232..0aab6e6 100644 --- a/cli/gluster-block.c +++ b/cli/gluster-block.c @@ -189,8 +189,11 @@ glusterBlockHelp(void) " gluster-block [] [--json*]\n" "\n" "commands:\n" - " create [ha ] [auth enable|disable] \n" - " create block device.\n" + " create [ha ]\n" + " [auth ]\n" + " [prealloc ]\n" + " \n" + " create block device [defaults: ha 1, auth disable, prealloc no]\n" "\n" " list \n" " list available block devices.\n" @@ -292,10 +295,9 @@ glusterBlockModify(int argcount, char **options, int json) /* if auth given then collect status which is next by 'auth' arg */ if (!strcmp(options[optind], "auth")) { optind++; - if(strcmp (options[optind], "enable") == 0) { - mobj.auth_mode = 1; - } else if (strcmp (options[optind], "disable") == 0) { - mobj.auth_mode = 0; + ret = convertStringToTrillianParse(options[optind++]); + if(ret >= 0) { + mobj.auth_mode = ret; } else { MSG("%s\n", "'auth' option is incorrect"); MSG("%s\n", GB_MODIFY_HELP_STR); @@ -354,10 +356,9 @@ glusterBlockCreate(int argcount, char **options, int json) /* if auth given then collect boolean which is next by 'auth' arg */ if (!strcmp(options[optind], "auth")) { optind++; - if(strcmp (options[optind], "enable") == 0) { - cobj.auth_mode = 1; - } else if (strcmp (options[optind], "disable") == 0) { - cobj.auth_mode = 0; + ret = convertStringToTrillianParse(options[optind++]); + if(ret >= 0) { + cobj.auth_mode = ret; } else { MSG("%s\n", "'auth' option is incorrect"); MSG("%s\n", GB_CREATE_HELP_STR); @@ -366,7 +367,24 @@ glusterBlockCreate(int argcount, char **options, int json) cobj.volume, cobj.block_name); goto out; } + } + } + + if (argcount - optind >= 2) { /* atleast 2 needed */ + /* if prealloc given then collect boolean which is next by 'prealloc' arg */ + if (!strcmp(options[optind], "prealloc")) { optind++; + ret = convertStringToTrillianParse(options[optind++]); + if(ret >= 0) { + cobj.prealloc = ret; + } else { + MSG("%s\n", "'prealloc' option is incorrect"); + MSG("%s\n", GB_CREATE_HELP_STR); + LOG("cli", GB_LOG_ERROR, "Create failed while parsing argument " + "to prealloc for <%s/%s>", + cobj.volume, cobj.block_name); + goto out; + } } } -- cgit