summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorSheetal Pamecha <sheetal.pamecha08@gmail.com>2018-11-19 22:15:25 +0530
committerAmar Tumballi <amarts@redhat.com>2019-06-03 02:59:17 +0000
commit950726dfc8e3171bef625b563c0c6dbba1ec2928 (patch)
tree9f29ddeaa3d93984ffcc0f6620779e0ee8418512 /xlators/storage/posix/src/posix-helpers.c
parent6fd8281ac9af58609979f660ece58c2ed1100e72 (diff)
posix: add storage.reserve-size option
storage.reserve-size option will take size as input instead of percentage. If set, priority will be given to storage.reserve-size over storage.reserve. Default value of this option is 0. fixes: bz#1651445 Change-Id: I7a7342c68e436e8bf65bd39c567512ee04abbcea Signed-off-by: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 80f5fb8..7296f69 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -2265,6 +2265,7 @@ posix_disk_space_check(xlator_t *this)
struct posix_private *priv = NULL;
char *subvol_path = NULL;
int op_ret = 0;
+ uint64_t size = 0;
int percent = 0;
struct statvfs buf = {0};
uint64_t totsz = 0;
@@ -2275,7 +2276,14 @@ posix_disk_space_check(xlator_t *this)
GF_VALIDATE_OR_GOTO(this->name, priv, out);
subvol_path = priv->base_path;
- percent = priv->disk_reserve;
+
+ if (priv->disk_reserve_size) {
+ size = priv->disk_reserve_size;
+ } else {
+ percent = priv->disk_reserve_percent;
+ totsz = (buf.f_blocks * buf.f_bsize);
+ size = ((totsz * percent) / 100);
+ }
op_ret = sys_statvfs(subvol_path, &buf);
@@ -2284,10 +2292,9 @@ posix_disk_space_check(xlator_t *this)
"statvfs failed on %s", subvol_path);
goto out;
}
- totsz = (buf.f_blocks * buf.f_bsize);
freesz = (buf.f_bfree * buf.f_bsize);
- if (freesz <= ((totsz * percent) / 100)) {
+ if (freesz <= size) {
priv->disk_space_full = 1;
} else {
priv->disk_space_full = 0;