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