summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2018-01-12 10:51:44 +0530
committerKrutika Dhananjay <kdhananj@redhat.com>2018-01-15 06:30:42 +0000
commitc494445c886e16ddc6a960b9074a68fe9621ee09 (patch)
treecd33714556b1979bb831e3e65eb251869688131f
parent0f653fe4fb3a654af65fda736fa23cf0ec9f741c (diff)
storage/posix: Set f_bfree to 0 if brick full
Return 0 free blocks if the brick is full or has less than the reserved limit. Change-Id: I2c5feda0303d0f4abe5af22fac903011792b2dc8 BUG: 1533736 Signed-off-by: N Balachandran <nbalacha@redhat.com>
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index 8cb7630c599..c90bc6c438a 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -1709,6 +1709,7 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
struct posix_private * priv = NULL;
int shared_by = 1;
int percent = 0;
+ uint64_t reserved_blocks = 0;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -1734,7 +1735,17 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
}
percent = priv->disk_reserve;
- buf.f_bfree = (buf.f_bfree - ((buf.f_blocks * percent) / 100));
+ reserved_blocks = (buf.f_blocks * percent) / 100;
+
+ if (buf.f_bfree > reserved_blocks) {
+ buf.f_bfree = (buf.f_bfree - reserved_blocks);
+ if (buf.f_bavail > buf.f_bfree) {
+ buf.f_bavail = buf.f_bfree;
+ }
+ } else {
+ buf.f_bfree = 0;
+ buf.f_bavail = 0;
+ }
shared_by = priv->shared_brick_count;
if (shared_by > 1) {