|
|
887953 |
From 216ac7a1bd22db08cc02d7b8688a3338e78c71cd Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Sanju Rakonde <srakonde@redhat.com>
|
|
|
887953 |
Date: Tue, 11 Sep 2018 14:19:42 +0530
|
|
|
887953 |
Subject: [PATCH 423/444] glusterd: acquire lock to update volinfo structure
|
|
|
887953 |
|
|
|
887953 |
Problem: With commit cb0339f92, we are using a separate syntask
|
|
|
887953 |
for restart_bricks. There can be a situation where two threads
|
|
|
887953 |
are accessing the same volinfo structure at the same time and
|
|
|
887953 |
updating volinfo structure. This can lead volinfo to have
|
|
|
887953 |
inconsistent values and assertion failures because of unexpected
|
|
|
887953 |
values.
|
|
|
887953 |
|
|
|
887953 |
Solution: While updating the volinfo structure, acquire a
|
|
|
887953 |
store_volinfo_lock, and release the lock only when the thread
|
|
|
887953 |
completed its critical section part.
|
|
|
887953 |
|
|
|
887953 |
> Fixes: bz#1627610
|
|
|
887953 |
> Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
|
|
|
887953 |
> Change-Id: I545e4e2368e3285d8f7aa28081ff4448abb72f5d
|
|
|
887953 |
|
|
|
887953 |
upstream patch: https://review.gluster.org/#/c/glusterfs/+/21150/
|
|
|
887953 |
|
|
|
887953 |
Change-Id: I545e4e2368e3285d8f7aa28081ff4448abb72f5d
|
|
|
887953 |
BUG: 1631418
|
|
|
887953 |
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/154885
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
xlators/mgmt/glusterd/src/glusterd-store.c | 67 +++++++++++++------------
|
|
|
887953 |
xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 2 +
|
|
|
887953 |
xlators/mgmt/glusterd/src/glusterd.h | 3 ++
|
|
|
887953 |
3 files changed, 40 insertions(+), 32 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
887953 |
index 015f6c2..37542e7 100644
|
|
|
887953 |
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
887953 |
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
887953 |
@@ -1796,46 +1796,49 @@ glusterd_store_volinfo (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t a
|
|
|
887953 |
|
|
|
887953 |
GF_ASSERT (volinfo);
|
|
|
887953 |
|
|
|
887953 |
- glusterd_perform_volinfo_version_action (volinfo, ac);
|
|
|
887953 |
- ret = glusterd_store_create_volume_dir (volinfo);
|
|
|
887953 |
- if (ret)
|
|
|
887953 |
- goto out;
|
|
|
887953 |
-
|
|
|
887953 |
- ret = glusterd_store_create_volume_run_dir (volinfo);
|
|
|
887953 |
- if (ret)
|
|
|
887953 |
- goto out;
|
|
|
887953 |
+ pthread_mutex_lock(&volinfo->store_volinfo_lock);
|
|
|
887953 |
+ {
|
|
|
887953 |
+ glusterd_perform_volinfo_version_action(volinfo, ac);
|
|
|
887953 |
+ ret = glusterd_store_create_volume_dir(volinfo);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
|
|
|
887953 |
- ret = glusterd_store_create_vol_shandle_on_absence (volinfo);
|
|
|
887953 |
- if (ret)
|
|
|
887953 |
- goto out;
|
|
|
887953 |
+ ret = glusterd_store_create_volume_run_dir(volinfo);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
|
|
|
887953 |
- ret = glusterd_store_create_nodestate_sh_on_absence (volinfo);
|
|
|
887953 |
- if (ret)
|
|
|
887953 |
- goto out;
|
|
|
887953 |
+ ret = glusterd_store_create_vol_shandle_on_absence(volinfo);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
|
|
|
887953 |
- ret = glusterd_store_perform_volume_store (volinfo);
|
|
|
887953 |
- if (ret)
|
|
|
887953 |
- goto out;
|
|
|
887953 |
+ ret = glusterd_store_create_nodestate_sh_on_absence(volinfo);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
|
|
|
887953 |
- ret = glusterd_store_volume_atomic_update (volinfo);
|
|
|
887953 |
- if (ret) {
|
|
|
887953 |
- glusterd_perform_volinfo_version_action (volinfo,
|
|
|
887953 |
- GLUSTERD_VOLINFO_VER_AC_DECREMENT);
|
|
|
887953 |
- goto out;
|
|
|
887953 |
- }
|
|
|
887953 |
+ ret = glusterd_store_perform_volume_store(volinfo);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
|
|
|
887953 |
- ret = glusterd_store_perform_node_state_store (volinfo);
|
|
|
887953 |
- if (ret)
|
|
|
887953 |
- goto out;
|
|
|
887953 |
+ ret = glusterd_store_volume_atomic_update(volinfo);
|
|
|
887953 |
+ if (ret) {
|
|
|
887953 |
+ glusterd_perform_volinfo_version_action(volinfo,
|
|
|
887953 |
+ GLUSTERD_VOLINFO_VER_AC_DECREMENT);
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
+ }
|
|
|
887953 |
|
|
|
887953 |
- /* checksum should be computed at the end */
|
|
|
887953 |
- ret = glusterd_compute_cksum (volinfo, _gf_false);
|
|
|
887953 |
- if (ret)
|
|
|
887953 |
- goto out;
|
|
|
887953 |
+ ret = glusterd_store_perform_node_state_store(volinfo);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
|
|
|
887953 |
-out:
|
|
|
887953 |
+ /* checksum should be computed at the end */
|
|
|
887953 |
+ ret = glusterd_compute_cksum(volinfo, _gf_false);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto unlock;
|
|
|
887953 |
+ }
|
|
|
887953 |
+unlock:
|
|
|
887953 |
+ pthread_mutex_unlock(&volinfo->store_volinfo_lock);
|
|
|
887953 |
if (ret)
|
|
|
887953 |
- glusterd_store_volume_cleanup_tmp (volinfo);
|
|
|
887953 |
+ glusterd_store_volume_cleanup_tmp(volinfo);
|
|
|
887953 |
|
|
|
887953 |
gf_msg_debug (THIS->name, 0, "Returning %d", ret);
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
887953 |
index 87b7acc..b91a516 100644
|
|
|
887953 |
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
887953 |
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
887953 |
@@ -2198,6 +2198,8 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
+ pthread_mutex_init(&volinfo->store_volinfo_lock, NULL);
|
|
|
887953 |
+
|
|
|
887953 |
ret = dict_get_str (dict, "volname", &volname);
|
|
|
887953 |
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
887953 |
index 8c70d48..edd41aa 100644
|
|
|
887953 |
--- a/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
887953 |
+++ b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
887953 |
@@ -478,6 +478,9 @@ struct glusterd_volinfo_ {
|
|
|
887953 |
gf_boolean_t stage_deleted; /* volume has passed staging
|
|
|
887953 |
* for delete operation
|
|
|
887953 |
*/
|
|
|
887953 |
+ pthread_mutex_t store_volinfo_lock; /* acquire lock for
|
|
|
887953 |
+ * updating the volinfo
|
|
|
887953 |
+ */
|
|
|
887953 |
};
|
|
|
887953 |
|
|
|
887953 |
typedef enum gd_snap_status_ {
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|