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