4 fixes for md in 4.4-rc5

- 2 recently introduced regressions fixed.
 - one older bug in RAID10 - tagged for -stable since 4.2
 - one minor sysfs api improvement.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJWddZIAAoJEDnsnt1WYoG5L/AQAMBmdj4kQiqVq/y4q26+V79d
 W4AVgmGJLRuya1Xy1yN58TIrG7TLWRciH7q/P21g9AIFEso3wU42PNwvDjYG4xRN
 XzovJA91xmRkz2RSxaDs45kxpaOCB2ED+VgdMn4+VLAl23I0oI/gdGxJfs/OBuWI
 OoG09gNCJXhuZETFRqtlH9BZb+QAfYWdJOKbHXvrXDJlevWmz1Oav+QO+V3rAWRu
 nnupsrlLL9GxvS51oSV7PmRcFFNa03AHDNelUPxdlPrQosi5CgH27SVlxygJtFBP
 djyq4NKFXAD0sTsqeleJ9Ib7D0HZ/P84GC68NNILEDbjdu8kMGWeC8FZ4rXuxRCf
 VARBF+H/647uxfjZfKUwqTZsYYPPANkr6gK8jKgiuo0gc8V1lgF53OsokeWkCPZN
 nvDpS9MYrhKB8m7VO3KL1cIgu9fee2vnJLjf8wsNh2N9SDkBCz+7vENjbfbAyKAz
 V2H97Mgw1UQSnOcsvfVv0r4TmMFUcCslujFyjQu7A83NTWZ/ICGkRVUKP7tK8pc6
 fQ6MG1vIdPzhVduOrTjlTr9eT/4Sk1ofl1LOFC7gnN6vHhubzOfcuwrDWgnqVGiE
 0BY0NVsa7f6tzjA6h9pDjnFjdF6uM4QGEgfnLBmRJ8ehwvXBwH6CJUbIBhDWHhj1
 rrm2LYiEuA1nWfWEpD8x
 =nHNn
 -----END PGP SIGNATURE-----

Merge tag 'md/4.4-rc5-fixes' of git://neil.brown.name/md

Pull md fixes from Neil Brown:
 "Four fixes for md:

   - two recently introduced regressions fixed.
   - one older bug in RAID10 - tagged for -stable since 4.2
   - one minor sysfs api improvement"

* tag 'md/4.4-rc5-fixes' of git://neil.brown.name/md:
  Fix remove_and_add_spares removes drive added as spare in slot_store
  md: fix bug due to nested suspend
  MD: change journal disk role to disk 0
  md/raid10: fix data corruption and crash during resync
This commit is contained in:
Linus Torvalds 2015-12-19 16:46:46 -08:00
commit 3a87711e58
3 changed files with 24 additions and 10 deletions

View file

@ -314,8 +314,8 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
*/
void mddev_suspend(struct mddev *mddev)
{
BUG_ON(mddev->suspended);
mddev->suspended = 1;
if (mddev->suspended++)
return;
synchronize_rcu();
wait_event(mddev->sb_wait, atomic_read(&mddev->active_io) == 0);
mddev->pers->quiesce(mddev, 1);
@ -326,7 +326,8 @@ EXPORT_SYMBOL_GPL(mddev_suspend);
void mddev_resume(struct mddev *mddev)
{
mddev->suspended = 0;
if (--mddev->suspended)
return;
wake_up(&mddev->sb_wait);
mddev->pers->quiesce(mddev, 0);
@ -1652,7 +1653,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
rdev->journal_tail = le64_to_cpu(sb->journal_tail);
if (mddev->recovery_cp == MaxSector)
set_bit(MD_JOURNAL_CLEAN, &mddev->flags);
rdev->raid_disk = mddev->raid_disks;
rdev->raid_disk = 0;
break;
default:
rdev->saved_raid_disk = role;
@ -2773,6 +2774,7 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
/* Activating a spare .. or possibly reactivating
* if we ever get bitmaps working here.
*/
int err;
if (rdev->raid_disk != -1)
return -EBUSY;
@ -2794,9 +2796,15 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
rdev->saved_raid_disk = -1;
clear_bit(In_sync, &rdev->flags);
clear_bit(Bitmap_sync, &rdev->flags);
remove_and_add_spares(rdev->mddev, rdev);
if (rdev->raid_disk == -1)
return -EBUSY;
err = rdev->mddev->pers->
hot_add_disk(rdev->mddev, rdev);
if (err) {
rdev->raid_disk = -1;
return err;
} else
sysfs_notify_dirent_safe(rdev->sysfs_state);
if (sysfs_link_rdev(rdev->mddev, rdev))
/* failure here is OK */;
/* don't wakeup anyone, leave that to userspace. */
} else {
if (slot >= rdev->mddev->raid_disks &&

View file

@ -566,7 +566,9 @@ static inline char * mdname (struct mddev * mddev)
static inline int sysfs_link_rdev(struct mddev *mddev, struct md_rdev *rdev)
{
char nm[20];
if (!test_bit(Replacement, &rdev->flags) && mddev->kobj.sd) {
if (!test_bit(Replacement, &rdev->flags) &&
!test_bit(Journal, &rdev->flags) &&
mddev->kobj.sd) {
sprintf(nm, "rd%d", rdev->raid_disk);
return sysfs_create_link(&mddev->kobj, &rdev->kobj, nm);
} else
@ -576,7 +578,9 @@ static inline int sysfs_link_rdev(struct mddev *mddev, struct md_rdev *rdev)
static inline void sysfs_unlink_rdev(struct mddev *mddev, struct md_rdev *rdev)
{
char nm[20];
if (!test_bit(Replacement, &rdev->flags) && mddev->kobj.sd) {
if (!test_bit(Replacement, &rdev->flags) &&
!test_bit(Journal, &rdev->flags) &&
mddev->kobj.sd) {
sprintf(nm, "rd%d", rdev->raid_disk);
sysfs_remove_link(&mddev->kobj, nm);
}

View file

@ -1946,6 +1946,8 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
first = i;
fbio = r10_bio->devs[i].bio;
fbio->bi_iter.bi_size = r10_bio->sectors << 9;
fbio->bi_iter.bi_idx = 0;
vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9);
/* now find blocks with errors */
@ -1989,7 +1991,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
bio_reset(tbio);
tbio->bi_vcnt = vcnt;
tbio->bi_iter.bi_size = r10_bio->sectors << 9;
tbio->bi_iter.bi_size = fbio->bi_iter.bi_size;
tbio->bi_rw = WRITE;
tbio->bi_private = r10_bio;
tbio->bi_iter.bi_sector = r10_bio->devs[i].addr;