Commit ea89238c authored by Guoqing Jiang's avatar Guoqing Jiang Committed by Shaohua Li

md-cluster: remove suspend_info

Previously, we allow multiple nodes can resync device, but we
had changed it to only support one node can do resync at one
time, but suspend_info is still used.

Now, let's remove the structure and use suspend_lo/hi to record
the range.
Reviewed-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGuoqing Jiang <gqjiang@suse.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent cb9ee154
...@@ -33,13 +33,6 @@ struct dlm_lock_resource { ...@@ -33,13 +33,6 @@ struct dlm_lock_resource {
int mode; int mode;
}; };
struct suspend_info {
int slot;
sector_t lo;
sector_t hi;
struct list_head list;
};
struct resync_info { struct resync_info {
__le64 lo; __le64 lo;
__le64 hi; __le64 hi;
...@@ -80,7 +73,13 @@ struct md_cluster_info { ...@@ -80,7 +73,13 @@ struct md_cluster_info {
struct dlm_lock_resource **other_bitmap_lockres; struct dlm_lock_resource **other_bitmap_lockres;
struct dlm_lock_resource *resync_lockres; struct dlm_lock_resource *resync_lockres;
struct list_head suspend_list; struct list_head suspend_list;
spinlock_t suspend_lock; spinlock_t suspend_lock;
/* record the region which write should be suspended */
sector_t suspend_lo;
sector_t suspend_hi;
int suspend_from; /* the slot which broadcast suspend_lo/hi */
struct md_thread *recovery_thread; struct md_thread *recovery_thread;
unsigned long recovery_map; unsigned long recovery_map;
/* communication loc resources */ /* communication loc resources */
...@@ -271,25 +270,22 @@ static void add_resync_info(struct dlm_lock_resource *lockres, ...@@ -271,25 +270,22 @@ static void add_resync_info(struct dlm_lock_resource *lockres,
ri->hi = cpu_to_le64(hi); ri->hi = cpu_to_le64(hi);
} }
static struct suspend_info *read_resync_info(struct mddev *mddev, struct dlm_lock_resource *lockres) static int read_resync_info(struct mddev *mddev,
struct dlm_lock_resource *lockres)
{ {
struct resync_info ri; struct resync_info ri;
struct suspend_info *s = NULL; struct md_cluster_info *cinfo = mddev->cluster_info;
sector_t hi = 0; int ret = 0;
dlm_lock_sync(lockres, DLM_LOCK_CR); dlm_lock_sync(lockres, DLM_LOCK_CR);
memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(struct resync_info)); memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(struct resync_info));
hi = le64_to_cpu(ri.hi); if (le64_to_cpu(ri.hi) > 0) {
if (hi > 0) { cinfo->suspend_hi = le64_to_cpu(ri.hi);
s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL); cinfo->suspend_lo = le64_to_cpu(ri.lo);
if (!s) ret = 1;
goto out;
s->hi = hi;
s->lo = le64_to_cpu(ri.lo);
} }
dlm_unlock_sync(lockres); dlm_unlock_sync(lockres);
out: return ret;
return s;
} }
static void recover_bitmaps(struct md_thread *thread) static void recover_bitmaps(struct md_thread *thread)
...@@ -299,7 +295,6 @@ static void recover_bitmaps(struct md_thread *thread) ...@@ -299,7 +295,6 @@ static void recover_bitmaps(struct md_thread *thread)
struct dlm_lock_resource *bm_lockres; struct dlm_lock_resource *bm_lockres;
char str[64]; char str[64];
int slot, ret; int slot, ret;
struct suspend_info *s, *tmp;
sector_t lo, hi; sector_t lo, hi;
while (cinfo->recovery_map) { while (cinfo->recovery_map) {
...@@ -326,11 +321,9 @@ static void recover_bitmaps(struct md_thread *thread) ...@@ -326,11 +321,9 @@ static void recover_bitmaps(struct md_thread *thread)
/* Clear suspend_area associated with the bitmap */ /* Clear suspend_area associated with the bitmap */
spin_lock_irq(&cinfo->suspend_lock); spin_lock_irq(&cinfo->suspend_lock);
list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list) cinfo->suspend_hi = 0;
if (slot == s->slot) { cinfo->suspend_lo = 0;
list_del(&s->list); cinfo->suspend_from = -1;
kfree(s);
}
spin_unlock_irq(&cinfo->suspend_lock); spin_unlock_irq(&cinfo->suspend_lock);
/* Kick off a reshape if needed */ /* Kick off a reshape if needed */
...@@ -441,24 +434,13 @@ static void ack_bast(void *arg, int mode) ...@@ -441,24 +434,13 @@ static void ack_bast(void *arg, int mode)
} }
} }
static void __remove_suspend_info(struct md_cluster_info *cinfo, int slot)
{
struct suspend_info *s, *tmp;
list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
if (slot == s->slot) {
list_del(&s->list);
kfree(s);
break;
}
}
static void remove_suspend_info(struct mddev *mddev, int slot) static void remove_suspend_info(struct mddev *mddev, int slot)
{ {
struct md_cluster_info *cinfo = mddev->cluster_info; struct md_cluster_info *cinfo = mddev->cluster_info;
mddev->pers->quiesce(mddev, 1); mddev->pers->quiesce(mddev, 1);
spin_lock_irq(&cinfo->suspend_lock); spin_lock_irq(&cinfo->suspend_lock);
__remove_suspend_info(cinfo, slot); cinfo->suspend_hi = 0;
cinfo->suspend_lo = 0;
spin_unlock_irq(&cinfo->suspend_lock); spin_unlock_irq(&cinfo->suspend_lock);
mddev->pers->quiesce(mddev, 0); mddev->pers->quiesce(mddev, 0);
} }
...@@ -467,7 +449,6 @@ static void process_suspend_info(struct mddev *mddev, ...@@ -467,7 +449,6 @@ static void process_suspend_info(struct mddev *mddev,
int slot, sector_t lo, sector_t hi) int slot, sector_t lo, sector_t hi)
{ {
struct md_cluster_info *cinfo = mddev->cluster_info; struct md_cluster_info *cinfo = mddev->cluster_info;
struct suspend_info *s;
struct mdp_superblock_1 *sb = NULL; struct mdp_superblock_1 *sb = NULL;
struct md_rdev *rdev; struct md_rdev *rdev;
...@@ -516,17 +497,11 @@ static void process_suspend_info(struct mddev *mddev, ...@@ -516,17 +497,11 @@ static void process_suspend_info(struct mddev *mddev,
cinfo->sync_low = lo; cinfo->sync_low = lo;
cinfo->sync_hi = hi; cinfo->sync_hi = hi;
s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL);
if (!s)
return;
s->slot = slot;
s->lo = lo;
s->hi = hi;
mddev->pers->quiesce(mddev, 1); mddev->pers->quiesce(mddev, 1);
spin_lock_irq(&cinfo->suspend_lock); spin_lock_irq(&cinfo->suspend_lock);
/* Remove existing entry (if exists) before adding */ cinfo->suspend_from = slot;
__remove_suspend_info(cinfo, slot); cinfo->suspend_lo = lo;
list_add(&s->list, &cinfo->suspend_list); cinfo->suspend_hi = hi;
spin_unlock_irq(&cinfo->suspend_lock); spin_unlock_irq(&cinfo->suspend_lock);
mddev->pers->quiesce(mddev, 0); mddev->pers->quiesce(mddev, 0);
} }
...@@ -825,7 +800,6 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots) ...@@ -825,7 +800,6 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots)
struct md_cluster_info *cinfo = mddev->cluster_info; struct md_cluster_info *cinfo = mddev->cluster_info;
int i, ret = 0; int i, ret = 0;
struct dlm_lock_resource *bm_lockres; struct dlm_lock_resource *bm_lockres;
struct suspend_info *s;
char str[64]; char str[64];
sector_t lo, hi; sector_t lo, hi;
...@@ -844,16 +818,13 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots) ...@@ -844,16 +818,13 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots)
bm_lockres->flags |= DLM_LKF_NOQUEUE; bm_lockres->flags |= DLM_LKF_NOQUEUE;
ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW); ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW);
if (ret == -EAGAIN) { if (ret == -EAGAIN) {
s = read_resync_info(mddev, bm_lockres); if (read_resync_info(mddev, bm_lockres)) {
if (s) {
pr_info("%s:%d Resync[%llu..%llu] in progress on %d\n", pr_info("%s:%d Resync[%llu..%llu] in progress on %d\n",
__func__, __LINE__, __func__, __LINE__,
(unsigned long long) s->lo, (unsigned long long) cinfo->suspend_lo,
(unsigned long long) s->hi, i); (unsigned long long) cinfo->suspend_hi,
spin_lock_irq(&cinfo->suspend_lock); i);
s->slot = i; cinfo->suspend_from = i;
list_add(&s->list, &cinfo->suspend_list);
spin_unlock_irq(&cinfo->suspend_lock);
} }
ret = 0; ret = 0;
lockres_free(bm_lockres); lockres_free(bm_lockres);
...@@ -1352,13 +1323,10 @@ static int resync_start(struct mddev *mddev) ...@@ -1352,13 +1323,10 @@ static int resync_start(struct mddev *mddev)
static void resync_info_get(struct mddev *mddev, sector_t *lo, sector_t *hi) static void resync_info_get(struct mddev *mddev, sector_t *lo, sector_t *hi)
{ {
struct md_cluster_info *cinfo = mddev->cluster_info; struct md_cluster_info *cinfo = mddev->cluster_info;
struct suspend_info *s;
spin_lock_irq(&cinfo->suspend_lock); spin_lock_irq(&cinfo->suspend_lock);
list_for_each_entry(s, &cinfo->suspend_list, list) { *lo = cinfo->suspend_lo;
*lo = s->lo; *hi = cinfo->suspend_hi;
*hi = s->hi;
}
spin_unlock_irq(&cinfo->suspend_lock); spin_unlock_irq(&cinfo->suspend_lock);
} }
...@@ -1414,21 +1382,14 @@ static int area_resyncing(struct mddev *mddev, int direction, ...@@ -1414,21 +1382,14 @@ static int area_resyncing(struct mddev *mddev, int direction,
{ {
struct md_cluster_info *cinfo = mddev->cluster_info; struct md_cluster_info *cinfo = mddev->cluster_info;
int ret = 0; int ret = 0;
struct suspend_info *s;
if ((direction == READ) && if ((direction == READ) &&
test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state)) test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state))
return 1; return 1;
spin_lock_irq(&cinfo->suspend_lock); spin_lock_irq(&cinfo->suspend_lock);
if (list_empty(&cinfo->suspend_list)) if (hi > cinfo->suspend_lo && lo < cinfo->suspend_hi)
goto out; ret = 1;
list_for_each_entry(s, &cinfo->suspend_list, list)
if (hi > s->lo && lo < s->hi) {
ret = 1;
break;
}
out:
spin_unlock_irq(&cinfo->suspend_lock); spin_unlock_irq(&cinfo->suspend_lock);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment