d2787b
From 43a8e2c7441b14f5f238cb11d83f32f248b16abb Mon Sep 17 00:00:00 2001
d2787b
From: Mohit Agrawal <moagrawa@redhat.com>
d2787b
Date: Tue, 13 Oct 2020 18:56:20 +0530
d2787b
Subject: [PATCH 505/511] trash: Create inode_table only while feature is
d2787b
 enabled
d2787b
d2787b
Currently trash xlator create a inode table(1M) even if
d2787b
feature is not enabled.In brick_mux environment while 250
d2787b
bricks are attached with a single brick process and feature
d2787b
is not enable brick process increase RSS size unnecessarily.
d2787b
d2787b
Solution: Create inode_table only while a feature is enabled.
d2787b
The patch reduces 250M RSS size per brick process
d2787b
if trash feature is not enabled.
d2787b
d2787b
> Change-Id: I11a6fd2b8419fe2988f398be6ec30fb4f3b99a5d
d2787b
> Fixes: #1543
d2787b
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
d2787b
> (Cherry pick from commit 32f25e7b1b4b080ab2640e178b407c878e629376)
d2787b
> (Reviewed on upstream link https://github.com/gluster/glusterfs/issues/1543)
d2787b
d2787b
Change-Id: I11a6fd2b8419fe2988f398be6ec30fb4f3b99a5d
d2787b
BUG: 1898781
d2787b
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
d2787b
Reviewed-on: https://code.engineering.redhat.com/gerrit/221184
d2787b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d2787b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
---
d2787b
 xlators/features/trash/src/trash.c | 47 +++++++++++++++++++++++++++++++++++---
d2787b
 1 file changed, 44 insertions(+), 3 deletions(-)
d2787b
d2787b
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
d2787b
index f96ed73..93f020f 100644
d2787b
--- a/xlators/features/trash/src/trash.c
d2787b
+++ b/xlators/features/trash/src/trash.c
d2787b
@@ -2235,16 +2235,47 @@ reconfigure(xlator_t *this, dict_t *options)
d2787b
     char trash_dir[PATH_MAX] = {
d2787b
         0,
d2787b
     };
d2787b
+    gf_boolean_t active_earlier = _gf_false;
d2787b
+    gf_boolean_t active_now = _gf_false;
d2787b
 
d2787b
     priv = this->private;
d2787b
 
d2787b
     GF_VALIDATE_OR_GOTO("trash", priv, out);
d2787b
 
d2787b
+    active_earlier = priv->state;
d2787b
+    GF_OPTION_RECONF("trash", active_now, options, bool, out);
d2787b
+
d2787b
+    /* Disable of trash feature is not allowed at this point until
d2787b
+       we are not able to find an approach to cleanup resource
d2787b
+       gracefully. Here to disable the feature need to destroy inode
d2787b
+       table and currently it is difficult to ensure inode is not
d2787b
+       being used
d2787b
+    */
d2787b
+    if (active_earlier && !active_now) {
d2787b
+        gf_log(this->name, GF_LOG_INFO,
d2787b
+               "Disable of trash feature is not allowed "
d2787b
+               "during graph reconfigure");
d2787b
+        ret = 0;
d2787b
+        goto out;
d2787b
+    }
d2787b
+
d2787b
+    if (!active_earlier && active_now) {
d2787b
+        if (!priv->trash_itable) {
d2787b
+            priv->trash_itable = inode_table_new(0, this);
d2787b
+            if (!priv->trash_itable) {
d2787b
+                ret = -ENOMEM;
d2787b
+                gf_log(this->name, GF_LOG_ERROR,
d2787b
+                       "failed to create trash inode_table"
d2787b
+                       "  during graph reconfigure");
d2787b
+                goto out;
d2787b
+            }
d2787b
+        }
d2787b
+        priv->state = active_now;
d2787b
+    }
d2787b
+
d2787b
     GF_OPTION_RECONF("trash-internal-op", priv->internal, options, bool, out);
d2787b
     GF_OPTION_RECONF("trash-dir", tmp, options, str, out);
d2787b
 
d2787b
-    GF_OPTION_RECONF("trash", priv->state, options, bool, out);
d2787b
-
d2787b
     if (priv->state) {
d2787b
         ret = create_or_rename_trash_directory(this);
d2787b
 
d2787b
@@ -2501,7 +2532,17 @@ init(xlator_t *this)
d2787b
         goto out;
d2787b
     }
d2787b
 
d2787b
-    priv->trash_itable = inode_table_new(0, this);
d2787b
+    if (priv->state) {
d2787b
+        priv->trash_itable = inode_table_new(0, this);
d2787b
+        if (!priv->trash_itable) {
d2787b
+            ret = -ENOMEM;
d2787b
+            priv->state = _gf_false;
d2787b
+            gf_log(this->name, GF_LOG_ERROR,
d2787b
+                   "failed to create trash inode_table disable trash");
d2787b
+            goto out;
d2787b
+        }
d2787b
+    }
d2787b
+
d2787b
     gf_log(this->name, GF_LOG_DEBUG, "brick path is%s", priv->brick_path);
d2787b
 
d2787b
     this->private = (void *)priv;
d2787b
-- 
d2787b
1.8.3.1
d2787b