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