Skip to content

Commit 63b106a

Browse files
committed
Merge tag 'md/4.6-rc2-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
Pull MD fixes from Shaohua Li: "This update mainly fixes bugs: - fix error handling (Guoqing) - fix a crash when a disk is hotremoved (me) - fix a dead loop (Wei Fang)" * tag 'md/4.6-rc2-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md: md/bitmap: clear bitmap if bitmap_create failed MD: add rdev reference for super write md: fix a trivial typo in comments md:raid1: fix a dead loop when read from a WriteMostly disk
2 parents 40bca9d + f9a67b1 commit 63b106a

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

drivers/md/bitmap.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,9 @@ static void bitmap_free(struct bitmap *bitmap)
16731673
if (!bitmap) /* there was no bitmap */
16741674
return;
16751675

1676+
if (bitmap->sysfs_can_clear)
1677+
sysfs_put(bitmap->sysfs_can_clear);
1678+
16761679
if (mddev_is_clustered(bitmap->mddev) && bitmap->mddev->cluster_info &&
16771680
bitmap->cluster_slot == md_cluster_ops->slot_number(bitmap->mddev))
16781681
md_cluster_stop(bitmap->mddev);
@@ -1712,15 +1715,13 @@ void bitmap_destroy(struct mddev *mddev)
17121715
if (mddev->thread)
17131716
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
17141717

1715-
if (bitmap->sysfs_can_clear)
1716-
sysfs_put(bitmap->sysfs_can_clear);
1717-
17181718
bitmap_free(bitmap);
17191719
}
17201720

17211721
/*
17221722
* initialize the bitmap structure
17231723
* if this returns an error, bitmap_destroy must be called to do clean up
1724+
* once mddev->bitmap is set
17241725
*/
17251726
struct bitmap *bitmap_create(struct mddev *mddev, int slot)
17261727
{
@@ -1865,8 +1866,10 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
18651866
struct bitmap_counts *counts;
18661867
struct bitmap *bitmap = bitmap_create(mddev, slot);
18671868

1868-
if (IS_ERR(bitmap))
1869+
if (IS_ERR(bitmap)) {
1870+
bitmap_free(bitmap);
18691871
return PTR_ERR(bitmap);
1872+
}
18701873

18711874
rv = bitmap_init_from_disk(bitmap, 0);
18721875
if (rv)
@@ -2170,14 +2173,14 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
21702173
else {
21712174
mddev->bitmap = bitmap;
21722175
rv = bitmap_load(mddev);
2173-
if (rv) {
2174-
bitmap_destroy(mddev);
2176+
if (rv)
21752177
mddev->bitmap_info.offset = 0;
2176-
}
21772178
}
21782179
mddev->pers->quiesce(mddev, 0);
2179-
if (rv)
2180+
if (rv) {
2181+
bitmap_destroy(mddev);
21802182
return rv;
2183+
}
21812184
}
21822185
}
21832186
}

drivers/md/md.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ static void super_written(struct bio *bio)
718718

719719
if (atomic_dec_and_test(&mddev->pending_writes))
720720
wake_up(&mddev->sb_wait);
721+
rdev_dec_pending(rdev, mddev);
721722
bio_put(bio);
722723
}
723724

@@ -732,6 +733,8 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev,
732733
*/
733734
struct bio *bio = bio_alloc_mddev(GFP_NOIO, 1, mddev);
734735

736+
atomic_inc(&rdev->nr_pending);
737+
735738
bio->bi_bdev = rdev->meta_bdev ? rdev->meta_bdev : rdev->bdev;
736739
bio->bi_iter.bi_sector = sector;
737740
bio_add_page(bio, page, size, 0);
@@ -6883,7 +6886,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
68836886

68846887
case ADD_NEW_DISK:
68856888
/* We can support ADD_NEW_DISK on read-only arrays
6886-
* on if we are re-adding a preexisting device.
6889+
* only if we are re-adding a preexisting device.
68876890
* So require mddev->pers and MD_DISK_SYNC.
68886891
*/
68896892
if (mddev->pers) {

drivers/md/raid1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
570570
if (best_dist_disk < 0) {
571571
if (is_badblock(rdev, this_sector, sectors,
572572
&first_bad, &bad_sectors)) {
573-
if (first_bad < this_sector)
573+
if (first_bad <= this_sector)
574574
/* Cannot use this */
575575
continue;
576576
best_good_sectors = first_bad - this_sector;

0 commit comments

Comments
 (0)