1
0
mirror of https://github.com/gluster/gluster-block.git synced 2026-02-05 12:45:33 +01:00

78 Commits

Author SHA1 Message Date
Xiubo Li
6aef07f35b create: fix failing with io_timeout not support
If the configshell_fb package version is low, or checking the
CONFIGSHELL_VERSION fails, the create_io_timeout capability will
be disabled:

gluster-blockd[12934]: Traceback (most recent call last):
gluster-blockd[12934]: File "<string>", line 1, in <module>
gluster-blockd[12934]: ImportError: cannot import name __version__

WARNING: io timeout needs atleast configshell >=1.1.25 and tcmu-runner >= 1.5.0,
so disabling its capability [at capabilities.c+179 :<gbSetCapabilties>]

The old code will always set the io_timeout to _DEF value even
in this case when the create_io_timeout capability is disabled.
This will finally cause the gluster-block create fails even we
won't specify or care about the io-timeout option.

This fix will disable the io_timeout option as default and only
we the create_io_timeout capability is enabled will we set the
_DEF for it.

Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2020-03-31 14:06:35 +05:30
Xiubo Li
9767ecea84 genconfig: switch to string instead of fixed 255 for the volume
If we specify more than 2 volumes in one genconfig command line,
the genconfig will truncate the volumes.

Fixes: RHBZ#1787371
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2020-01-07 17:02:05 +05:30
Prasanna Kumar Kalever
d8fb2f2fa8 create: add tcmur_cmd_time_out option support
Set the tcmur_cmd_time_out=43s as default, which is larger than
each IO's timeout value(default is 30s) in the client/initiator side,
and at the same time it will be larger than 42s, the Gluster ping
timeout.

Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2019-11-14 14:25:41 +05:30
Prasanna Kumar Kalever
2863af468d reload: add capabilities
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-10-17 13:44:36 +05:30
Prasanna Kumar Kalever
70165bde45 reload: add ability to reload a single block volume
Problem:
-------
Right now, if any block volume is failed to load as part of service bringup
or node reboot, may be because of an issue from the backend, then there is
no way to reload that single block volume, we need to reload/restart all the\
block volumes present in the node just to load one block volume, this interrupts
ongoing  I/O (via this path) for all the volumes hosted within the node.

Solution:
--------
Add ability to reload a single block volume without touching other block volumes
in the node.

$ gluster-block help
usage:
  gluster-block [timeout <seconds>] <command> <volname[/blockname]> [<args>] [--json*]

commands:
[...]
  reload <volname/blockname>
        reload a block device.
[...]

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-10-17 13:44:36 +05:30
Xiubo Li
c5bb230db4 ringbuffer: fix the max limited size to 1024M
The ringbuffer size for each target could up to the global limitation
which is 2GB, here we will allow it up to 1GB. This relevant kernel
patch has been updated into the same verions with the dynamic growth
and shrink patch set.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
2019-09-26 17:11:22 +05:30
Prasanna Kumar Kalever
e5e686b700 cleanup: remove unsupported code
Previously we had code which allows passing more than HA number of hosts to the
create command. But the future was incomplete and this code was left dead.

This PR removes it all, may be once we have self-healing, this sort of  feature
addition becomes more easy.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-07-22 14:54:42 +05:30
Xiubo Li
b387d126b7 modify: clean the command options
The 'force' will only useful when resizing, so make it only optional
together with the size option.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-07-05 12:51:02 +05:30
Xiubo Li
0364da4d7a create: fail it with unknown options
If we pass some unknown options, there isn't any prompt messages and
it will continue and successes, like:

IQN: iqn.2016-12.org.gluster-block:d27f0da6-ccde-4479-bfd6-a6e9eb9790f1
PORTAL(S):  192.168.195.162:3260
RESULT: SUCCESS

It should fail the command.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-07-05 12:51:02 +05:30
Xiubo Li
698dbaced0 blksize: add hw block size setting support
This will still need to depend the taregetcli's saveconfig support,
the rtslib PR is open-iscsi/rtslib-fb#150.

When creating the BV with the 'block-size <SIZE>' option:

In case all the ha nodes have supported the rtslib-fb#150:
1) if local node support the block-size, but if there is any of
   the remote nodes is not, it will fail with the cap not match error.
2) if local node does not support the block-size, no matter whether
   the remote nodes support it or not, it will always ignore the
   block-size option due to the exist bug.

In case if there is any of the ha nodes does not support rtslib-fb#150:
3) if local node support the block-size, it will always fails with the
   cap not match error.
4) if local mode does not support the block-size, no matter whether
   the remote nodes support it or not, it will ignore the block-size
   option due to the exist bug.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-07-05 12:51:02 +05:30
Prasanna Kumar Kalever
635e25bd8c create: defend on the use of hostnames
We have noticed that our users are trying to create block volume with
hostnames and reporting issues, so it would be better if we defend it.

$ gluster-block create sample-test/block block.lab.green.com 1MiB
hostnames are not supported with gluster-block
Hint: please use ip addresses only

$ gluster-block create sample-test/block 192.168.43.158 1MiB
IQN: iqn.2016-12.org.gluster-block:2d4a2dfb-db5d-401c-b21a-01c57ad38705
PORTAL(S):  192.168.43.158:3260
RESULT: SUCCESS

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-05-02 19:00:39 +05:30
Xiubo Li
d3b1bb7ed5 gbConf: Use shared memory instead of from the data segment
Problems:
-------
Since we have make the cli and server routines into 2 different
processes in gluster-blockd daemon, the gbConf data will also
be have different copies. If the gbConf data is changed by the
dyn-config thread in the cli(parent) process, the new changes won't
be visible for the server(child) process.

Resolution:
----------
For the gbConf data, use the shared memory instead of the in the
data segment.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-29 21:18:03 +05:30
Xiubo Li
8d34a8bb38 spec: fix build warning
Problem:
-------
There has tons of warnings when building the rpms:

../utils/utils.h:166:25: warning: comparison with string literal results in unspecified behavior [-Waddress]
               if ((str) == "mgmt")                                     \
                         ^

gluster-block.c:463:3: warning: (near initialization for 'mobj.block_name') [-Wmissing-braces]
gluster-block.c:464:3: warning: missing braces around initializer [-Wmissing-braces]
   blockModifySizeCli msobj = {0, };
   ^

block_svc_routines.c: In function 'block_delete_cli_1_svc_st':
block_svc_routines.c:4707:37: warning: ?: using integer constants in boolean context [-Wint-in-bool-context]
   LOG("cmdlog", errCode?GB_LOG_ERROR:GB_LOG_INFO, "%s", reply->out);
../utils/utils.h:169:17: note: in definition of macro 'LOG'
             if (level <= gbConf.logLevel) {                            \
                 ^~~~~

Resolution:
----------
Use the strcmp() instead and add extra braces when initializing.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-26 15:13:33 +05:30
Xiubo Li
6fcff951b0 logger: allow without any variable argument
If there is no any variable argument in the logger callout, it
will hit the following compile errors:

../utils/utils.h:175:34: error: expected expression before ‘,’ token
                       __VA_ARGS__, __FILE__, __LINE__, __FUNCTION__);  \
                                  ^
gluster-blockd.c:268:5: note: in expansion of macro ‘LOG’
     LOG ("mgmt", GB_LOG_ERROR, "Test................");
     ^

More detail please see the GNU doc:
https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-18 14:12:38 +05:30
Prasanna Kumar Kalever
b246756023 gluster-block: correct some rpc socket setup bits
Creating the socket is not needed for svcunix_create(), it does all the
work for us (and prevents "address already in use" errors).

For svctcp_create(), the socket is expected on port 24010 and hence
needs to be setup completely with bind() and listen() before it can be
used. Registering the RPC-program should make it possible to use a
dynamically assigned port, but the gluster-block CLI expects it on the
static port.

This also fixes a warning when building the RPM from 'make dist' tarball
as the 22 June 2017 was a Thursday, nt Tuesday.

Changes from pkalever:
Add a flag at config time for tweaking the use of tirpc or glibc sunrpc
$ ./autogen.sh && ./configure --enable-tirpc=yes/no

Change-Id: If3a6b7527399dd0a5a16f4273efdd607617289de
Updates: #56
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-04-15 19:32:12 +05:30
Niels de Vos
3ac1399c0e rpc: use modern libtirpc instead of old glibc implementation
glibc has removed the rpc functions from current releases. Instead of
relying on glibc providing these, the modern libtirpc library should be
used instead.

