cb8e9e
From c5ec2f7b76ce128c93413ab260c7bb7b59027219 Mon Sep 17 00:00:00 2001
cb8e9e
From: Venky Shankar <vshankar@redhat.com>
cb8e9e
Date: Tue, 30 Jun 2015 13:10:46 +0530
cb8e9e
Subject: [PATCH 240/244] features/bitrot: move inode state just at the last moment
cb8e9e
cb8e9e
    Backport of http://review.gluster.org/11461
cb8e9e
cb8e9e
Which was done at half the set expiry time resulting in actual
cb8e9e
IOs incrementing the object version. Now this is done just at
cb8e9e
the last moment with re-notification now cut-shorting into
cb8e9e
checksum calculation without waiting in the timer-wheel.
cb8e9e
cb8e9e
BUG: 1242585
cb8e9e
Change-Id: If655b77d822ebf7b2a4f65e1b5583dd3609306e7
cb8e9e
Signed-off-by: Venky Shankar <vshankar@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/52926
cb8e9e
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
cb8e9e
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
cb8e9e
---
cb8e9e
 xlators/features/bit-rot/src/bitd/bit-rot.c |   61 ++++++++++++++++++--------
cb8e9e
 1 files changed, 42 insertions(+), 19 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
cb8e9e
index 94063cb..4a050c8 100644
cb8e9e
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
cb8e9e
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
cb8e9e
@@ -594,15 +594,12 @@ static inline int32_t br_sign_object (br_object_t *object)
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
-        /* sanity check */
cb8e9e
-        sign_info = ntohl (object->sign_info);
cb8e9e
-        GF_ASSERT (sign_info != BR_SIGN_NORMAL);
cb8e9e
-
cb8e9e
         /**
cb8e9e
          * For fd's that have notified for reopening, we send an explicit
cb8e9e
          * open() followed by a dummy write() call. This triggers the
cb8e9e
          * actual signing of the object.
cb8e9e
          */
cb8e9e
+        sign_info = ntohl (object->sign_info);
cb8e9e
         if (sign_info == BR_SIGN_REOPEN_WAIT) {
cb8e9e
                 br_object_resign (this, object, linked_inode);
cb8e9e
                 goto unref_inode;
cb8e9e
@@ -722,7 +719,8 @@ br_add_object_to_queue (struct gf_tw_timer_list *timer,
cb8e9e
         }
cb8e9e
         pthread_mutex_unlock (&priv->lock);
cb8e9e
 
cb8e9e
-        mem_put (timer);
cb8e9e
+        if (timer)
cb8e9e
+                mem_put (timer);
cb8e9e
         return;
cb8e9e
 }
cb8e9e
 
cb8e9e
@@ -762,7 +760,7 @@ br_initialize_timer (xlator_t *this, br_object_t *object, br_child_t *child,
cb8e9e
                 goto out;
cb8e9e
         INIT_LIST_HEAD (&timer->entry);
cb8e9e
 
cb8e9e
-        timer->expires  = (priv->expiry_time >> 1);
cb8e9e
+        timer->expires = priv->expiry_time;
cb8e9e
         if (!timer->expires)
cb8e9e
                 timer->expires = 1;
cb8e9e
 
cb8e9e
@@ -774,6 +772,27 @@ out:
cb8e9e
         return timer;
cb8e9e
 }
cb8e9e
 
cb8e9e
+static int32_t
cb8e9e
+br_schedule_object_reopen (xlator_t *this, br_object_t *object,
cb8e9e
+                           br_child_t *child, changelog_event_t *ev)
cb8e9e
+{
cb8e9e
+        struct gf_tw_timer_list *timer = NULL;
cb8e9e
+
cb8e9e
+        timer = br_initialize_timer (this, object, child, ev);
cb8e9e
+        if (!timer)
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED,
cb8e9e
+                        "Failed to allocate object expiry timer [GFID: %s]",
cb8e9e
+                        uuid_utoa (object->gfid));
cb8e9e
+        return timer ? 0 : -1;
cb8e9e
+}
cb8e9e
+
cb8e9e
+static int32_t
cb8e9e
+br_object_quicksign (xlator_t *this, br_object_t *object)
cb8e9e
+{
cb8e9e
+        br_add_object_to_queue (NULL, object, 0ULL);
cb8e9e
+        return 0;
cb8e9e
+}
cb8e9e
+
cb8e9e
 /**
cb8e9e
  * This callback function registered with the changelog is executed
cb8e9e
  * whenever a notification from the changelog is received. This should
cb8e9e
@@ -787,11 +806,12 @@ void
cb8e9e
 br_brick_callback (void *xl, char *brick,
cb8e9e
                    void *data, changelog_event_t *ev)
cb8e9e
 {
cb8e9e
-        uuid_t gfid = {0,};
cb8e9e
-        xlator_t                *this   = NULL;
cb8e9e
-        br_object_t             *object = NULL;
cb8e9e
-        br_child_t              *child  = NULL;
cb8e9e
-        struct gf_tw_timer_list *timer  = NULL;
cb8e9e
+        int32_t          ret       = 0;
cb8e9e
+        uuid_t           gfid      = {0,};
cb8e9e
+        xlator_t        *this      = NULL;
cb8e9e
+        br_object_t     *object    = NULL;
cb8e9e
+        br_child_t      *child     = NULL;
cb8e9e
+        br_sign_state_t  sign_info = BR_SIGN_INVALID;
cb8e9e
 
cb8e9e
         this = xl;
cb8e9e
 
cb8e9e
@@ -822,22 +842,25 @@ br_brick_callback (void *xl, char *brick,
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
-        timer = br_initialize_timer (this, object, child, ev);
cb8e9e
-        if (!timer) {
cb8e9e
-                gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED,
cb8e9e
-                        "failed to allocate object expiry timer [GFID: %s]",
cb8e9e
-                        uuid_utoa (gfid));
cb8e9e
+        /* sanity check */
cb8e9e
+        sign_info = ntohl (object->sign_info);
cb8e9e
+        GF_ASSERT (sign_info != BR_SIGN_NORMAL);
cb8e9e
+
cb8e9e
+        if (sign_info == BR_SIGN_REOPEN_WAIT)
cb8e9e
+                ret = br_schedule_object_reopen (this, object, child, ev);
cb8e9e
+        else
cb8e9e
+                ret = br_object_quicksign (this, object);
cb8e9e
+
cb8e9e
+        if (ret)
cb8e9e
                 goto free_object;
cb8e9e
-        }
cb8e9e
 
cb8e9e
         gf_msg_debug (this->name, 0, "->callback: brick [%s], type [%d]\n",
cb8e9e
                       brick, ev->ev_type);
cb8e9e
-
cb8e9e
         return;
cb8e9e
 
cb8e9e
  free_object:
cb8e9e
         GF_FREE (object);
cb8e9e
-out:
cb8e9e
+ out:
cb8e9e
         return;
cb8e9e
 }
cb8e9e
 
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e