1
0
mirror of https://github.com/gluster/glusterfs.git synced 2026-02-06 09:48:44 +01:00
Commit Graph

995 Commits

Author SHA1 Message Date
Aravinda VK
b664044c1c cli: Fix Hostname validation
Gluster volume create command fails to use the hostnames
that starts with `0.`

```
Please provide a valid hostname/ip other than localhost, 127.0.0.1 or
loopback address (0.0.0.0 to 0.255.255.255).
```

For example:

```
gluster volume create vol1 0.s1.dev:/data/gfs/vol1/b1 force
```

Fixes: #4309
Signed-off-by: Aravinda VK <aravinda@kadalu.tech>
2024-02-15 23:50:29 +05:30
mohit84
d3e2e1344a Coverity: Fix several coverity warnings (#4098)
CID 1506829  Use of 32-bit time_t
  cli/src/cli-cmd.c
CID 1504519  DEADCODE
  xlators/mgmt/glusterd/src/glusterd-syncop.c
CID 1502328  Improper use of -ve
  xlators/nfs/server/src/mount3.c
CID 1502327  Uninitialized scalar variable
  xlators/storage/posix/src/posix-inode-fd-ops.c
CID 1502326  Improper use of -ve
  xlators/nfs/server/src/mount3.c
CID 1502325  Improper use of -ve
  xlators/nfs/server/src/mount3.c
CID 1502324  Resource leak
  xlators/features/marker/src/marker.c
CID 1502323  Improper use of -ve
  xlators/cluster/dht/src/dht-rebalance.c
CID 1502322  Improper use of -ve
  xlators/features/changelog/lib/src/gf-history-changelog.c
CID 1502321  Double free
  xlators/system/posix-acl/src/posix-acl.c
CID 1502320  Improper use of -ve
  xlators/storage/posix/src/posix-inode-fd-ops.c
CID 1502317  Improper use of -ve
  xlators/nfs/server/src/mount3.c
CID 1502316  Dereference after NULL check
  libglusterfs/src/glusterfs/dict.h
CID 1502315  Uninitialized scalar variable
  xlators/features/snapview-client/src/snapview-client.c
CID 1502314  Uninitialized scalar variable
  xlators/features/snapview-server/src/snapview-server.c
CID 1502313  Resource leak
  cli/src/cli-cmd-system.c
CID 1502312  Resource leak
  api/src/glfs-fops.c
CID 1502311  Use of 32-bit time_t
  xlators/cluster/ec/src/ec-common.c

Updates #1060
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>

Change-Id: Ic0a939d0bb4f568b5c3f60a5930c90ebeb6a28d4
2023-04-05 19:24:15 +05:30
Niraj Kumar Yadav
f6da05e2c1 [cli-cmd] Fix return type (#4048)
* [cli-cmd] Fix return type

time_t is signed on UNIX/POSIX compliant systems.
 
Use time_t for better clarity of return type

Change-Id: I47976d63f122f24e095c1aacf7a50b50e46616b3
Signed-off-by: black-dragon74 <niryadav@redhat.com>
2023-03-21 06:59:52 +05:30
karthik-us
92f7b6d371 [coverity]: Fix resource leak in cli-cmd-parser.c
CID: 1487685

Change-Id: I87f16253bbd20e103deb01617c9ae13828107758
Updates: #1060
Signed-off-by: karthik-us <ksubrahm@redhat.com>
2023-02-27 15:01:27 +01:00
Kaleb S. KEITHLEY
cef682c03d glusterfs: Build with Modern C, change set 5
GCC and Clang communities are hinting that in versions 14 and 16
respectively they will deprecate or disable legacy C89 features,
e.g. K&R1 style function definitions, among others.

In parallel, Fedora is going to start enforcing C99 as the minimum,
expected to land in F40. (I.e. around Spring 2024 IIRC.)

Currently Fedora is recommending that use of -Werror=implicit-int,
-Werror=implicit-function-declaration, -Werror=int-conversion,
-Werror=strict-prototypes, and -Werror=old-style-definition a set
of options to build with in the mean time to clean up code.

This change fixes a subset of the errors found when compiling with
this set of options.

Change-Id: I2025e39566aeb1f68836226d6d18c43418ca7f95
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2022-11-02 10:05:46 +01:00
Yaniv Kaul
0b1dcc1b2f Use a flexible array member for data pair key (#3870)
* dictionary data_pair: make key a flexible array member

We always ended up calling allocation - even though we tried to avoid it using the free pair which was supposed to handle
the common case of a single data pair in a dictionary, we still called GF_MALLOC for the key.
Instead, allocate the key together with the data pair, unconditionally, in a single call.
This also simplifies the code a bit by getting rid of the logic around the free pair and removes multiple checks for NULL of pair->key.

Updates: #1000
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>

* Multiple files: remove dict_pair_pool memory pool

It's not needed anymore, now that we allocate the pair (along with the pair->key).

Updates: #1000
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2022-10-18 09:13:12 +02:00
Aravinda Vishwanathapura
a5748dfe2f Fix showing wrong distCount in XML output (#3663)
While reading from the Volinfo, `distCount` is set to `dist_leaf_count`
instead of `brick_count / dist_leaf_count`.

Fixes: #3662
Change-Id: I6e909d0ba82658bab60181a39d124ccc84da4418
Signed-off-by: Aravinda Vishwanathapura <aravinda@kadalu.tech>
2022-08-05 09:58:14 +05:30
Dmitry Antipov
ce225d8a60 rpc, cli, dht, glusterd: unify defrag related enums
Since 'gf_cli_defrag_type' is actually used beyond cli,
consistently rename it to 'gf_defrag_type_t' and use the
only definition from cli1-xdr.x everywhere, as well as
with 'gf_defrag_status_t'.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2022-05-31 12:39:25 +02:00
Dmitry Antipov
6cb49f6ff5 libglusterfs: add function to set limit of open file descriptors
Introduce 'gf_set_nofile()' to wrap commonly (well, beyond Darwin)
used 'setrlimit(RLIMIT_NOFILE, ...)', adjust related code and drop
useless inclusion of 'sys/resource.h' here and there.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2022-05-26 09:11:29 +02:00
Chen Jinhao
02f9551678 Fix ta_brick parse failure (#3508)
Set ta_brick as empty after malloc, to ensure
the correct brick info can be obtained by glusterd.

Fixes: #3507

Change-Id: I674bdb9554731b6f456bb7ce0b685ebb4fe7f234
Signed-off-by: ChenJinhao <chen.jinhao@zte.com.cn>
2022-05-17 17:35:17 +05:30
Dmitry Antipov
ab745e2d8d libglusterfs, cli: use qsort everywhere (#3482)
Drop 'gf_array_insertionsort()' and related quirks, tweak
'cmd_profile_volume_brick_out()' and 'cli_cmd_sort()' to
use standard 'qsort()' instead.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2022-05-06 12:33:10 +02:00
Dmitry Antipov
32d9aceecf cli: simplify command submission routines
Drop really unused and always-NULL 'struct iobref *' argument of
'cli_cmd_submit()', 'cli_submit_request()' and 'cli_to_glusterd()',
adjust related code.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2022-05-04 09:37:45 +02:00
Yaniv Kaul
4f537c0e02 cli.c: cli_local_get() did not check for GF_CALLOC() success (#3463)
Fixed so it ensures local is actually allocated before trying to use it.

Updates: #1000
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2022-04-25 07:23:35 +05:30
Dmitry Antipov
e02c233713 build: drop libglusterd (#3433)
Since libglusterd consists of just two simple functions
which can be easily inlined, it may be replaced with the
only header, which is rpc/rpc-lib/src/protocol-utils.h.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2022-04-18 10:50:28 +05:30
Yaniv Kaul
2bd36b3c15 cli.c: do not use iobuf pool (#2966)
* cli.c: do not use iobuf pool

There's really no need to allocate an iobuf pool for the CLI.
It's a waste of memory and CPU to do all this allocation for CLI command
invocation.

Fixes: #2963
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>

* iobuf.c: make iobuf_get_from_small() non static and use in cli

Re-use the function, by making it non-static.

(Remove the unneeded use of 'ret' in the function while at it).

Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2022-03-05 11:59:56 +05:30
Yaniv Kaul
55420543c2 Multiple files: cleanup common include files (#3140)
As a continuation to #3130 , there are several .h files that are included in various files.
However, many of the definitions in those include files should be local to specific files, or is simply dead code.
We can easily clean them up.
Note - there are some functions that were deemed useful as common or utilities that were meant to be shared across the codebase.
After 10 or so years, I think it's OK to move some of them that were never shared across the code,
to their own users (and make them static while at it).

This commit specifically cleaned up glusterd-utils.c

    Updates: #3137
    Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2022-02-28 08:10:54 +05:30
Sheetal Pamecha
b1b5ed7355 cli: syntax check for disperse volume creation
If the number of fragments are more than 16, volume mount fails.
Ideally it should fail at volume creation only

Fixes: #3217
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
2022-02-15 12:32:38 +01:00
Yaniv Kaul
3b00855b0f Multiple files: reduce the number of include statements (#3141)
We have hundreds of redundant, or unused #include statements in the code. I have a WIP patch to remove many of them
We have several that are circular (include A calls B which calls A ...)
We have some unused statements in popular include file (glusterd.h is a good example).
The end goal would be to reduce the no. of include statements, include what's needed,
and thus improve code readability, maintainability and hopefully reduce compilation times.

Note: it is still not pretty, but it's a good step towards really including what is needed, per file/modulex/xlator/...

Updates: #3130
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2022-02-12 10:06:42 +05:30
Yaniv Kaul
33cec86d97 Multiple files: reduce the work needed to format the time in a log line (#3014)
Many inovcations use the same format - gf_timefmt_FT.
Co-locate the functions in the same file, to make them static, reduce
the unneeded calls and create a specific function for this use case.

Convert some gf_time_fmt() to gf_time_fmt_FT() and gf_time_fmt_tv()
to gf_time_fmt_tv_FT().

In the cases where we have the ctx variable, use it and skip the
call to gf_log_get_localtime() which calls 'THIS'.

Fixes: #1000
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2022-02-09 12:37:23 +05:30
Yaniv Kaul
c2af6523c5 Events: make structures more memory friendly (#3041)
Move separate fields to the same structure, to make them accessible
together.

Some other minor cleanups, mainly removing work from under lock, etc.

Updates: #1000
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2022-02-09 12:35:26 +05:30
Aravinda Vishwanathapura
1787def0ab snapshots: plugin architecture (#2834)
* snapshots: plugin architecture

A few plugin APIs are based on below repo. New plugin methods are
added that were not present in the initial code, also some of the
methods like getting device, missed_snaps are removed.

https://github.com/major0/glusterfs/commits/glusterfs-snapshots

Retained the original authors. This PR contains only the code
changes that are required to make the current glusterd code pluggable.

ZFS and Btrfs plugins from the above glusterfs fork are not
included in this PR. Those will be sent as separate PRs with
tests.

Every plugin should implement the following Struct

```c
struct glusterd_snap_ops {
    /* Name of the Plugin */
    const char *name;

    /* To check if a plugin is supported or not */
    gf_boolean_t (*const probe)(
        char *brick_path
    );

    /* To get usage details */
    int (*const details)(
        dict_t *rsp_dict,
        glusterd_brickinfo_t *snap_brickinfo,
        char *key_prefix
    );

    /* Create the Snapshot */
    int32_t (*const create)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Create a Clone */
    int32_t (*const clone)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        char *clonename,
        char *clone_volume_id,
        int32_t brick_num
    );

    /* Remove a Snapshot */
    int32_t (*const remove)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Activate and Mount a Snapshot */
    int32_t (*const activate)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Unmount and Deactivate a Snapshot */
    int32_t (*const deactivate)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Restore a Snapshot */
    int32_t (*const restore)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num,
        gf_boolean_t *retain_origin_path
    );

    /* Brick Path of a Snapshot/Clone */
    int32_t (*const brick_path)(
        char *snap_mount_dir,
        int clone,
        char *snap_clone_name,
        char *snap_clone_volume_id,
        char *snap_brick_dir,
        int brick_num,
        char **snap_brick_path
    );
};
```

When a Snapshot is activated, Glusterd tries to set the new `volume-id`
xattr to the Snapshot brick root. But if the Snapshot is readonly then
this is not possible(For example, ZFS). Skip setting `volume-id`
xattr for Snapshot bricks and allow mounting Snapshot Volume with
parent Volume ID itself. Set xattr only while taking Clones.

Unavailability of dict keys are already handled and respective
output is shown in the CLI snap status command. Logging is not useful
here, changed log level to DEBUG.

* snapshots: Disable posix health check for Snapshot bricks

Backend Snapshots may be readonly, enabling health check will
terminate the Snapshot bricks.

* snapshots: Fix crash during pending snap unmount after restart

* snapshots: Fix Snapshot delete handling and empty mountdir

* snapshots: Fix the issue while recreating the snap brick mounts

During restore, if the Snapshot was not activated then it was
failing to find the brick directory and failing to restore.

With this PR, if the brick directory is not found it triggers
Snap brick activation.

* snapshots: Avoid running Probe multiple times

Save the Snapshot plugin name in Snap Volume info. Use that
to fetch the Plugin struct when required.

* snapshots: Fix the issue while copying volinfo to new node

`snap_plugin` key was not copied to the Volinfo of new node. Due
to this checksum was failing after peer probe and ends in Peer Rejected
state.

* snapshots: Fix duplicate code block

* snapshots: Fix issue while importing Snapshot data

If any Snapshot operations like deactivate is performed when
a peer is down then once that peer comes back online, it imports
the changes from other peers. Snap plugin key was not imported and
Glusterd fails to start.

* snapshots: Save Snapshot Volume ID and Snapshot name in the restored volume

During Glusterd restart, it tries to mount the Restored
Volume/Clone/Snapshot if it is in started state or if any
Snapshot is in activated state.

Restored Volume fails to find the Snapshot name from which it was
restored. This PR adds snapshot volume_id and snapshot name to
the volume info of restored volume.

* snapshots: Fix the workdir cleanup after Snapshot delete
* snapshots: Disable Changelog xlator while starting Snapshot brick
* snapshots: Add origin_path field to imported snap brickinfo

On Glusterd reboot, origin_path was missing in the imported
snap brickinfo.

Change-Id: I3c8b8b0801d8b6f03362494e2ccf672e569071db
Updates: #145
Signed-off-by: Sriram Raghunathan <sriram@marirs.net.in>
Signed-off-by: Mark Ferrell <major@homeonderanged.org>
Signed-off-by: Aravinda Vishwanathapura <aravinda@kadalu.io>
2021-12-17 09:52:20 +05:30
Yaniv Kaul
637d54e0ca multiple files: remove the stub pool
It's unused since I've removed its usage in commit 11b7266 - call-stub: remove unused fields (#2055)

Fixes: #2964
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2021-11-23 09:17:46 +01:00
Yaniv Kaul
67fed04465 Multiple files: use regular endian conversion instead of our own. (#2868)
Instead of using our own implementation, let's use the platform's endian conversion routines.
For example, be32toh() instead of ntoh32().

Fixes: #2735
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2021-11-12 11:24:03 +01:00
Aravinda Vishwanathapura
2637974ace cli: Fix wrong value of inodeSize in volume status xml output
Fs type was added to inodeSize xml output. Now it is fixed
by adding the actual variable.

Fixes: #2936
Change-Id: Iaa285cb2a7dbf77d7a2cf1e2636e4285d2257124
Signed-off-by: Aravinda Vishwanathapura <aravinda@kadalu.io>
2021-11-12 09:54:04 +01:00
Dmitry Antipov
d23881073f cli: move RPC call timeouts to state data (#2813)
Move default and special RPC call timeouts to 'struct cli_state',
provide meaningful macros and adjust related bits here and there.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-10-27 12:44:52 +05:30
XiJinyu
0f2b25ccd4 nit: the "data" was used twice. (#2858)
dict_t *dict = data;
dict = data;

Change-Id: I578ce05dd5a18b62eac6632778e94044c028951b
Updates: #2857
Signed-off-by: Xi Jinyu <xijinyu_yewu@cmss.chinamobile.com>
2021-10-11 23:14:41 +05:30
Dmitry Antipov
b48e64cebc cli: drop global RPC client contexts (#2767)
Embed glusterd and quotad RPC client context pointers
into CLI state instead of using global variables, adjust
related initialization functions and comments.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-09-22 16:04:10 +05:30
Dmitry Antipov
db36432eec cli: fix a few memory use-after-free and leak errors (#2737)
Fix a few use-after-free error detected by ASan, for example:

==1089284==ERROR: AddressSanitizer: heap-use-after-free on address ...

WRITE of size 8 at 0x61100001ffd0 thread T2
    #0 0x7fa6ab385633 in dict_unref libglusterfs/src/dict.c:798
    #1 0x41664a in cli_cmd_volume_stop_cbk cli/src/cli-cmd-volume.c:564
    #2 0x40f2d6 in cli_cmd_process cli/src/cli-cmd.c:133
    #3 0x40e772 in cli_batch cli/src/input.c:29
    #4 0x7fa6aae3e298 in start_thread (/lib64/libpthread.so.0+0x9298)
    #5 0x7fa6aaa78352 in clone (/lib64/libc.so.6+0x100352)

0x61100001ffd0 is located 80 bytes inside of 224-byte region ...
freed by thread T2 here:
    #0 0x7fa6ab732647 in free (/lib64/libasan.so.6+0xae647)
    #1 0x7fa6ab43171a in __gf_free libglusterfs/src/mem-pool.c:362
    #2 0x7fa6ab38559b in dict_destroy libglusterfs/src/dict.c:782
    #3 0x7fa6ab38565e in dict_unref libglusterfs/src/dict.c:801
    #4 0x40cd28 in cli_local_wipe cli/src/cli.c:783
    #5 0x4165c4 in cli_cmd_volume_stop_cbk cli/src/cli-cmd-volume.c:562
    #6 0x40f2d6 in cli_cmd_process cli/src/cli-cmd.c:133
    #7 0x40e772 in cli_batch cli/src/input.c:29
    #8 0x7fa6aae3e298 in start_thread (/lib64/libpthread.so.0+0x9298)

previously allocated by thread T2 here:
    #0 0x7fa6ab732af7 in calloc (/lib64/libasan.so.6+0xaeaf7)
    #1 0x7fa6ab430a91 in __gf_calloc libglusterfs/src/mem-pool.c:151
    #2 0x7fa6ab382562 in get_new_dict_full libglusterfs/src/dict.c:84
    #3 0x7fa6ab38268d in dict_new libglusterfs/src/dict.c:127
    #4 0x415fcf in cli_cmd_volume_stop_cbk cli/src/cli-cmd-volume.c:501
    #5 0x40f2d6 in cli_cmd_process cli/src/cli-cmd.c:133
    #6 0x40e772 in cli_batch cli/src/input.c:29
    #7 0x7fa6aae3e298 in start_thread (/lib64/libpthread.so.0+0x9298)

Thread T2 created by T0 here:
    #0 0x7fa6ab6da8d6 in pthread_create (/lib64/libasan.so.6+0x568d6)
    #1 0x40eb2b in cli_input_init cli/src/input.c:76
    #2 0x40d0ee in main cli/src/cli.c:863
    #3 0x7fa6aa99fb74 in __libc_start_main (/lib64/libc.so.6+0x27b74)

Also tweak CLI_LOCAL_INIT() to take an extra reference to related
'dict_t' object and ensure correct reference counting sequence for
the most of CLI commands, which should follow the scheme below:

int
cli_cmd_xxx(...)
{
    int ret = -1;
    dict_t *options = NULL;
    ...
    ret = cli_cmd_xxx_parse(..., &options);      /* refcount 1 */
    if (!ret)
        goto out;
    ...
    CLI_LOCAL_INIT(..., options);                /* refcount 2 */
    ...
    ret = proc->fn(..., options);
    ...
out:
    CLI_STACK_DESTROY(...);                      /* refcount 1 */
    if (options)
       dict_unref(options);         /* freed due to refcount 0 */
    return ret;
}

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-09-14 11:55:59 +05:30
mohit84
2936241ea9 Revert "libglusterfs: drop core infrastructure of memory pools (#2675)" (#2777)
In case of glibc_pool it is good to use glusterfs mempool so revert
the commit 9cd6735ff5.

Change-Id: I780f0a1b7dae815becfd8c072735b6fdecb936f8
Updates: #1000
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
2021-09-10 07:26:04 +05:30
Tamar Shacked
76fb94f505 cli: fix coverity issue (#2766)
fixing null dereference reported by coverity

CID: 1462029
Updates: #1060

Change-Id: I2c42a677b02ea23da4d18d4c662a020f40081e03
Signed-off-by: Tamar Shacked <tshacked@redhat.com>
2021-09-09 17:35:13 +03:00
Dmitry Antipov
77b9bf1034 cli: drop global state variable (#2753)
Drop 'global_state' and pass CLI state as a parameter
or indirectly via call frame or THIS where appropriate.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-09-04 13:11:35 +05:30
Dmitry Antipov
368d5b5891 glusterd, cli: more time_t usage where appropriate (#2749)
More time_t values for time intervals and timeouts,
drop weird is_valid_int() since strtol() is capable
enough to handle errors, adjust relevant comments.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-09-04 13:08:58 +05:30
Dmitry Antipov
9cd6735ff5 libglusterfs: drop core infrastructure of memory pools (#2675)
Separate memory allocation type tracking from core infrastructure of
memory pools and drop the latter alongside with '--disable-mempool'
configuration option, provide '--disable-allocation-tracking' to control
the former instead.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-09-04 12:02:48 +05:30
Dmitry Antipov
21f1d246a9 build: use pkg-config to check whether readline is available
Use convenient PKG_CHECK_MODULES macro to check whether readline
library is present, drop specific check for rl_do_undo() since
it is available since ancient readiline 2.0 or maybe even older.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-09-02 14:08:27 +02:00
Dmitry Antipov
35039253ba libglusterfs, cli, rpc, xlators: consistently use time_t (#2710)
Tweak dict and xlator interfaces to allow explicit values of 'time_t' type
and consistently use it for timeouts, time intervals, and whatever similar.
Adjust related tests to prefer 0 over -1 for disabled timeouts.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-08-30 17:10:20 +05:30
Dmitry Antipov
bcf09403ed cli: do not allow to use help as the volume name (#2721)
Add 'help' to the list of unacceptable volume names because using
it as such silently confuses the most of CLI commands, for example:

$ gluster volume info

Volume Name: abcd
Type: Replicate
Volume ID: db862536-61da-404b-98c9-b5450eb1f80d
Status: Created
Snapshot Count: 0
Number of Bricks: 1 x 3 = 3
Transport-type: tcp
Bricks:
Brick1: 192.168.222.110:/home/pool/3
Brick2: 192.168.222.110:/home/pool/4
Brick3: 192.168.222.110:/home/pool/5
Options Reconfigured:
cluster.granular-entry-heal: on
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off

Volume Name: help
Type: Replicate
Volume ID: 10442b69-18fa-4ad8-8dc9-3867c0598523
Status: Created
Snapshot Count: 0
Number of Bricks: 1 x 3 = 3
Transport-type: tcp
Bricks:
Brick1: 192.168.222.110:/home/pool/0
Brick2: 192.168.222.110:/home/pool/1
Brick3: 192.168.222.110:/home/pool/2
Options Reconfigured:
cluster.granular-entry-heal: on
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off

$ gluster volume set abcd performance.cache-size 256MB

volume set: success

$ gluster volume set help performance.cache-size 256MB
volume set: failed

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-08-20 19:23:52 +05:30
Dmitry Antipov
329491acae xlators, cli: prefer timespec over timeval (#2458)
Prefer timespec_now_realtime() over gettimeofday() to simplify and
avoid extra multiply by 1000.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
2021-05-23 06:47:18 +05:30
Dmitry Antipov
9c7e6594ae libglusterfs: prefer mallinfo2() to mallinfo() if available
Since glibc 2.33, mallinfo() is marked obsolete due to the limited
range of 'int' type used in 'struct mallinfo', and new 'size_t'-based
counterpart 'struct mallinfo2' with corresponding function mallinfo2()
should be preferred instead. To avoid compatibility mess, it's also
reasonable to use 'uint64_t' values for storing and operating with
mallinfo data internally, as suggested by Xavi Hernandez.

Fixes: #2414
Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2021-05-14 11:20:51 +02:00
nik-redhat
e210d5c61a cli-line-coverage: Added test for negative case, removed stale code
Fix:
Added new .t file for increasing the line,function coverage
in cli component, and removed/commented out stale code.

Updates: #1052

Change-Id: I0a3c12a12f18bee39824157129c1d0187f4030d4
Signed-off-by: nik-redhat <nladha@redhat.com>
2021-05-13 10:47:15 +02:00
Ayush Ujjwal
b4314878f9 Coverity : Use after free
CID: 1430111

Description:
The previous condition `if(tmp)` was freeing  `tmp` always.
Hence,  replaced the condition with a new condition which checks if `rv >= 0`.

Updates: #1060

Change-Id: I0ebe18d1978b73b577ded259915b7305a58253ff
Signed-off-by: Ayush Ujjwal <aujjwal@redhat.com>
2021-05-06 11:55:51 +02:00
Karthik Subrahmanya
803d53103f cluster/afr: Code coverage improvement for afr-self-heald.c & cli-rpc-ops.c (#2366)
Problem 1:
The code to handle the volume heal split-brain was there in both
glfs-heal.c and afr-self-heald.c. The code path in the later file
was never hit since it will always be handled by self-heal.c.

Fix:
Removed the code to handle heal info split-brain request from
afr-self-heald.c and cli-rpc-ops.c files.

Problem 2:
The volume heal statistics was never called in any of the test cases.

Fix:
Calling volume heal statistics in afr-heal-info.t which will increase
the code coverage of both afr-self-heald.c an cli-rpc-ops.c.

Change-Id: I242ef088bb2da9c8d9a200986514758cb0f08b37
Signed-off-by: karthik-us <ksubrahm@redhat.com>
Updates: #1000
2021-05-03 16:34:44 +05:30
Nikhil Ladha
4336edecaf cli: Increased spacing in cli for option table (#2322)
* cli: Increased spacing in cli for option table

Issue:
Some options have name larger than length 40,
due to which the output of command `gluster vol get <volname> all`
mixes up the option, value for long option names.

Fix:
Increased the spacing in cli for `gluster vol get <volname> all`
output to 50.

Fixes: #2313

Change-Id: I841730ced074547a81171a4432d15ec9c35f39cd
Signed-off-by: nik-redhat <nladha@redhat.com>

* Added separator

Change-Id: I210877c89bc468ed6a3090cd14fde7ecee1d33b6
Signed-off-by: nik-redhat <nladha@redhat.com>

* Removed separator and added space

Change-Id: Ic0eb9c9bc39a354465aabd939f72bc65be738f6c
Signed-off-by: nik-redhat <nladha@redhat.com>
2021-04-13 17:55:12 +05:30
nishith-vihar
5fd3d4175f Removal of force option in snapshot create (#2110)
The force option does fail for snapshot create command even though
the quorum is satisfied and is redundant.

The change deprecates the force option for snapshot create command
and checks if all bricks are online instead of checking for quorum
for creating a snapshot.

Fixes: #2099
Change-Id: I45d866e67052fef982a60aebe8dec069e78015bd
Signed-off-by: Nishith Vihar Sakinala <nsakinal@redhat.com>
2021-04-06 16:10:50 +02:00
Pranith Kumar Karampuri
ec189a499d cluster/dht: use readdir for fix-layout in rebalance (#2243)
Problem:
On a cluster with 15 million files, when fix-layout was started, it was
not progressing at all. So we tried to do a os.walk() + os.stat() on the
backend filesystem directly. It took 2.5 days. We removed os.stat() and
re-ran it on another brick with similar data-set. It took 15 minutes. We
realized that readdirp is extremely costly compared to readdir if the
stat is not useful. fix-layout operation only needs to know that the
entry is a directory so that fix-layout operation can be triggered on
it. Most of the modern filesystems provide this information in readdir
operation. We don't need readdirp i.e. readdir+stat.

Fix:
Use readdir operation in fix-layout. Do readdir+stat/lookup for
filesystems that don't provide d_type in readdir operation.

fixes: #2241
Change-Id: I5fe2ecea25a399ad58e31a2e322caf69fc7f49eb
Signed-off-by: Pranith Kumar K <pranith.karampuri@phonepe.com>
2021-03-22 10:19:27 +05:30
Ravishankar N
f41f7dec05 cli: syntax check for arbiter volume creation (#2207)
commit 8e7bfd6a58 changed the syntax for
arbiter volume creation to 'replica 2 arbiter 1', while still allowing
the old syntax of 'replica 3 arbiter 1'. But while doing so, it also
removed a conditional check, thereby allowing replica count > 3. This
patch fixes it.

Fixes: #2192
Change-Id: Ie109325adb6d78e287e658fd5f59c26ad002e2d3
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
2021-03-05 11:54:46 +05:30
Ryo Furuhashi
ea86b664f3 glusterd-volgen: Add functionality to accept any custom xlator (#1974)
* glusterd-volgen: Add functionality to accept any custom xlator

Add new function which allow users to insert any custom xlators.
It makes to provide a way to add any processing into file operations.

Users can deploy the plugin(xlator shared object) and integrate it to glusterfsd.

If users want to enable a custom xlator, do the follows:

1. put xlator object(.so file) into "XLATOR_DIR/user/"
2. set the option user.xlator.<xlator> to the existing xlator-name to specify of the position in graph
3. restart gluster volume

Options for custom xlator are able to set in "user.xlator.<xlator>.<optkey>".

Fixes: #1943
Signed-off-by:Ryo Furuhashi <ryo.furuhashi.nh@hitachi.com>
Co-authored-by: Yaniv Kaul <ykaul@redhat.com>
Co-authored-by: Xavi Hernandez <xhernandez@users.noreply.github.com>
2021-02-05 09:26:03 +05:30
mohit84
90f18d12f5 tests: ./tests/bugs/replicate/bug-921231.t is continuously failing (#2006)
The test case (./tests/bugs/replicate/bug-921231.t )
is continuously failing.The test case is failing because
inodelk_max_latency is showing wrong value in profile.
The value is not correct because recently the profile
timestamp is changed from microsec to nanosec from
the patch #1833.

Fixes: #2005
Change-Id: Ieb683836938d986b56f70b2380103efe95657821
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
2021-01-13 17:58:28 +05:30
Sheetal Pamecha
1d74669ab9 stripe cleanup: Remove the option from create and add-brick cmds (#1812)
* stripe cleanup: Remove the option from create and add-brick cmds

This patch aims to remove the code for stripe option instead
of keeping a default values of stripe/stripe-count variables and
setting and getting dict options and similar redundant operations.
Also removing tests for stripe volumes that have been already
marked bad.

Updates: #1000
Change-Id: Ic2b3cabd671f0c8dc0521384b164c3078f7ca7c6
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>

* Fix regression error

tests/000-flaky/basic_changelog_changelog-snapshot.t
was failing due to 0 return value

Change-Id: I8ea0443669c63768760526db5aa1f205978e1dbb
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>

* add constant stripe_count value for upgrade scenerios

Change-Id: I49f3da4f106c55f9da20d0b0a299275a19daf4ba

* Fix clang-format warning

Change-Id: I83bae85d10c8c5b3c66f56c9f8de1ec81d0bbc95
2021-01-05 20:00:32 +05:30
Mohammed Ashour
bba4e92de9 Fixing the split-brain link where going for a 2 replicated volume. (#1964)
Fixes in functions:
	- cli_cmd_volume_create_parse()
	- cli_cmd_volume_add_brick_parse()
	- cli_cmd_volume_remove_brick_parse()

Fixes: #1959
Signed-off-by: Mohammed Ali Ashour <m.aly.ashour@gmail.com>
2020-12-31 09:45:47 +05:30
Ravishankar N
aa29aaf1c9 cli/glusterd: conscious language changes for geo-rep
Replace master and slave terminology in geo-replication with primary and
secondary respectively.

All instances are replaced in cli and glusterd.

Changes to other parts of the code to follow in separate patches.
tests/00-geo-rep/* are passing thus far.

Updates: #1415
Change-Id: Ifb12b7f5ce927a4a61bda1e953c1eb0fdfc8a7c5
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
2020-12-30 15:55:22 +05:30