Skip to content

Commit b219a1d

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
Pull MD updates from Shaohua Li: "A few MD fixes for 4.19-rc1: - several md-cluster fixes from Guoqing - a data corruption fix from BingJing - other cleanups" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md: md/raid5: fix data corruption of replacements after originals dropped drivers/md/raid5: Do not disable irq on release_inactive_stripe_list() call drivers/md/raid5: Use irqsave variant of atomic_dec_and_lock() md/r5cache: remove redundant pointer bio md-cluster: don't send msg if array is closing md-cluster: show array's status more accurate md-cluster: clear another node's suspend_area after the copy is finished
2 parents c2fc71c + d63e2fc commit b219a1d

5 files changed

Lines changed: 61 additions & 18 deletions

File tree

‎drivers/md/md-cluster.c‎

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,6 @@ static void recover_bitmaps(struct md_thread *thread)
304304
while (cinfo->recovery_map) {
305305
slot = fls64((u64)cinfo->recovery_map) - 1;
306306

307-
/* Clear suspend_area associated with the bitmap */
308-
spin_lock_irq(&cinfo->suspend_lock);
309-
list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
310-
if (slot == s->slot) {
311-
list_del(&s->list);
312-
kfree(s);
313-
}
314-
spin_unlock_irq(&cinfo->suspend_lock);
315-
316307
snprintf(str, 64, "bitmap%04d", slot);
317308
bm_lockres = lockres_init(mddev, str, NULL, 1);
318309
if (!bm_lockres) {
@@ -331,14 +322,30 @@ static void recover_bitmaps(struct md_thread *thread)
331322
pr_err("md-cluster: Could not copy data from bitmap %d\n", slot);
332323
goto clear_bit;
333324
}
325+
326+
/* Clear suspend_area associated with the bitmap */
327+
spin_lock_irq(&cinfo->suspend_lock);
328+
list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
329+
if (slot == s->slot) {
330+
list_del(&s->list);
331+
kfree(s);
332+
}
333+
spin_unlock_irq(&cinfo->suspend_lock);
334+
334335
if (hi > 0) {
335336
if (lo < mddev->recovery_cp)
336337
mddev->recovery_cp = lo;
337338
/* wake up thread to continue resync in case resync
338339
* is not finished */
339340
if (mddev->recovery_cp != MaxSector) {
340-
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
341-
md_wakeup_thread(mddev->thread);
341+
/*
342+
* clear the REMOTE flag since we will launch
343+
* resync thread in current node.
344+
*/
345+
clear_bit(MD_RESYNCING_REMOTE,
346+
&mddev->recovery);
347+
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
348+
md_wakeup_thread(mddev->thread);
342349
}
343350
}
344351
clear_bit:
@@ -457,6 +464,11 @@ static void process_suspend_info(struct mddev *mddev,
457464
struct suspend_info *s;
458465

459466
if (!hi) {
467+
/*
468+
* clear the REMOTE flag since resync or recovery is finished
469+
* in remote node.
470+
*/
471+
clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
460472
remove_suspend_info(mddev, slot);
461473
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
462474
md_wakeup_thread(mddev->thread);
@@ -585,6 +597,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
585597
revalidate_disk(mddev->gendisk);
586598
break;
587599
case RESYNCING:
600+
set_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
588601
process_suspend_info(mddev, le32_to_cpu(msg->slot),
589602
le64_to_cpu(msg->low),
590603
le64_to_cpu(msg->high));
@@ -1265,8 +1278,18 @@ static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi)
12651278
static int resync_finish(struct mddev *mddev)
12661279
{
12671280
struct md_cluster_info *cinfo = mddev->cluster_info;
1281+
1282+
clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
12681283
dlm_unlock_sync(cinfo->resync_lockres);
1269-
return resync_info_update(mddev, 0, 0);
1284+
1285+
/*
1286+
* If resync thread is interrupted so we can't say resync is finished,
1287+
* another node will launch resync thread to continue.
1288+
*/
1289+
if (test_bit(MD_CLOSING, &mddev->flags))
1290+
return 0;
1291+
else
1292+
return resync_info_update(mddev, 0, 0);
12701293
}
12711294

12721295
static int area_resyncing(struct mddev *mddev, int direction,

‎drivers/md/md.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7677,6 +7677,23 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
76777677
resync -= atomic_read(&mddev->recovery_active);
76787678

76797679
if (resync == 0) {
7680+
if (test_bit(MD_RESYNCING_REMOTE, &mddev->recovery)) {
7681+
struct md_rdev *rdev;
7682+
7683+
rdev_for_each(rdev, mddev)
7684+
if (rdev->raid_disk >= 0 &&
7685+
!test_bit(Faulty, &rdev->flags) &&
7686+
rdev->recovery_offset != MaxSector &&
7687+
rdev->recovery_offset) {
7688+
seq_printf(seq, "\trecover=REMOTE");
7689+
return 1;
7690+
}
7691+
if (mddev->reshape_position != MaxSector)
7692+
seq_printf(seq, "\treshape=REMOTE");
7693+
else
7694+
seq_printf(seq, "\tresync=REMOTE");
7695+
return 1;
7696+
}
76807697
if (mddev->recovery_cp < MaxSector) {
76817698
seq_printf(seq, "\tresync=PENDING");
76827699
return 1;

‎drivers/md/md.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ enum recovery_flags {
496496
MD_RECOVERY_FROZEN, /* User request to abort, and not restart, any action */
497497
MD_RECOVERY_ERROR, /* sync-action interrupted because io-error */
498498
MD_RECOVERY_WAIT, /* waiting for pers->start() to finish */
499+
MD_RESYNCING_REMOTE, /* remote node is running resync thread */
499500
};
500501

501502
static inline int __must_check mddev_lock(struct mddev *mddev)

‎drivers/md/raid5-cache.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,6 @@ static void r5c_disable_writeback_async(struct work_struct *work)
717717
static void r5l_submit_current_io(struct r5l_log *log)
718718
{
719719
struct r5l_io_unit *io = log->current_io;
720-
struct bio *bio;
721720
struct r5l_meta_block *block;
722721
unsigned long flags;
723722
u32 crc;
@@ -730,7 +729,6 @@ static void r5l_submit_current_io(struct r5l_log *log)
730729
block->meta_size = cpu_to_le32(io->meta_offset);
731730
crc = crc32c_le(log->uuid_checksum, block, PAGE_SIZE);
732731
block->checksum = cpu_to_le32(crc);
733-
bio = io->current_bio;
734732

735733
log->current_io = NULL;
736734
spin_lock_irqsave(&log->io_list_lock, flags);

‎drivers/md/raid5.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,14 @@ void raid5_release_stripe(struct stripe_head *sh)
409409
md_wakeup_thread(conf->mddev->thread);
410410
return;
411411
slow_path:
412-
local_irq_save(flags);
413412
/* we are ok here if STRIPE_ON_RELEASE_LIST is set or not */
414-
if (atomic_dec_and_lock(&sh->count, &conf->device_lock)) {
413+
if (atomic_dec_and_lock_irqsave(&sh->count, &conf->device_lock, flags)) {
415414
INIT_LIST_HEAD(&list);
416415
hash = sh->hash_lock_index;
417416
do_release_stripe(conf, sh, &list);
418-
spin_unlock(&conf->device_lock);
417+
spin_unlock_irqrestore(&conf->device_lock, flags);
419418
release_inactive_stripe_list(conf, &list, hash);
420419
}
421-
local_irq_restore(flags);
422420
}
423421

424422
static inline void remove_hash(struct stripe_head *sh)
@@ -4521,6 +4519,12 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
45214519
s->failed++;
45224520
if (rdev && !test_bit(Faulty, &rdev->flags))
45234521
do_recovery = 1;
4522+
else if (!rdev) {
4523+
rdev = rcu_dereference(
4524+
conf->disks[i].replacement);
4525+
if (rdev && !test_bit(Faulty, &rdev->flags))
4526+
do_recovery = 1;
4527+
}
45244528
}
45254529

45264530
if (test_bit(R5_InJournal, &dev->flags))

0 commit comments

Comments
 (0)