summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-inode-fd-ops.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-inode-fd-ops.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-inode-fd-ops.c')
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index cf74327e1f5..09018165f91 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -719,7 +719,7 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
thread after every 5 sec sleep to working correctly storage.reserve
option behaviour
*/
- if (priv->disk_reserve_size || priv->disk_reserve_percent)
+ if (priv->disk_reserve)
posix_disk_space_check(this);
DISK_SPACE_CHECK_AND_GOTO(frame, priv, xdata, ret, ret, out);
@@ -2313,7 +2313,7 @@ posix_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
};
struct posix_private *priv = NULL;
int shared_by = 1;
- int percent = 0;
+ double percent = 0;
uint64_t reserved_blocks = 0;
VALIDATE_OR_GOTO(frame, out);
@@ -2340,11 +2340,14 @@ posix_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
goto out;
}
- if (priv->disk_reserve_size) {
- reserved_blocks = priv->disk_reserve_size / buf.f_bsize;
+ if (priv->disk_unit == 'p') {
+ percent = priv->disk_reserve;
+ reserved_blocks = (((buf.f_blocks * percent) / 100) + 0.5);
} else {
- percent = priv->disk_reserve_percent;
- reserved_blocks = (buf.f_blocks * percent) / 100;
+ if (buf.f_bsize) {
+ reserved_blocks = (priv->disk_reserve + buf.f_bsize - 1) /
+ buf.f_bsize;
+ }
}
if (buf.f_bfree > reserved_blocks) {