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