Skip to content

Commit

Permalink
Merge tag 'md/4.6-rc2-fix' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/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
  • Loading branch information
Linus Torvalds committed Apr 9, 2016
2 parents 40bca9d + f9a67b1 commit 63b106a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
19 changes: 11 additions & 8 deletions drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,9 @@ static void bitmap_free(struct bitmap *bitmap)
if (!bitmap) /* there was no bitmap */
return;

if (bitmap->sysfs_can_clear)
sysfs_put(bitmap->sysfs_can_clear);

if (mddev_is_clustered(bitmap->mddev) && bitmap->mddev->cluster_info &&
bitmap->cluster_slot == md_cluster_ops->slot_number(bitmap->mddev))
md_cluster_stop(bitmap->mddev);
Expand Down Expand Up @@ -1712,15 +1715,13 @@ void bitmap_destroy(struct mddev *mddev)
if (mddev->thread)
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;

if (bitmap->sysfs_can_clear)
sysfs_put(bitmap->sysfs_can_clear);

bitmap_free(bitmap);
}

/*
* initialize the bitmap structure
* if this returns an error, bitmap_destroy must be called to do clean up
* once mddev->bitmap is set
*/
struct bitmap *bitmap_create(struct mddev *mddev, int slot)
{
Expand Down Expand Up @@ -1865,8 +1866,10 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
struct bitmap_counts *counts;
struct bitmap *bitmap = bitmap_create(mddev, slot);

if (IS_ERR(bitmap))
if (IS_ERR(bitmap)) {
bitmap_free(bitmap);
return PTR_ERR(bitmap);
}

rv = bitmap_init_from_disk(bitmap, 0);
if (rv)
Expand Down Expand Up @@ -2170,14 +2173,14 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
else {
mddev->bitmap = bitmap;
rv = bitmap_load(mddev);
if (rv) {
bitmap_destroy(mddev);
if (rv)
mddev->bitmap_info.offset = 0;
}
}
mddev->pers->quiesce(mddev, 0);
if (rv)
if (rv) {
bitmap_destroy(mddev);
return rv;
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ static void super_written(struct bio *bio)

if (atomic_dec_and_test(&mddev->pending_writes))
wake_up(&mddev->sb_wait);
rdev_dec_pending(rdev, mddev);
bio_put(bio);
}

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

atomic_inc(&rdev->nr_pending);

bio->bi_bdev = rdev->meta_bdev ? rdev->meta_bdev : rdev->bdev;
bio->bi_iter.bi_sector = sector;
bio_add_page(bio, page, size, 0);
Expand Down Expand Up @@ -6883,7 +6886,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,

case ADD_NEW_DISK:
/* We can support ADD_NEW_DISK on read-only arrays
* on if we are re-adding a preexisting device.
* only if we are re-adding a preexisting device.
* So require mddev->pers and MD_DISK_SYNC.
*/
if (mddev->pers) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
if (best_dist_disk < 0) {
if (is_badblock(rdev, this_sector, sectors,
&first_bad, &bad_sectors)) {
if (first_bad < this_sector)
if (first_bad <= this_sector)
/* Cannot use this */
continue;
best_good_sectors = first_bad - this_sector;
Expand Down

0 comments on commit 63b106a

Please sign in to comment.