|
|
50dc83 |
From 4d82c7879387e6f7963b4d9c84c4ff8a1788055d Mon Sep 17 00:00:00 2001
|
|
|
50dc83 |
From: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
|
|
|
50dc83 |
Date: Mon, 19 Nov 2018 22:15:25 +0530
|
|
|
50dc83 |
Subject: [PATCH 171/178] posix: add storage.reserve-size option
|
|
|
50dc83 |
|
|
|
50dc83 |
storage.reserve-size option will take size as input
|
|
|
50dc83 |
instead of percentage. If set, priority will be given to
|
|
|
50dc83 |
storage.reserve-size over storage.reserve. Default value
|
|
|
50dc83 |
of this option is 0.
|
|
|
50dc83 |
|
|
|
50dc83 |
> fixes: bz#1651445
|
|
|
50dc83 |
> Change-Id: I7a7342c68e436e8bf65bd39c567512ee04abbcea
|
|
|
50dc83 |
> Signed-off-by: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
|
|
|
50dc83 |
> Cherry pick from commit 950726dfc8e3171bef625b563c0c6dbba1ec2928
|
|
|
50dc83 |
> Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/21686/
|
|
|
50dc83 |
|
|
|
50dc83 |
BUG: 1573077
|
|
|
50dc83 |
Change-Id: I7a7342c68e436e8bf65bd39c567512ee04abbcea
|
|
|
50dc83 |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
50dc83 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/172709
|
|
|
50dc83 |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
50dc83 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
50dc83 |
---
|
|
|
50dc83 |
tests/bugs/posix/bug-1651445.t | 58 +++++++++++++++++++++++++
|
|
|
50dc83 |
xlators/mgmt/glusterd/src/glusterd-volume-set.c | 33 ++++++++++++++
|
|
|
50dc83 |
xlators/storage/posix/src/posix-common.c | 34 ++++++++++++---
|
|
|
50dc83 |
xlators/storage/posix/src/posix-helpers.c | 13 ++++--
|
|
|
50dc83 |
xlators/storage/posix/src/posix-inode-fd-ops.c | 10 +++--
|
|
|
50dc83 |
xlators/storage/posix/src/posix.h | 3 +-
|
|
|
50dc83 |
6 files changed, 138 insertions(+), 13 deletions(-)
|
|
|
50dc83 |
create mode 100644 tests/bugs/posix/bug-1651445.t
|
|
|
50dc83 |
|
|
|
50dc83 |
diff --git a/tests/bugs/posix/bug-1651445.t b/tests/bugs/posix/bug-1651445.t
|
|
|
50dc83 |
new file mode 100644
|
|
|
50dc83 |
index 0000000..f6f1833
|
|
|
50dc83 |
--- /dev/null
|
|
|
50dc83 |
+++ b/tests/bugs/posix/bug-1651445.t
|
|
|
50dc83 |
@@ -0,0 +1,58 @@
|
|
|
50dc83 |
+#!/bin/bash
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+. $(dirname $0)/../../include.rc
|
|
|
50dc83 |
+. $(dirname $0)/../../volume.rc
|
|
|
50dc83 |
+. $(dirname $0)/../../snapshot.rc
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+cleanup
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+TEST verify_lvm_version
|
|
|
50dc83 |
+TEST glusterd
|
|
|
50dc83 |
+TEST pidof glusterd
|
|
|
50dc83 |
+TEST init_n_bricks 3
|
|
|
50dc83 |
+TEST setup_lvm 3
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+TEST $CLI volume create $V0 replica 3 $H0:$L{1,2,3}
|
|
|
50dc83 |
+TEST $CLI volume start $V0
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+TEST $CLI volume set $V0 storage.reserve-size 10MB
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+#No effect as priority to reserve-size
|
|
|
50dc83 |
+TEST $CLI volume set $V0 storage.reserve 20
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+TEST dd if=/dev/zero of=$M0/a bs=100M count=1
|
|
|
50dc83 |
+sleep 5
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+#Below dd confirms posix is giving priority to reserve-size
|
|
|
50dc83 |
+TEST dd if=/dev/zero of=$M0/b bs=40M count=1
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+sleep 5
|
|
|
50dc83 |
+TEST ! dd if=/dev/zero of=$M0/c bs=5M count=1
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+rm -rf $M0/*
|
|
|
50dc83 |
+#Size will reserve from the previously set reserve option = 20%
|
|
|
50dc83 |
+TEST $CLI volume set $V0 storage.reserve-size 0
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+#Overwrite reserve option
|
|
|
50dc83 |
+TEST $CLI volume set $V0 storage.reserve-size 40MB
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+#wait 5s to reset disk_space_full flag
|
|
|
50dc83 |
+sleep 5
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+TEST dd if=/dev/zero of=$M0/a bs=100M count=1
|
|
|
50dc83 |
+TEST dd if=/dev/zero of=$M0/b bs=10M count=1
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+# Wait 5s to update disk_space_full flag because thread check disk space
|
|
|
50dc83 |
+# after every 5s
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+sleep 5
|
|
|
50dc83 |
+# setup_lvm create lvm partition of 150M and 40M are reserve so after
|
|
|
50dc83 |
+# consuming more than 110M next dd should fail
|
|
|
50dc83 |
+TEST ! dd if=/dev/zero of=$M0/c bs=5M count=1
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+TEST $CLI volume stop $V0
|
|
|
50dc83 |
+TEST $CLI volume delete $V0
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+cleanup
|
|
|
50dc83 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
50dc83 |
index 7a83124..3a7ab83 100644
|
|
|
50dc83 |
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
50dc83 |
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
50dc83 |
@@ -1231,6 +1231,30 @@ out:
|
|
|
50dc83 |
|
|
|
50dc83 |
return ret;
|
|
|
50dc83 |
}
|
|
|
50dc83 |
+static int
|
|
|
50dc83 |
+validate_size(glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value,
|
|
|
50dc83 |
+ char **op_errstr)
|
|
|
50dc83 |
+{
|
|
|
50dc83 |
+ xlator_t *this = NULL;
|
|
|
50dc83 |
+ uint64_t size = 0;
|
|
|
50dc83 |
+ int ret = -1;
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+ this = THIS;
|
|
|
50dc83 |
+ GF_VALIDATE_OR_GOTO("glusterd", this, out);
|
|
|
50dc83 |
+ ret = gf_string2bytesize_uint64(value, &size);
|
|
|
50dc83 |
+ if (ret < 0) {
|
|
|
50dc83 |
+ gf_asprintf(op_errstr,
|
|
|
50dc83 |
+ "%s is not a valid size. %s "
|
|
|
50dc83 |
+ "expects a valid value in bytes",
|
|
|
50dc83 |
+ value, key);
|
|
|
50dc83 |
+ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_INVALID_ENTRY, "%s",
|
|
|
50dc83 |
+ *op_errstr);
|
|
|
50dc83 |
+ }
|
|
|
50dc83 |
+out:
|
|
|
50dc83 |
+ gf_msg_debug("glusterd", 0, "Returning %d", ret);
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+ return ret;
|
|
|
50dc83 |
+}
|
|
|
50dc83 |
|
|
|
50dc83 |
/* dispatch table for VOLUME SET
|
|
|
50dc83 |
* -----------------------------
|
|
|
50dc83 |
@@ -2830,6 +2854,15 @@ struct volopt_map_entry glusterd_volopt_map[] = {
|
|
|
50dc83 |
.op_version = GD_OP_VERSION_3_13_0,
|
|
|
50dc83 |
},
|
|
|
50dc83 |
{
|
|
|
50dc83 |
+ .key = "storage.reserve-size",
|
|
|
50dc83 |
+ .voltype = "storage/posix",
|
|
|
50dc83 |
+ .value = "0",
|
|
|
50dc83 |
+ .validate_fn = validate_size,
|
|
|
50dc83 |
+ .description = "If set, priority will be given to "
|
|
|
50dc83 |
+ "storage.reserve-size over storage.reserve",
|
|
|
50dc83 |
+ .op_version = GD_OP_VERSION_7_0,
|
|
|
50dc83 |
+ },
|
|
|
50dc83 |
+ {
|
|
|
50dc83 |
.option = "health-check-timeout",
|
|
|
50dc83 |
.key = "storage.health-check-timeout",
|
|
|
50dc83 |
.type = NO_DOC,
|
|
|
50dc83 |
diff --git a/xlators/storage/posix/src/posix-common.c b/xlators/storage/posix/src/posix-common.c
|
|
|
50dc83 |
index ed82e35..0f70af5 100644
|
|
|
50dc83 |
--- a/xlators/storage/posix/src/posix-common.c
|
|
|
50dc83 |
+++ b/xlators/storage/posix/src/posix-common.c
|
|
|
50dc83 |
@@ -345,11 +345,18 @@ posix_reconfigure(xlator_t *this, dict_t *options)
|
|
|
50dc83 |
" fallback to <hostname>:<export>");
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
- GF_OPTION_RECONF("reserve", priv->disk_reserve, options, uint32, out);
|
|
|
50dc83 |
- if (priv->disk_reserve) {
|
|
|
50dc83 |
+ GF_OPTION_RECONF("reserve-size", priv->disk_reserve_size, options, size,
|
|
|
50dc83 |
+ out);
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+ GF_OPTION_RECONF("reserve", priv->disk_reserve_percent, options, uint32,
|
|
|
50dc83 |
+ out);
|
|
|
50dc83 |
+ if (priv->disk_reserve_size || priv->disk_reserve_percent) {
|
|
|
50dc83 |
ret = posix_spawn_disk_space_check_thread(this);
|
|
|
50dc83 |
- if (ret)
|
|
|
50dc83 |
+ if (ret) {
|
|
|
50dc83 |
+ gf_msg(this->name, GF_LOG_INFO, 0, P_MSG_DISK_SPACE_CHECK_FAILED,
|
|
|
50dc83 |
+ "Getting disk space check from thread failed");
|
|
|
50dc83 |
goto out;
|
|
|
50dc83 |
+ }
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
GF_OPTION_RECONF("health-check-interval", priv->health_check_interval,
|
|
|
50dc83 |
@@ -968,11 +975,17 @@ posix_init(xlator_t *this)
|
|
|
50dc83 |
|
|
|
50dc83 |
_private->disk_space_check_active = _gf_false;
|
|
|
50dc83 |
_private->disk_space_full = 0;
|
|
|
50dc83 |
- GF_OPTION_INIT("reserve", _private->disk_reserve, uint32, out);
|
|
|
50dc83 |
- if (_private->disk_reserve) {
|
|
|
50dc83 |
+ GF_OPTION_INIT("reserve-size", _private->disk_reserve_size, size, out);
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+ GF_OPTION_INIT("reserve", _private->disk_reserve_percent, uint32, out);
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+ if (_private->disk_reserve_size || _private->disk_reserve_percent) {
|
|
|
50dc83 |
ret = posix_spawn_disk_space_check_thread(this);
|
|
|
50dc83 |
- if (ret)
|
|
|
50dc83 |
+ if (ret) {
|
|
|
50dc83 |
+ gf_msg(this->name, GF_LOG_INFO, 0, P_MSG_DISK_SPACE_CHECK_FAILED,
|
|
|
50dc83 |
+ "Getting disk space check from thread failed ");
|
|
|
50dc83 |
goto out;
|
|
|
50dc83 |
+ }
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
_private->health_check_active = _gf_false;
|
|
|
50dc83 |
@@ -1216,6 +1229,15 @@ struct volume_options posix_options[] = {
|
|
|
50dc83 |
" Set to 0 to disable",
|
|
|
50dc83 |
.op_version = {GD_OP_VERSION_3_13_0},
|
|
|
50dc83 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
|
|
|
50dc83 |
+ {.key = {"reserve-size"},
|
|
|
50dc83 |
+ .type = GF_OPTION_TYPE_SIZET,
|
|
|
50dc83 |
+ .min = 0,
|
|
|
50dc83 |
+ .default_value = "0",
|
|
|
50dc83 |
+ .validate = GF_OPT_VALIDATE_MIN,
|
|
|
50dc83 |
+ .description = "size in megabytes to be reserved for disk space."
|
|
|
50dc83 |
+ " Set to 0 to disable",
|
|
|
50dc83 |
+ .op_version = {GD_OP_VERSION_7_0},
|
|
|
50dc83 |
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
|
|
|
50dc83 |
{.key = {"batch-fsync-mode"},
|
|
|
50dc83 |
.type = GF_OPTION_TYPE_STR,
|
|
|
50dc83 |
.default_value = "reverse-fsync",
|
|
|
50dc83 |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
50dc83 |
index d0fd45a..aecf4f8 100644
|
|
|
50dc83 |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
50dc83 |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
50dc83 |
@@ -2246,6 +2246,7 @@ posix_disk_space_check(xlator_t *this)
|
|
|
50dc83 |
struct posix_private *priv = NULL;
|
|
|
50dc83 |
char *subvol_path = NULL;
|
|
|
50dc83 |
int op_ret = 0;
|
|
|
50dc83 |
+ uint64_t size = 0;
|
|
|
50dc83 |
int percent = 0;
|
|
|
50dc83 |
struct statvfs buf = {0};
|
|
|
50dc83 |
uint64_t totsz = 0;
|
|
|
50dc83 |
@@ -2256,7 +2257,14 @@ posix_disk_space_check(xlator_t *this)
|
|
|
50dc83 |
GF_VALIDATE_OR_GOTO(this->name, priv, out);
|
|
|
50dc83 |
|
|
|
50dc83 |
subvol_path = priv->base_path;
|
|
|
50dc83 |
- percent = priv->disk_reserve;
|
|
|
50dc83 |
+
|
|
|
50dc83 |
+ if (priv->disk_reserve_size) {
|
|
|
50dc83 |
+ size = priv->disk_reserve_size;
|
|
|
50dc83 |
+ } else {
|
|
|
50dc83 |
+ percent = priv->disk_reserve_percent;
|
|
|
50dc83 |
+ totsz = (buf.f_blocks * buf.f_bsize);
|
|
|
50dc83 |
+ size = ((totsz * percent) / 100);
|
|
|
50dc83 |
+ }
|
|
|
50dc83 |
|
|
|
50dc83 |
op_ret = sys_statvfs(subvol_path, &buf;;
|
|
|
50dc83 |
|
|
|
50dc83 |
@@ -2265,10 +2273,9 @@ posix_disk_space_check(xlator_t *this)
|
|
|
50dc83 |
"statvfs failed on %s", subvol_path);
|
|
|
50dc83 |
goto out;
|
|
|
50dc83 |
}
|
|
|
50dc83 |
- totsz = (buf.f_blocks * buf.f_bsize);
|
|
|
50dc83 |
freesz = (buf.f_bfree * buf.f_bsize);
|
|
|
50dc83 |
|
|
|
50dc83 |
- if (freesz <= ((totsz * percent) / 100)) {
|
|
|
50dc83 |
+ if (freesz <= size) {
|
|
|
50dc83 |
priv->disk_space_full = 1;
|
|
|
50dc83 |
} else {
|
|
|
50dc83 |
priv->disk_space_full = 0;
|
|
|
50dc83 |
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
50dc83 |
index 2c19ce1..7ca4d26 100644
|
|
|
50dc83 |
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
50dc83 |
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
50dc83 |
@@ -720,7 +720,7 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
|
|
|
50dc83 |
thread after every 5 sec sleep to working correctly storage.reserve
|
|
|
50dc83 |
option behaviour
|
|
|
50dc83 |
*/
|
|
|
50dc83 |
- if (priv->disk_reserve)
|
|
|
50dc83 |
+ if (priv->disk_reserve_size || priv->disk_reserve_percent)
|
|
|
50dc83 |
posix_disk_space_check(this);
|
|
|
50dc83 |
|
|
|
50dc83 |
DISK_SPACE_CHECK_AND_GOTO(frame, priv, xdata, ret, ret, out);
|
|
|
50dc83 |
@@ -2331,8 +2331,12 @@ posix_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
|
|
|
50dc83 |
goto out;
|
|
|
50dc83 |
}
|
|
|
50dc83 |
|
|
|
50dc83 |
- percent = priv->disk_reserve;
|
|
|
50dc83 |
- reserved_blocks = (buf.f_blocks * percent) / 100;
|
|
|
50dc83 |
+ if (priv->disk_reserve_size) {
|
|
|
50dc83 |
+ reserved_blocks = priv->disk_reserve_size / buf.f_bsize;
|
|
|
50dc83 |
+ } else {
|
|
|
50dc83 |
+ percent = priv->disk_reserve_percent;
|
|
|
50dc83 |
+ reserved_blocks = (buf.f_blocks * percent) / 100;
|
|
|
50dc83 |
+ }
|
|
|
50dc83 |
|
|
|
50dc83 |
if (buf.f_bfree > reserved_blocks) {
|
|
|
50dc83 |
buf.f_bfree = (buf.f_bfree - reserved_blocks);
|
|
|
50dc83 |
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
|
|
|
50dc83 |
index 1da4d01..4364b96 100644
|
|
|
50dc83 |
--- a/xlators/storage/posix/src/posix.h
|
|
|
50dc83 |
+++ b/xlators/storage/posix/src/posix.h
|
|
|
50dc83 |
@@ -225,7 +225,8 @@ struct posix_private {
|
|
|
50dc83 |
pthread_t health_check;
|
|
|
50dc83 |
gf_boolean_t health_check_active;
|
|
|
50dc83 |
|
|
|
50dc83 |
- uint32_t disk_reserve;
|
|
|
50dc83 |
+ uint32_t disk_reserve_percent;
|
|
|
50dc83 |
+ uint64_t disk_reserve_size;
|
|
|
50dc83 |
uint32_t disk_space_full;
|
|
|
50dc83 |
pthread_t disk_space_check;
|
|
|
50dc83 |
gf_boolean_t disk_space_check_active;
|
|
|
50dc83 |
--
|
|
|
50dc83 |
1.8.3.1
|
|
|
50dc83 |
|