summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorSheetal Pamecha <spamecha@redhat.com>2019-06-19 15:08:58 +0530
committerAmar Tumballi <amarts@redhat.com>2019-06-26 14:07:48 +0000
commit5cbc87d8b8f1287e81c38b793b8d13b057208c62 (patch)
treeae6599a14a1ae78367bfcbc89faec695b5442a97 /xlators/storage/posix/src/posix-helpers.c
parent1716a907da1a835b658740f1325033d7ddd44952 (diff)
posix: modify storage.reserve option to take size and percent
* reverting changes made in https://review.gluster.org/#/c/glusterfs/+/21686/ * Now storage.reserve can take value in percent or bytes fixes: bz#1651445 Change-Id: Id4826210ec27991c55b17d1fecd90356bff3e036 Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index a0c273fa772..5fa73bff7cd 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -2257,11 +2257,11 @@ 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;
+ double size = 0;
+ double percent = 0;
struct statvfs buf = {0};
- uint64_t totsz = 0;
- uint64_t freesz = 0;
+ double totsz = 0;
+ double freesz = 0;
GF_VALIDATE_OR_GOTO(this->name, this, out);
priv = this->private;
@@ -2269,14 +2269,6 @@ posix_disk_space_check(xlator_t *this)
subvol_path = priv->base_path;
- 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);
if (op_ret == -1) {
@@ -2284,8 +2276,16 @@ posix_disk_space_check(xlator_t *this)
"statvfs failed on %s", subvol_path);
goto out;
}
- freesz = (buf.f_bfree * buf.f_bsize);
+ if (priv->disk_unit == 'p') {
+ percent = priv->disk_reserve;
+ totsz = (buf.f_blocks * buf.f_bsize);
+ size = ((totsz * percent) / 100);
+ } else {
+ size = priv->disk_reserve;
+ }
+
+ freesz = (buf.f_bfree * buf.f_bsize);
if (freesz <= size) {
priv->disk_space_full = 1;
} else {