e7a346
From 78918cf18ead4637c5aea20025c319d845518733 Mon Sep 17 00:00:00 2001
e7a346
From: moagrawa <moagrawa@redhat.com>
e7a346
Date: Mon, 26 Mar 2018 11:00:22 +0530
e7a346
Subject: [PATCH 201/201] posix: After set storage.reserve limit df does not
e7a346
 show correct output
e7a346
e7a346
Problem: After set storage.reserve limit df does not show correct
e7a346
         output on client
e7a346
e7a346
Solution: Update code in posix_statfs to reflect the disk usage
e7a346
          correctly on client
e7a346
e7a346
> BUG: 1533736
e7a346
> Change-Id: I2c5feda0303d0f4abe5af22fac903011792b2dc8
e7a346
> Reviewed on https://review.gluster.org/#/c/19186/
e7a346
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
e7a346
> (cherry pick from commit c494445c886e16ddc6a960b9074a68fe9621ee09)
e7a346
e7a346
BUG: 1550982
e7a346
Change-Id: I5444fad40f2df2fdcf4ab80c2641fc9cc56b18fe
e7a346
Signed-off-by: moagrawa <moagrawa@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/133745
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
---
e7a346
 xlators/storage/posix/src/posix.c | 13 ++++++++++++-
e7a346
 1 file changed, 12 insertions(+), 1 deletion(-)
e7a346
e7a346
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
e7a346
index 6856e5e..56a2ca9 100644
e7a346
--- a/xlators/storage/posix/src/posix.c
e7a346
+++ b/xlators/storage/posix/src/posix.c
e7a346
@@ -3751,6 +3751,7 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
e7a346
         struct posix_private * priv      = NULL;
e7a346
         int                    shared_by = 1;
e7a346
         int                    percent   = 0;
e7a346
+        uint64_t               reserved_blocks = 0;
e7a346
 
e7a346
         VALIDATE_OR_GOTO (frame, out);
e7a346
         VALIDATE_OR_GOTO (this, out);
e7a346
@@ -3776,7 +3777,17 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
e7a346
         }
e7a346
 
e7a346
         percent = priv->disk_reserve;
e7a346
-        buf.f_bfree = (buf.f_bfree - ((buf.f_blocks * percent) / 100));
e7a346
+        reserved_blocks = (buf.f_blocks * percent) / 100;
e7a346
+
e7a346
+        if (buf.f_bfree > reserved_blocks) {
e7a346
+                buf.f_bfree = (buf.f_bfree - reserved_blocks);
e7a346
+                if (buf.f_bavail > buf.f_bfree) {
e7a346
+                        buf.f_bavail = buf.f_bfree;
e7a346
+                }
e7a346
+        } else {
e7a346
+                buf.f_bfree = 0;
e7a346
+                buf.f_bavail = 0;
e7a346
+        }
e7a346
 
e7a346
         shared_by = priv->shared_brick_count;
e7a346
         if (shared_by > 1) {
e7a346
-- 
e7a346
1.8.3.1
e7a346