summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-internal.h12
-rw-r--r--api/src/glfs-master.c3
-rw-r--r--api/src/glfs-resolve.c14
3 files changed, 23 insertions, 6 deletions
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index e1b8c8ac5f2..fe59a3b8eb9 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -187,8 +187,16 @@ struct glfs {
int ret;
int err;
- xlator_t *active_subvol;
- xlator_t *next_subvol;
+ xlator_t *active_subvol; /* active graph */
+ xlator_t *mip_subvol; /* graph for which migration is in
+ * progress */
+ xlator_t *next_subvol; /* Any new graph is put to
+ * next_subvol, the graph in
+ * next_subvol can either be move to
+ * mip_subvol (if any IO picks it up
+ * for migration), or be detroyed (if
+ * there is a new graph, and this was
+ * never picked for migration) */
xlator_t *old_subvol;
char *oldvolfile;
diff --git a/api/src/glfs-master.c b/api/src/glfs-master.c
index b49ce2c8447..fd1f45d715f 100644
--- a/api/src/glfs-master.c
+++ b/api/src/glfs-master.c
@@ -45,7 +45,8 @@ graph_setup (struct glfs *fs, glusterfs_graph_t *graph)
{
if (new_subvol->switched ||
new_subvol == fs->active_subvol ||
- new_subvol == fs->next_subvol) {
+ new_subvol == fs->next_subvol ||
+ new_subvol == fs->mip_subvol) {
/* Spurious CHILD_UP event on old graph */
ret = 0;
goto unlock;
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index 4c44b4f7ac8..b31507a949b 100644
--- a/api/src/glfs-resolve.c
+++ b/api/src/glfs-resolve.c
@@ -825,6 +825,13 @@ __glfs_migrate_openfds (struct glfs *fs, xlator_t *subvol)
}
+/* Note that though it appears that this function executes under fs->mutex,
+ * it is not fully executed under fs->mutex. i.e. there are functions like
+ * __glfs_first_lookup, __glfs_refresh_inode, __glfs_migrate_openfds which
+ * unlocks fs->mutex before sending any network fop, and reacquire fs->mutex
+ * once the fop is complete. Hence the variable read from fs at the start of the
+ * function need not have the same value by the end of the function.
+ */
xlator_t *
__glfs_active_subvol (struct glfs *fs)
{
@@ -835,7 +842,8 @@ __glfs_active_subvol (struct glfs *fs)
if (!fs->next_subvol)
return fs->active_subvol;
- new_subvol = fs->next_subvol;
+ new_subvol = fs->mip_subvol = fs->next_subvol;
+ fs->next_subvol = NULL;
ret = __glfs_first_lookup (fs, new_subvol);
if (ret) {
@@ -869,8 +877,8 @@ __glfs_active_subvol (struct glfs *fs)
should be atomic
*/
fs->old_subvol = fs->active_subvol;
- fs->active_subvol = fs->next_subvol;
- fs->next_subvol = NULL;
+ fs->active_subvol = fs->mip_subvol;
+ fs->mip_subvol = NULL;
if (new_cwd) {
__glfs_cwd_set (fs, new_cwd);