summaryrefslogtreecommitdiffstats
path: root/super1.c
diff options
context:
space:
mode:
authorGuoqing Jiang <gqjiang@suse.com>2018-01-22 10:12:08 +0100
committerJes Sorensen <jsorensen@fb.com>2018-03-08 20:16:42 +0100
commit1b7eb962db2cf9179d097e06cce74b84ac80e49d (patch)
treef0fa6b7fe7f88b2d8e9341a2ca4f7349d06471ea /super1.c
parentAdd one sanity check for missing device (diff)
downloadmdadm-1b7eb962db2cf9179d097e06cce74b84ac80e49d.tar.xz
mdadm-1b7eb962db2cf9179d097e06cce74b84ac80e49d.zip
mdadm: improve the dlm locking mechanism for clustered raid
Previously, the dlm locking only protects several functions which writes to superblock (update_super, add_to_super and store_super), and we missed other funcs such as add_internal_bitmap. We also need to call the funcs which read superblock under the locking protection to avoid consistent issue. So let's remove the dlm stuffs from super1.c, and provide the locking mechanism to the main() except assemble mode which will be handled in next commit. And since we can identify it is a clustered raid or not based on check the different conditions of each mode, so the change should not have effect on native array. And we improve the existed locking stuffs as follows: 1. replace ls_unlock with ls_unlock_wait since we should return when unlock operation is complete. 2. inspired by lvm, let's also try to use the existed lockspace first before creat a lockspace blindly if the lockspace not released for some reason. 3. try more times before quit if EAGAIN happened for locking. Note: for MANAGE mode, we do not need to get lock if node just want to confirm device change, otherwise we can't add a disk to cluster since all nodes are compete for the lock. Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c42
1 files changed, 0 insertions, 42 deletions
diff --git a/super1.c b/super1.c
index 7ae6dc32..6774fbd2 100644
--- a/super1.c
+++ b/super1.c
@@ -1185,20 +1185,9 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
* ignored.
*/
int rv = 0;
- int lockid;
struct mdp_superblock_1 *sb = st->sb;
bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + MAX_SB_SIZE);
- if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready()) {
- rv = cluster_get_dlmlock(&lockid);
- if (rv) {
- pr_err("Cannot get dlmlock in %s return %d\n",
- __func__, rv);
- cluster_release_dlmlock(lockid);
- return rv;
- }
- }
-
if (strcmp(update, "homehost") == 0 &&
homehost) {
/* Note that 'homehost' is special as it is really
@@ -1551,8 +1540,6 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
rv = -1;
sb->sb_csum = calc_sb_1_csum(sb);
- if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready())
- cluster_release_dlmlock(lockid);
return rv;
}
@@ -1656,20 +1643,8 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
struct mdp_superblock_1 *sb = st->sb;
__u16 *rp = sb->dev_roles + dk->number;
struct devinfo *di, **dip;
- bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + MAX_SB_SIZE);
- int rv, lockid;
int dk_state;
- if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready()) {
- rv = cluster_get_dlmlock(&lockid);
- if (rv) {
- pr_err("Cannot get dlmlock in %s return %d\n",
- __func__, rv);
- cluster_release_dlmlock(lockid);
- return rv;
- }
- }
-
dk_state = dk->state & ~(1<<MD_DISK_FAILFAST);
if ((dk_state & (1<<MD_DISK_ACTIVE)) &&
(dk_state & (1<<MD_DISK_SYNC)))/* active, sync */
@@ -1701,9 +1676,6 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
di->next = NULL;
*dip = di;
- if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready())
- cluster_release_dlmlock(lockid);
-
return 0;
}
@@ -1716,18 +1688,6 @@ static int store_super1(struct supertype *st, int fd)
struct align_fd afd;
int sbsize;
unsigned long long dsize;
- bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + MAX_SB_SIZE);
- int rv, lockid;
-
- if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready()) {
- rv = cluster_get_dlmlock(&lockid);
- if (rv) {
- pr_err("Cannot get dlmlock in %s return %d\n",
- __func__, rv);
- cluster_release_dlmlock(lockid);
- return rv;
- }
- }
if (!get_dev_size(fd, NULL, &dsize))
return 1;
@@ -1788,8 +1748,6 @@ static int store_super1(struct supertype *st, int fd)
}
}
fsync(fd);
- if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready())
- cluster_release_dlmlock(lockid);
return 0;
}