Change-Id: I46c979e52147abce956255de5ad16b01b5621f52
Updates: #56
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-04-15 19:32:12 +05:30
Prasanna Kumar Kalever
5d8a381a7e cli: add log-msg for cli-timeout in DEBUG or higher level
gluster-block-cli.log:
[...]
[2019-04-05 08:20:38.738329] DEBUG: logLevel now is DEBUG
[at utils.c+50:<glusterBlockSetLogLevel>]
[2019-04-05 08:20:38.738515] DEBUG: cli timeout now is 300
[at gluster-block.c+171 :<glusterBlockCliRPC_1>]

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-05 14:27:39 +05:30
Prasanna Kumar Kalever
21f69e69db gluster-block: dump config key:value changes to respective log files
Problem:
-------
Currently cli process Loads Config on every operation in cli process
context. Hence log msgs:

DEBUG: logLevel now is TRACE [at utils.c+50:<glusterBlockSetLogLevel>]
DEBUG: glfsLruCount now is 5 [at lru.c+43:<glusterBlockSetLruCount>]

are dumped to gluster-blockd.log on every single cli operation. Apart
from the inotify triggers to Load Config.

Solution:
--------

Print the Key:Value config file parameters to respective log files based
on the process context.

That is,
- if cli process calls Load Config, then dump the logs to
gluster-block-cli.log (only DEBUG or higher level)
- if dameon process calls Load Config ( via DynConfig thread), then dump
the logs to gluster-blockd.log (in CRIT level)

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Tested-by: Xiubo Li <xiubli@redhat.com>
2019-04-05 12:08:39 +05:30
Prasanna Kumar Kalever
6f0451050d cli: fix dereference of undefined pointer value
reported by scan-build:

gluster-block.c:158:11: warning: Dereference of undefined pointer value
          create_obj->block_hosts);
          ^~~~~~~~~~~~~~~~~~~~~~~
../utils/utils.h:176:23: note: expanded from macro 'LOG'
                      __VA_ARGS__, __FILE__, __LINE__, __FUNCTION__);  \
                      ^~~~~~~~~~~
1 warning generated.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-04-03 21:11:44 +08:00
Prasanna Kumar Kalever
feb0aa1956 logs: remove '\n' in LOG() usage
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-03 18:32:11 +05:30
Prasanna Kumar Kalever
e9faa8ec58 create: turn 'prealloc full' by default
As of now prealloc is off by default.
This patch change the default prealloc to full.

Fixes: #149
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-04-02 09:43:18 +05:30
Xiubo Li
9c80c89ad8 logger: fix the log messages with adding extra whitspace
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-03-25 10:14:28 +05:30
Prasanna Kumar Kalever
262996608f cli: add timeout option
gluster-block (0.3)
usage:
  gluster-block [timeout <seconds>] <command> <volname[/blockname]> [<args>] [--json*]

commands:
  [...]
common cli options: (fixed formats)
  timeout <seconds>
        it is the time in seconds that cli can wait for daemon to respond.
        [default: timeout 300]
  --json*
        used to request the output result in json format [default: plain text]
        supported JSON formats: --json|--json-plain|--json-spaced|--json-pretty

