17b94a
From dc03340654d921916ac3890d713fc84ef4bb1e28 Mon Sep 17 00:00:00 2001
17b94a
From: Mohit Agrawal <moagrawal@redhat.com>
17b94a
Date: Sat, 29 Sep 2018 13:15:35 +0530
17b94a
Subject: [PATCH 445/449] feature/changelog: Avoid thread creation if xlator is
17b94a
 not enabled
17b94a
17b94a
Problem:
17b94a
Changelog creates threads even if the changelog is not enabled
17b94a
17b94a
Background:
17b94a
Changelog xlator broadly does two things
17b94a
  1. Journalling - Cosumers are geo-rep and glusterfind
17b94a
  2. Event Notification for registered events like (open, release etc) -
17b94a
     Consumers are bitrot, geo-rep
17b94a
17b94a
The existing option "changelog.changelog" controls journalling and
17b94a
there is no option to control event notification and is enabled by
17b94a
default. So when bitrot/geo-rep is not enabled on the volume, threads
17b94a
and resources(rpc and rbuf) related to event notifications consumes
17b94a
resources and cpu cycle which is unnecessary.
17b94a
17b94a
Solution:
17b94a
The solution is to have two different options as below.
17b94a
 1. changelog-notification : Event notifications
17b94a
 2. changelog : Journalling
17b94a
17b94a
This patch introduces the option "changelog-notification" which is
17b94a
not exposed to user. When either bitrot or changelog (journalling)
17b94a
is enabled, it internally enbales 'changelog-notification'. But
17b94a
once the 'changelog-notification' is enabled, it will not be disabled
17b94a
for the life time of the brick process even after bitrot and changelog
17b94a
is disabled. As of now, rpc resource cleanup has lot of races and is
17b94a
difficult to cleanup cleanly. If allowed, it leads to memory leaks
17b94a
and crashes on enable/disable of bitrot or changelog (journal) in a
17b94a
loop. Hence to be safer, the event notification is not disabled within
17b94a
lifetime of process once enabled.
17b94a
17b94a
> Change-Id: Ifd00286e0966049e8eb9f21567fe407cf11bb02a
17b94a
> Updates: #475
17b94a
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
17b94a
> (Cherry pick from commit 6de80bcd6366778ac34ce58ec496fa08cc02bd0b)
17b94a
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/21896/)
17b94a
17b94a
BUG: 1790336
17b94a
Change-Id: Ifd00286e0966049e8eb9f21567fe407cf11bb02a
17b94a
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/202778
17b94a
Tested-by: Mohit Agrawal <moagrawa@redhat.com>
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 rpc/rpc-lib/src/rpcsvc.c                           |  26 ++--
17b94a
 tests/basic/changelog/changelog-history.t          |  12 +-
17b94a
 tests/bugs/bitrot/bug-1227996.t                    |   1 -
17b94a
 tests/bugs/bitrot/bug-1245981.t                    |   4 +-
17b94a
 xlators/features/changelog/src/changelog-helpers.h |   4 +
17b94a
 .../features/changelog/src/changelog-rpc-common.c  |   3 +
17b94a
 xlators/features/changelog/src/changelog.c         | 149 +++++++++++++++------
17b94a
 xlators/mgmt/glusterd/src/glusterd-volgen.c        |  13 ++
17b94a
 8 files changed, 154 insertions(+), 58 deletions(-)
17b94a
17b94a
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
17b94a
index b058932..3f184bf 100644
17b94a
--- a/rpc/rpc-lib/src/rpcsvc.c
17b94a
+++ b/rpc/rpc-lib/src/rpcsvc.c
17b94a
@@ -1865,6 +1865,18 @@ rpcsvc_program_unregister(rpcsvc_t *svc, rpcsvc_program_t *program)
17b94a
         goto out;
17b94a
     }
17b94a
 
17b94a
+    pthread_rwlock_rdlock(&svc->rpclock);
17b94a
+    {
17b94a
+        list_for_each_entry(prog, &svc->programs, program)
17b94a
+        {
17b94a
+            if ((prog->prognum == program->prognum) &&
17b94a
+                (prog->progver == program->progver)) {
17b94a
+                break;
17b94a
+            }
17b94a
+        }
17b94a
+    }
17b94a
+    pthread_rwlock_unlock(&svc->rpclock);
17b94a
+
17b94a
     ret = rpcsvc_program_unregister_portmap(program);
