a3470f
From c4ce2bb15a9df0a1b6a999612ccd053e67dc7083 Mon Sep 17 00:00:00 2001
a3470f
From: Pranith Kumar K <pkarampu@redhat.com>
a3470f
Date: Mon, 19 Mar 2018 12:09:18 +0530
a3470f
Subject: [PATCH 187/201] features/shard: Do list_del_init() while list memory
a3470f
 is valid
a3470f
a3470f
Problem:
a3470f
shard_post_lookup_fsync_handler() goes over the list of inode-ctx that need to
a3470f
be fsynced and in cbk it removes each of the inode-ctx from the list. When the
a3470f
first member of list is removed it tries to modifies list head's memory with
a3470f
the latest next/prev and when this happens, there is no guarantee that the
a3470f
list-head which is from stack memory of shard_post_lookup_fsync_handler() is
a3470f
valid.
a3470f
a3470f
Fix:
a3470f
Do list_del_init() in the loop before winding fsync.
a3470f
a3470f
 >BUG: 1557876
a3470f
 >Change-Id: If429d3634219e1a435bd0da0ed985c646c59c2ca
a3470f
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
a3470f
a3470f
Upstream-patch: https://review.gluster.org/19737
a3470f
BUG: 1556895
a3470f
Change-Id: If429d3634219e1a435bd0da0ed985c646c59c2ca
a3470f
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/133241
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
a3470f
---
a3470f
 xlators/features/shard/src/shard.c | 2 +-
a3470f
 1 file changed, 1 insertion(+), 1 deletion(-)
a3470f
a3470f
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
a3470f
index a661345..945458e 100644
a3470f
--- a/xlators/features/shard/src/shard.c
a3470f
+++ b/xlators/features/shard/src/shard.c
a3470f
@@ -4521,7 +4521,6 @@ out:
a3470f
                         if (op_ret == 0)
a3470f
                                 ctx->fsync_needed -= fsync_count;
a3470f
                         GF_ASSERT (ctx->fsync_needed >= 0);
a3470f
-                        list_del_init (&ctx->to_fsync_list);
a3470f
                         if (ctx->fsync_needed != 0) {
a3470f
                                 list_add_tail (&ctx->to_fsync_list,
a3470f
                                                &base_ictx->to_fsync_list);
a3470f
@@ -4596,6 +4595,7 @@ shard_post_lookup_fsync_handler (call_frame_t *frame, xlator_t *this)
a3470f
         anon_fd = NULL;
a3470f
 
a3470f
         list_for_each_entry_safe (iter, tmp, &copy, to_fsync_list) {
a3470f
+                list_del_init (&iter->to_fsync_list);
a3470f
                 fsync_count = 0;
a3470f
                 shard_inode_ctx_get_fsync_count (iter->inode, this,
a3470f
                                                  &fsync_count);
a3470f
-- 
a3470f
1.8.3.1
a3470f