From c494445c886e16ddc6a960b9074a68fe9621ee09 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 12 Jan 2018 10:51:44 +0530 Subject: 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 --- xlators/storage/posix/src/posix-inode-fd-ops.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'xlators/storage/posix/src') 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) { -- cgit