Precedence of various methods to set cli timeout:
1. Options set through config file /etc/sysconfig/gluster-blockd          [Top Prio]
eg: uncommenting and adjusting key:value at /etc/sysconfig/gluster-blockd
2. Argument passed at cli
eg: timeout 900
3. Environment variable
eg: export GB_CLI_TIMEOUT=900
4. Code level defaults (300 sec)                                          [Least Prio]

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed & Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-02-20 16:17:56 +05:30
Prasanna Kumar Kalever
9b0849c3e8 Minor fixes (#176)
* blockGetPrioPath: avoid crash when nhosts is zero

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>

* cli: do not allow 'ha 0'

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-02-19 09:30:26 +05:30
Prasanna Kumar Kalever
090328521c cli: support env variable way of controlling GB_CLI_TIMEOUT
precedence:
1. config file, /etc/sysconfig/gluster-blockd          [high-prio]
2. env variable way, ex: # export GB_CLI_TIMEOUT=900;  [low-prio]

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed & Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-01-29 19:39:06 +05:30
Prasanna Kumar Kalever
61e6fa82f4 cli-timeout: make rpc-timeout as configurable option
There are two rpc calls involved in the design,
Channel A: From cli process to local daemon (cli thread)
Channel B: From local daemon (cli thread) to remote daemon (remote thread)

Timeout for channel A is configurable now, using
/etc/sysconfig/gluster-blockd, by adjusting option 'GB_CLI_TIMEOUT' (in seconds)

$ cat /etc/sysconfig/gluster-blockd
GB_CLI_TIMEOUT=900

Changes to this value takes effect every time we start running/triggering new
cli command/request.

At the moment making Timeout configurable for channel B is not important, it is
hardcoded as 300 seconds in the code for now.

Some more details:
-----------------
It would have been an easy fix calling clnt_control() right after clnt_create(),
unfortunately there is a bug in glibc, which is why we had to hack the rpc
generated code instead of directly calling clnt_control(), see my very old
commit [1] which explains why we had to override (in a hacky-way) the default
generated TIMEOUT.

[1] 1dbbd7d457

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed & Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-01-29 19:39:06 +05:30
Amar Tumballi
0fd2ea41bd coverity: fix multiple issues (#172)
CIDs involved:
326396 - Constant variable guards deadcode
326345 - Argument cannot be negative
326355 - Infinite loop
326371 - Printf format string issue
328498 - Resource leak
328500 - Unchecked return value
326360 - Explicit null dereference

Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-01-03 16:24:54 +05:30
Prasanna Kumar Kalever
88624a0f7c cli: push output to stderr if remote rpc return non-zero
This is basically what we have missed at #121

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-11-29 19:07:24 +05:30
Xiubo Li
866f9e6ae9 cli: clean up the code style
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2018-11-15 19:20:33 +05:30
Prasanna Kumar Kalever
fd62ac4f57 gluster-block: dump all failure msgs to stderr
Ensure:
On FAILURE dump error msg to stderr
On SUCCESS dump response to stdout

Fixes: #117
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-10-24 17:22:50 +05:30
Xiubo Li
ec38036302 genconfig: add helper info
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2018-10-12 14:32:51 +05:30
Bhumika Goyal
8416247cbc Auditlog Feature
Record the responses of all the requests for the operations
Create/Delete/Modify/Replace on gluster-block.
The logging format is:

In case of success:
[time] INFO: <command string> <function details>
[time] INFO: Response string <function details>

In case of failure:
[time] INFO: <command string> <function details>
[time] ERROR: Response string <function details>

Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Bhumika Goyal <bgoyal@redhat.com>
2018-09-25 13:30:12 +05:30
Bhumika Goyal
3a64fff50e Help/man page update
With the introduction of new option 'storage' for the create command,
the field 'size' is rendered optional when that 'storage' option is given.
Update the man page and help commands to reflect this change.

Signed-off-by: Bhumika Goyal <bgoyal@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-08-13 12:49:06 +05:30
Prasanna Kumar Kalever
766f97ed8a rpc: avoid socket double free
From man:

clnt_destroy(CLIENT *clnt);
 A macro that destroys the client's RPC handle.  Destruction usually involves
 deallocation of  private data  structures,  including clnt itself.  Use of
 clnt is undefined after calling clnt_destroy(). If the RPC library opened the
 associated socket, it will close it also. Otherwise, the socket remains open.

we are closing the socket twice in this case,
i.e. by calling clnt_destroy and then close(sockfd)

Thanks to Pranith for the RC.

Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Pranith Kumar K <pkarampu@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-07-18 11:29:31 +05:30
Xiubo Li
e971593411 gluster-block: align the target device size to sector size
This will align the target device size to GB_DEFAULT_SECTOR_SIZE

Tested-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Pranith Kumar K <pkarampu@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2018-07-11 14:15:26 +05:30
Prasanna Kumar Kalever
917d0b2924 gluster-block: fix gcc and rpmbuild warnings
Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Pranith Kumar K <pkarampu@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-06-12 15:21:34 +05:30
Prasanna Kumar Kalever
4a0ac4998a genconfig: add support
$ gluster-block genconfig
Inadequate arguments for genconfig:
gluster-block genconfig <volname[,volume2,volume3,...]> enable-tpg <host> [--json*]

$ gluster-block genconfig testvol1,testvol2 enable-tpg 192.168.124.227
{
  "storage_objects":[
    {
      "attributes":{
        "cmd_time_out":0,
        "dev_size":1073741824
      },
      "config":"glfs/testvol1@192.168.124.227/block-store/8effb447-875b-407e-8fe5-bd6500a96ee6",
      "name":"blockX",
      "plugin":"user",
      "size":1073741824,
      "wwn":"8effb447-875b-407e-8fe5-bd6500a96ee6"
    },
...
}

Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Pranith Kumar K <pkarampu@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-06-05 12:43:03 +08:00
Prasanna Kumar Kalever
5a180e9c50 modify: fix auth command args parsing
Fix regression introduced by:

commit cfa7677b1e
Author: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Date:   Wed Mar 21 16:28:15 2018 +0530

    gluster-block: add resize support

Fixes: #71
Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Pranith Kumar K <pkarampu@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-04-09 19:57:29 +05:30
Prasanna Kumar Kalever
34c4a6d535 create: add TCMU Ring Buffer size settable
$ gluster-block --help
[...]
commands:
  create  <volname/blockname> [ha <count>]
                              [auth <enable|disable>]
                              [prealloc <full|no>]
                              [storage <filename>]
                              [ring-buffer <size-in-MB-units>]
                              <host1[,host2,...]> <size>
        create block device [defaults: ha 1, auth disable, prealloc no, size in bytes,
                             ring-buffer default size dependends on kernel]
[...]

$ gluster-block create dht0/block33 ring-buffer 60 ha 3 192.168.195.137,192.168.195.134,192.168.195.135 1G --json-pretty
{
  "IQN":"iqn.2016-12.org.gluster-block:1e9d26a4-28d7-43a5-a2dc-b7d08a6cbedd",
  "PORTAL(S)":[
    "192.168.195.137:3260",
    "192.168.195.134:3260",
    "192.168.195.135:3260"
  ],
  "RESULT":"SUCCESS"
}

$ cat block-meta/block32
VOLUME: dht0
GBID: da787d30-ac8a-420c-8907-09b494e07ebf
HA: 3
ENTRYCREATE: INPROGRESS
SIZE: 1073741824
RINGBUFFER: 60
ENTRYCREATE: SUCCESS
192.168.195.137: CONFIGINPROGRESS
192.168.195.134: CONFIGINPROGRESS
192.168.195.135: CONFIGINPROGRESS
192.168.195.134: CONFIGSUCCESS
192.168.195.137: CONFIGSUCCESS
192.168.195.135: CONFIGSUCCESS

$ targetcli /backstores/user:glfs/block32/ get attribute max_data_area_mb
max_data_area_mb=60 [ro]

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-03-23 20:51:08 +05:30
Prasanna Kumar Kalever
cfa7677b1e gluster-block: add resize support
$ gluster-block modify sample/block1 size 20GiB --json-pretty
{
    "IQN":"iqn.2016-12.org.gluster-block:1a84d8d1-a6d9-4761-9531-47736468186f",
    "SIZE":"20.0 GiB",
    "SUCCESSFUL ON":[
      "192.168.0.105"
    ],
    "RESULT":"SUCCESS"
}

Fixes: #6
Change-Id: I422095bf4a9bc7c7774de1426621255e7dc533ab
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-03-23 19:22:14 +05:30
Prasanna Kumar Kalever
8b106204f5 fix spec file
also other minor compiler errors

Change-Id: I17625008d91740f3ba9efc6e574ec3dcd0b6c85f
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-03-06 15:42:26 +05:30
Prasanna Kumar Kalever
7008073e1d delete: support [unlink-storage <yes|no>] option
$ gluster-block help
gluster-block (0.3)
usage:
  gluster-block <command> <volname[/blockname]> [<args>] [--json*]

commands:
[...]

  delete  <volname/blockname> [unlink-storage <yes|no>] [force]
        delete block device.
[...]
supported JSON formats:
  --json|--json-plain|--json-spaced|--json-pretty

Change-Id: I64bc99a8519be6f90a7e8bc5558b0d7518661995
Fixes: #19
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-02-08 13:11:56 +05:30
Prasanna Kumar Kalever
450f7e8911 create: support [storage <filename>] option
$ gluster-block help
gluster-block (0.3)
usage:
  gluster-block <command> <volname[/blockname]> [<args>] [--json*]

commands:
  create  <volname/blockname> [ha <count>]
                              [auth <enable|disable>]
                              [prealloc <full|no>]
                              [storage <filename>]
                              <host1[,host2,...]> <size>
        create block device [defaults: ha 1, auth disable, prealloc no, size in bytes]
[...]
supported JSON formats:
  --json|--json-plain|--json-spaced|--json-pretty

Fixes: #18
Change-Id: I5d9b4abb58596bd2297cffb294c6d31f752d53e9
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-02-08 13:11:40 +05:30
Prasanna Kumar Kalever
d7ebb69745 replace strcat and strcpy with their secure versions
Change-Id: If98ce7b7e50901ee130bbe190a12664ec0adb8c2
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-02-08 12:30:49 +05:30
Prasanna Kumar Kalever
540e81676b replace: add replace feature
1. create conf in new node
2. delete conf from old node
3. replace portals from nodes hosting other paths (HA)

$ gluster-block create sample/block ha 3 192.168.124.57,192.168.124.26,192.168.124.30 1GiB --json-pretty
{
  "IQN":"iqn.2016-12.org.gluster-block:d516bb5c-5f56-4d9c-96a7-385df19c2e2c",
  "PORTAL(S)":[
    "192.168.124.57:3260",
    "192.168.124.26:3260",
    "192.168.124.30:3260"
  ],
  "RESULT":"SUCCESS"
}

$ gluster-block help
gluster-block (0.3)
usage:
  gluster-block <command> <volname[/blockname]> [<args>] [--json*]

commands:
[...]
  replace <volname/blockname> <old-node> <new-node> [force]
        replace operations.
[...]

supported JSON formats:
  --json|--json-plain|--json-spaced|--json-pretty

$ gluster-block replace sample/block 192.168.124.26 192.168.124.56 --json-pretty
{
  "NAME":"block",
  "CREATE SUCCESS":"192.168.124.56",
  "DELETE SUCCESS":"192.168.124.26",
  "REPLACE PORTAL SUCCESS ON":[
    "192.168.124.57",
    "192.168.124.30"
  ],
  "RESULT":"SUCCESS"
}

Fixes: #4
Change-Id: I0411d15c407111db0d423052d9a6bc075174bf90
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-02-07 16:49:21 +05:30
Michael Adam
f03d641062 cli: make unit prefixes case insensitive
Change-Id: I28544d08217f15b90c3e439bfd9aa75ba0432d07
Signed-off-by: Michael Adam <obnox@redhat.com>
2017-12-21 08:19:58 +01:00
Prasanna Kumar Kalever
258f30c6d7 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>
2017-10-09 13:54:57 +00:00
Prasanna Kumar Kalever
3d0953aa99 rpc: switch to MT-safe block RPC routines
blockResponse *
block_delete_1(blockDelete *argp, CLIENT *clnt)
{
        static blockResponse clnt_res; <<<<<<-------- Same memory is used by everyone

        memset((char *)&clnt_res, 0, sizeof(clnt_res)); <<<<<---- Here memset is happening
        if (clnt_call (clnt, BLOCK_DELETE,
                (xdrproc_t) xdr_blockDelete, (caddr_t) argp,
                (xdrproc_t) xdr_blockResponse, (caddr_t) &clnt_res,
                TIMEOUT) != RPC_SUCCESS) {
                return (NULL);
        }
        return (&clnt_res); <<<<<---- ptr to this memory is returned.
}

So while Thread-1 is returned "return (&clnt_res);" another thread could be
doing "memset((char *)&clnt_res, 0, sizeof(clnt_res));"

This seem to be a day-1 gluster-blockd bug from the looks of it.

Change-Id: I3fc76d7814c4fe5b286577586ec44d752dcc73f0
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
2017-09-19 04:07:48 +00:00
Prasanna Kumar Kalever
b535c44fdd logger: support logdir choosing via Environment variable
Currently the default logdir is DATADIR /log/gluster-block/

This patch will provide a way to change this default logdir via Env variable
$ export GB_LOGDIR=/var/log/gluster-block-new-path/

Note: make sure to restart the processes (cli & daemon) after you set GB_LOGDIR

Change-Id: Id142e4a4dfe7b6ebc9cf8296b8ceb8bff37691b8
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2017-08-17 14:22:55 +05:30
Prasanna Kumar Kalever
d723907c8e gluster-block: support force delete option
$ gluster-block help
gluster-block (0.2.1)
usage:
  gluster-block <command> <volname[/blockname]> [<args>] [--json*]

commands:
[...]
  delete  <volname/blockname> [force]
        delete block device.
[...]

Change-Id: I64ac01ec148e2e1d4d0ba0d4c5560df9334d58f5
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2017-08-08 15:44:32 +05:30