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