17b94a
     if (ret == -1) {
17b94a
         gf_log(GF_RPCSVC, GF_LOG_ERROR,
17b94a
@@ -1881,17 +1893,6 @@ rpcsvc_program_unregister(rpcsvc_t *svc, rpcsvc_program_t *program)
17b94a
         goto out;
17b94a
     }
17b94a
 #endif
17b94a
-    pthread_rwlock_rdlock(&svc->rpclock);
17b94a
-    {
17b94a
-        list_for_each_entry(prog, &svc->programs, program)
17b94a
-        {
17b94a
-            if ((prog->prognum == program->prognum) &&
17b94a
-                (prog->progver == program->progver)) {
17b94a
-                break;
17b94a
-            }
17b94a
-        }
17b94a
-    }
17b94a
-    pthread_rwlock_unlock(&svc->rpclock);
17b94a
 
17b94a
     gf_log(GF_RPCSVC, GF_LOG_DEBUG,
17b94a
            "Program unregistered: %s, Num: %d,"
17b94a
@@ -1912,6 +1913,9 @@ rpcsvc_program_unregister(rpcsvc_t *svc, rpcsvc_program_t *program)
17b94a
 
17b94a
     ret = 0;
17b94a
 out:
17b94a
+    if (prog)
17b94a
+        GF_FREE(prog);
17b94a
+
17b94a
     if (ret == -1) {
17b94a
         if (program) {
17b94a
             gf_log(GF_RPCSVC, GF_LOG_ERROR,
17b94a
diff --git a/tests/basic/changelog/changelog-history.t b/tests/basic/changelog/changelog-history.t
17b94a
index 3ce4098..b56e247 100644
17b94a
--- a/tests/basic/changelog/changelog-history.t
17b94a
+++ b/tests/basic/changelog/changelog-history.t
17b94a
@@ -5,6 +5,7 @@
17b94a
 
17b94a
 cleanup;
17b94a
 
17b94a
+SCRIPT_TIMEOUT=300
17b94a
 HISTORY_BIN_PATH=$(dirname $0)/../../utils/changelog
17b94a
 build_tester $HISTORY_BIN_PATH/get-history.c -lgfchangelog
17b94a
 
17b94a
@@ -68,18 +69,21 @@ TEST $CLI volume set $V0 changelog.changelog off
17b94a
 sleep 3
17b94a
 time_after_disable=$(date '+%s')
17b94a
 
17b94a
+TEST $CLI volume set $V0 changelog.changelog on
17b94a
+sleep 5
17b94a
+
17b94a
 #Passes, gives the changelogs till continuous changelogs are available
17b94a
 # but returns 1
17b94a
-EXPECT "1" $HISTORY_BIN_PATH/get-history $time_after_enable1 $time_in_sec_htime2
17b94a
+EXPECT_WITHIN 10 "1" $HISTORY_BIN_PATH/get-history $time_after_enable1 $time_in_sec_htime2
17b94a
 
17b94a
 #Fails as start falls between htime files
17b94a
-EXPECT "-3" $HISTORY_BIN_PATH/get-history $time_between_htime $time_in_sec_htime1
17b94a
+EXPECT_WITHIN 10 "-3" $HISTORY_BIN_PATH/get-history $time_between_htime $time_in_sec_htime1
17b94a
 
17b94a
 #Passes as start and end falls in same htime file
17b94a
-EXPECT "0" $HISTORY_BIN_PATH/get-history $time_in_sec_htime1 $time_in_sec_htime2
17b94a
+EXPECT_WITHIN 10 "0" $HISTORY_BIN_PATH/get-history $time_in_sec_htime1 $time_in_sec_htime2
17b94a
 
17b94a
 #Passes, gives the changelogs till continuous changelogs are available
17b94a
-EXPECT "0" $HISTORY_BIN_PATH/get-history $time_in_sec_htime2 $time_after_disable
17b94a
+EXPECT_WITHIN 10 "0" $HISTORY_BIN_PATH/get-history $time_in_sec_htime2 $time_after_disable
17b94a
 
17b94a
 TEST rm $HISTORY_BIN_PATH/get-history
17b94a
 
17b94a
diff --git a/tests/bugs/bitrot/bug-1227996.t b/tests/bugs/bitrot/bug-1227996.t
17b94a
index 47ebc42..121c7b5 100644
17b94a
--- a/tests/bugs/bitrot/bug-1227996.t
17b94a
+++ b/tests/bugs/bitrot/bug-1227996.t
17b94a
@@ -17,7 +17,6 @@ TEST pidof glusterd;
17b94a
 ## Lets create and start the volume
17b94a
 TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1
17b94a
 TEST $CLI volume start $V0
17b94a
-
17b94a
 ## Enable bitrot on volume $V0
17b94a
 TEST $CLI volume bitrot $V0 enable
17b94a
 
17b94a
diff --git a/tests/bugs/bitrot/bug-1245981.t b/tests/bugs/bitrot/bug-1245981.t
17b94a
index 2bed4d9..f395525 100644
17b94a
--- a/tests/bugs/bitrot/bug-1245981.t
17b94a
+++ b/tests/bugs/bitrot/bug-1245981.t
17b94a
@@ -47,9 +47,9 @@ touch $M0/5
17b94a
 sleep `expr $SLEEP_TIME \* 2`
17b94a
 
17b94a
 backpath=$(get_backend_paths $fname)
17b94a
-TEST getfattr -m . -n trusted.bit-rot.signature $backpath
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'trusted.bit-rot.signature' check_for_xattr 'trusted.bit-rot.signature' $backpath
17b94a
 
17b94a
 backpath=$(get_backend_paths $M0/new_file)
17b94a
-TEST getfattr -m . -n trusted.bit-rot.signature $backpath
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'trusted.bit-rot.signature' check_for_xattr 'trusted.bit-rot.signature' $backpath
17b94a
 
17b94a
 cleanup;
17b94a
diff --git a/xlators/features/changelog/src/changelog-helpers.h b/xlators/features/changelog/src/changelog-helpers.h
17b94a
index 517c4dc..3afacc9 100644
17b94a
--- a/xlators/features/changelog/src/changelog-helpers.h
17b94a
+++ b/xlators/features/changelog/src/changelog-helpers.h
17b94a
@@ -190,8 +190,12 @@ typedef struct changelog_ev_selector {
17b94a
 
17b94a
 /* changelog's private structure */
17b94a
 struct changelog_priv {
17b94a
+    /* changelog journalling */
17b94a
     gf_boolean_t active;
17b94a
 
17b94a
+    /* changelog live notifications */
17b94a
+    gf_boolean_t rpc_active;
17b94a
+
17b94a
     /* to generate unique socket file per brick */
17b94a
     char *changelog_brick;
17b94a
 
17b94a
diff --git a/xlators/features/changelog/src/changelog-rpc-common.c b/xlators/features/changelog/src/changelog-rpc-common.c
17b94a
index dcdcfb1..f2d1853 100644
17b94a
--- a/xlators/features/changelog/src/changelog-rpc-common.c
17b94a
+++ b/xlators/features/changelog/src/changelog-rpc-common.c
17b94a
@@ -263,6 +263,9 @@ changelog_rpc_server_destroy(xlator_t *this, rpcsvc_t *rpc, char *sockfile,
17b94a
     struct rpcsvc_program *prog = NULL;
17b94a
     rpc_transport_t *trans = NULL;
17b94a
 
17b94a
+    if (!rpc)
17b94a
+        return;
17b94a
+
17b94a
     while (*progs) {
17b94a
         prog = *progs;
17b94a
         (void)rpcsvc_program_unregister(rpc, prog);
17b94a
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
17b94a
index d9025f3..ff06c09 100644
17b94a
--- a/xlators/features/changelog/src/changelog.c
17b94a
+++ b/xlators/features/changelog/src/changelog.c
17b94a
@@ -34,6 +34,12 @@ static struct changelog_bootstrap cb_bootstrap[] = {
17b94a
     },
17b94a
 };
17b94a
 
17b94a
+static int
17b94a
+changelog_init_rpc(xlator_t *this, changelog_priv_t *priv);
17b94a
+
17b94a
+static int
17b94a
+changelog_init(xlator_t *this, changelog_priv_t *priv);
17b94a
+
17b94a
 /* Entry operations - TYPE III */
17b94a
 
17b94a
 /**
17b94a
@@ -2008,6 +2014,11 @@ notify(xlator_t *this, int event, void *data, ...)
17b94a
     uint64_t clntcnt = 0;
17b94a
     changelog_clnt_t *conn = NULL;
17b94a
     gf_boolean_t cleanup_notify = _gf_false;
17b94a
+    char sockfile[UNIX_PATH_MAX] = {
17b94a
+        0,
17b94a
+    };
17b94a
+    rpcsvc_listener_t *listener = NULL;
17b94a
+    rpcsvc_listener_t *next = NULL;
17b94a
 
17b94a
     INIT_LIST_HEAD(&queue);
17b94a
 
17b94a
@@ -2021,23 +2032,40 @@ notify(xlator_t *this, int event, void *data, ...)
17b94a
                "cleanup changelog rpc connection of brick %s",
17b94a
                priv->victim->name);
17b94a
 
17b94a
-        this->cleanup_starting = 1;
17b94a
-        changelog_destroy_rpc_listner(this, priv);
17b94a
-        conn = &priv->connections;
17b94a
-        if (conn)
17b94a
-            changelog_ev_cleanup_connections(this, conn);
17b94a
-        xprtcnt = GF_ATOMIC_GET(priv->xprtcnt);
17b94a
-        clntcnt = GF_ATOMIC_GET(priv->clntcnt);
17b94a
-
17b94a
-        if (!xprtcnt && !clntcnt) {
17b94a
-            LOCK(&priv->lock);
17b94a
-            {
17b94a
-                cleanup_notify = priv->notify_down;
17b94a
-                priv->notify_down = _gf_true;
17b94a
+        if (priv->rpc_active) {
17b94a
+            this->cleanup_starting = 1;
17b94a
+            changelog_destroy_rpc_listner(this, priv);
17b94a
+            conn = &priv->connections;
17b94a
+            if (conn)
17b94a
+                changelog_ev_cleanup_connections(this, conn);
17b94a
+            xprtcnt = GF_ATOMIC_GET(priv->xprtcnt);
17b94a
+            clntcnt = GF_ATOMIC_GET(priv->clntcnt);
17b94a
+            if (!xprtcnt && !clntcnt) {
17b94a
+                LOCK(&priv->lock);
17b94a
+                {
17b94a
+                    cleanup_notify = priv->notify_down;
17b94a
+                    priv->notify_down = _gf_true;
17b94a
+                }
17b94a
+                UNLOCK(&priv->lock);
17b94a
+                list_for_each_entry_safe(listener, next, &priv->rpc->listeners,
17b94a
+                                         list)
17b94a
+                {
17b94a
+                    if (listener->trans) {
17b94a
+                        rpc_transport_unref(listener->trans);
17b94a
+                    }
17b94a
+                }
17b94a
+                CHANGELOG_MAKE_SOCKET_PATH(priv->changelog_brick, sockfile,
17b94a
+                                           UNIX_PATH_MAX);
17b94a
+                sys_unlink(sockfile);
17b94a
+                if (priv->rpc) {
17b94a
+                    rpcsvc_destroy(priv->rpc);
17b94a
+                    priv->rpc = NULL;
17b94a
+                }
17b94a
+                if (!cleanup_notify)
17b94a
+                    default_notify(this, GF_EVENT_PARENT_DOWN, data);
17b94a
             }
17b94a
-            UNLOCK(&priv->lock);
17b94a
-            if (!cleanup_notify)
17b94a
-                default_notify(this, GF_EVENT_PARENT_DOWN, data);
17b94a
+        } else {
17b94a
+            default_notify(this, GF_EVENT_PARENT_DOWN, data);
17b94a
         }
17b94a
         goto out;
17b94a
     }
17b94a
@@ -2425,6 +2453,22 @@ changelog_barrier_pthread_destroy(changelog_priv_t *priv)
17b94a
     LOCK_DESTROY(&priv->bflags.lock);
17b94a
 }
17b94a
 
17b94a
+static void
17b94a
+changelog_cleanup_rpc(xlator_t *this, changelog_priv_t *priv)
17b94a
+{
17b94a
+    /* terminate rpc server */
17b94a
+    if (!this->cleanup_starting)
17b94a
+        changelog_destroy_rpc_listner(this, priv);
17b94a
+
17b94a
+    (void)changelog_cleanup_rpc_threads(this, priv);
17b94a
+    /* cleanup rot buffs */
17b94a
+    rbuf_dtor(priv->rbuf);
17b94a
+
17b94a
+    /* cleanup poller thread */
17b94a
+    if (priv->poller)
17b94a
+        (void)changelog_thread_cleanup(this, priv->poller);
17b94a
+}
17b94a
+
17b94a
 int
17b94a
 reconfigure(xlator_t *this, dict_t *options)
17b94a
 {
17b94a
@@ -2433,6 +2477,9 @@ reconfigure(xlator_t *this, dict_t *options)
17b94a
     changelog_priv_t *priv = NULL;
17b94a
     gf_boolean_t active_earlier = _gf_true;
17b94a
     gf_boolean_t active_now = _gf_true;
17b94a
+    gf_boolean_t rpc_active_earlier = _gf_true;
17b94a
+    gf_boolean_t rpc_active_now = _gf_true;
17b94a
+    gf_boolean_t iniate_rpc = _gf_false;
17b94a
     changelog_time_slice_t *slice = NULL;
17b94a
     changelog_log_data_t cld = {
17b94a
         0,
17b94a
@@ -2454,6 +2501,7 @@ reconfigure(xlator_t *this, dict_t *options)
17b94a
 
17b94a
     ret = -1;
17b94a
     active_earlier = priv->active;
17b94a
+    rpc_active_earlier = priv->rpc_active;
17b94a
 
17b94a
     /* first stop the rollover and the fsync thread */
17b94a
     changelog_cleanup_helper_threads(this, priv);
17b94a
@@ -2487,6 +2535,29 @@ reconfigure(xlator_t *this, dict_t *options)
17b94a
         goto out;
17b94a
 
17b94a
     GF_OPTION_RECONF("changelog", active_now, options, bool, out);
17b94a
+    GF_OPTION_RECONF("changelog-notification", rpc_active_now, options, bool,
17b94a
+                     out);
17b94a
+
17b94a
+    /* If journalling is enabled, enable rpc notifications */
17b94a
+    if (active_now && !active_earlier) {
17b94a
+        if (!rpc_active_earlier)
17b94a
+            iniate_rpc = _gf_true;
17b94a
+    }
17b94a
+
17b94a
+    if (rpc_active_now && !rpc_active_earlier) {
17b94a
+        iniate_rpc = _gf_true;
17b94a
+    }
17b94a
+
17b94a
+    /* TODO: Disable of changelog-notifications is not supported for now
17b94a
+     * as there is no clean way of cleaning up of rpc resources
17b94a
+     */
17b94a
+
17b94a
+    if (iniate_rpc) {
17b94a
+        ret = changelog_init_rpc(this, priv);
17b94a
+        if (ret)
17b94a
+            goto out;
17b94a
+        priv->rpc_active = _gf_true;
17b94a
+    }
17b94a
 
17b94a
     /**
17b94a
      * changelog_handle_change() handles changes that could possibly
17b94a
@@ -2618,6 +2689,7 @@ changelog_init_options(xlator_t *this, changelog_priv_t *priv)
17b94a
         goto dealloc_2;
17b94a
 
17b94a
     GF_OPTION_INIT("changelog", priv->active, bool, dealloc_2);
17b94a
+    GF_OPTION_INIT("changelog-notification", priv->rpc_active, bool, dealloc_2);
17b94a
     GF_OPTION_INIT("capture-del-path", priv->capture_del_path, bool, dealloc_2);
17b94a
 
17b94a
     GF_OPTION_INIT("op-mode", tmp, str, dealloc_2);
17b94a
@@ -2656,22 +2728,6 @@ error_return:
17b94a
     return -1;
17b94a
 }
17b94a
 
17b94a
-static void
17b94a
-changelog_cleanup_rpc(xlator_t *this, changelog_priv_t *priv)
17b94a
-{
17b94a
-    /* terminate rpc server */
17b94a
-    if (!this->cleanup_starting)
17b94a
-        changelog_destroy_rpc_listner(this, priv);
17b94a
-
17b94a
-    (void)changelog_cleanup_rpc_threads(this, priv);
17b94a
-    /* cleanup rot buffs */
17b94a
-    rbuf_dtor(priv->rbuf);
17b94a
-
17b94a
-    /* cleanup poller thread */
17b94a
-    if (priv->poller)
17b94a
-        (void)changelog_thread_cleanup(this, priv->poller);
17b94a
-}
17b94a
-
17b94a
 static int
17b94a
 changelog_init_rpc(xlator_t *this, changelog_priv_t *priv)
17b94a
 {
17b94a
@@ -2768,10 +2824,13 @@ init(xlator_t *this)
17b94a
     INIT_LIST_HEAD(&priv->queue);
17b94a
     priv->barrier_enabled = _gf_false;
17b94a
 
17b94a
-    /* RPC ball rolling.. */
17b94a
-    ret = changelog_init_rpc(this, priv);
17b94a
-    if (ret)
17b94a
-        goto cleanup_barrier;
17b94a
+    if (priv->rpc_active || priv->active) {
17b94a
+        /* RPC ball rolling.. */
17b94a
+        ret = changelog_init_rpc(this, priv);
17b94a
+        if (ret)
17b94a
+            goto cleanup_barrier;
17b94a
+        priv->rpc_active = _gf_true;
17b94a
+    }
17b94a
 
17b94a
     ret = changelog_init(this, priv);
17b94a
     if (ret)
17b94a
@@ -2783,7 +2842,9 @@ init(xlator_t *this)
17b94a
     return 0;
17b94a
 
17b94a
 cleanup_rpc:
17b94a
-    changelog_cleanup_rpc(this, priv);
17b94a
+    if (priv->rpc_active) {
17b94a
+        changelog_cleanup_rpc(this, priv);
17b94a
+    }
17b94a
 cleanup_barrier:
17b94a
     changelog_barrier_pthread_destroy(priv);
17b94a
 cleanup_options:
17b94a
@@ -2808,9 +2869,10 @@ fini(xlator_t *this)
17b94a
     priv = this->private;
17b94a
 
17b94a
     if (priv) {
17b94a
-        /* terminate RPC server/threads */
17b94a
-        changelog_cleanup_rpc(this, priv);
17b94a
-
17b94a
+        if (priv->active || priv->rpc_active) {
17b94a
+            /* terminate RPC server/threads */
17b94a
+            changelog_cleanup_rpc(this, priv);
17b94a
+        }
17b94a
         /* call barrier_disable to cancel timer */
17b94a
         if (priv->barrier_enabled)
17b94a
             __chlog_barrier_disable(this, &queue);
17b94a
@@ -2879,6 +2941,13 @@ struct volume_options options[] = {
17b94a
      .flags = OPT_FLAG_SETTABLE,
17b94a
      .level = OPT_STATUS_BASIC,
17b94a
      .tags = {"journal", "georep", "glusterfind"}},
17b94a
+    {.key = {"changelog-notification"},
17b94a
+     .type = GF_OPTION_TYPE_BOOL,
17b94a
+     .default_value = "off",
17b94a
+     .description = "enable/disable changelog live notification",
17b94a
+     .op_version = {3},
17b94a
+     .level = OPT_STATUS_BASIC,
17b94a
+     .tags = {"bitrot", "georep"}},
17b94a
     {.key = {"changelog-brick"},
17b94a
      .type = GF_OPTION_TYPE_PATH,
17b94a
      .description = "brick path to generate unique socket file name."
17b94a
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
17b94a
index 16346e7..13f84ea 100644
17b94a
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
17b94a
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
17b94a
@@ -1876,6 +1876,19 @@ brick_graph_add_changelog(volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
17b94a
     ret = xlator_set_fixed_option(xl, "changelog-dir", changelog_basepath);
17b94a
     if (ret)
17b94a
         goto out;
17b94a
+
17b94a
+    ret = glusterd_is_bitrot_enabled(volinfo);
17b94a
+    if (ret == -1) {
17b94a
+        goto out;
17b94a
+    } else if (ret) {
17b94a
+        ret = xlator_set_fixed_option(xl, "changelog-notification", "on");
17b94a
+        if (ret)
17b94a
+            goto out;
17b94a
+    } else {
17b94a
+        ret = xlator_set_fixed_option(xl, "changelog-notification", "off");
17b94a
+        if (ret)
17b94a
+            goto out;
17b94a
+    }
17b94a
 out:
17b94a
     return ret;
17b94a
 }
17b94a
-- 
17b94a
1.8.3.1
17b94a