Commit 29ee7a4a authored by Jens Axboe's avatar Jens Axboe

Merge tag 'md-fixes-20230914' of...

Merge tag 'md-fixes-20230914' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into block-6.6

Pull MD fixes from Song:

"These commits fix a bugzilla report [1] and some recent issues in 6.5
 and 6.6.

 [1] https://bugzilla.kernel.org/show_bug.cgi?id=217798"

* tag 'md-fixes-20230914' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md:
  md: Put the right device in md_seq_next
  md/raid1: fix error: ISO C90 forbids mixed declarations
  md: fix warning for holder mismatch from export_rdev()
  md: don't dereference mddev after export_rdev()
parents 6be6d112 c8870379
...@@ -798,14 +798,14 @@ void mddev_unlock(struct mddev *mddev) ...@@ -798,14 +798,14 @@ void mddev_unlock(struct mddev *mddev)
} else } else
mutex_unlock(&mddev->reconfig_mutex); mutex_unlock(&mddev->reconfig_mutex);
md_wakeup_thread(mddev->thread);
wake_up(&mddev->sb_wait);
list_for_each_entry_safe(rdev, tmp, &delete, same_set) { list_for_each_entry_safe(rdev, tmp, &delete, same_set) {
list_del_init(&rdev->same_set); list_del_init(&rdev->same_set);
kobject_del(&rdev->kobj); kobject_del(&rdev->kobj);
export_rdev(rdev, mddev); export_rdev(rdev, mddev);
} }
md_wakeup_thread(mddev->thread);
wake_up(&mddev->sb_wait);
} }
EXPORT_SYMBOL_GPL(mddev_unlock); EXPORT_SYMBOL_GPL(mddev_unlock);
...@@ -2452,7 +2452,8 @@ static void export_rdev(struct md_rdev *rdev, struct mddev *mddev) ...@@ -2452,7 +2452,8 @@ static void export_rdev(struct md_rdev *rdev, struct mddev *mddev)
if (test_bit(AutoDetected, &rdev->flags)) if (test_bit(AutoDetected, &rdev->flags))
md_autodetect_dev(rdev->bdev->bd_dev); md_autodetect_dev(rdev->bdev->bd_dev);
#endif #endif
blkdev_put(rdev->bdev, mddev->external ? &claim_rdev : rdev); blkdev_put(rdev->bdev,
test_bit(Holder, &rdev->flags) ? rdev : &claim_rdev);
rdev->bdev = NULL; rdev->bdev = NULL;
kobject_put(&rdev->kobj); kobject_put(&rdev->kobj);
} }
...@@ -3632,6 +3633,7 @@ EXPORT_SYMBOL_GPL(md_rdev_init); ...@@ -3632,6 +3633,7 @@ EXPORT_SYMBOL_GPL(md_rdev_init);
static struct md_rdev *md_import_device(dev_t newdev, int super_format, int super_minor) static struct md_rdev *md_import_device(dev_t newdev, int super_format, int super_minor)
{ {
struct md_rdev *rdev; struct md_rdev *rdev;
struct md_rdev *holder;
sector_t size; sector_t size;
int err; int err;
...@@ -3646,8 +3648,15 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe ...@@ -3646,8 +3648,15 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
if (err) if (err)
goto out_clear_rdev; goto out_clear_rdev;
if (super_format == -2) {
holder = &claim_rdev;
} else {
holder = rdev;
set_bit(Holder, &rdev->flags);
}
rdev->bdev = blkdev_get_by_dev(newdev, BLK_OPEN_READ | BLK_OPEN_WRITE, rdev->bdev = blkdev_get_by_dev(newdev, BLK_OPEN_READ | BLK_OPEN_WRITE,
super_format == -2 ? &claim_rdev : rdev, NULL); holder, NULL);
if (IS_ERR(rdev->bdev)) { if (IS_ERR(rdev->bdev)) {
pr_warn("md: could not open device unknown-block(%u,%u).\n", pr_warn("md: could not open device unknown-block(%u,%u).\n",
MAJOR(newdev), MINOR(newdev)); MAJOR(newdev), MINOR(newdev));
...@@ -3684,7 +3693,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe ...@@ -3684,7 +3693,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
return rdev; return rdev;
out_blkdev_put: out_blkdev_put:
blkdev_put(rdev->bdev, super_format == -2 ? &claim_rdev : rdev); blkdev_put(rdev->bdev, holder);
out_clear_rdev: out_clear_rdev:
md_rdev_clear(rdev); md_rdev_clear(rdev);
out_free_rdev: out_free_rdev:
...@@ -8256,7 +8265,7 @@ static void *md_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -8256,7 +8265,7 @@ static void *md_seq_next(struct seq_file *seq, void *v, loff_t *pos)
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
if (to_put) if (to_put)
mddev_put(mddev); mddev_put(to_put);
return next_mddev; return next_mddev;
} }
......
...@@ -211,6 +211,9 @@ enum flag_bits { ...@@ -211,6 +211,9 @@ enum flag_bits {
* check if there is collision between raid1 * check if there is collision between raid1
* serial bios. * serial bios.
*/ */
Holder, /* rdev is used as holder while opening
* underlying disk exclusively.
*/
}; };
static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors, static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors,
......
...@@ -1837,12 +1837,11 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1837,12 +1837,11 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
struct r1conf *conf = mddev->private; struct r1conf *conf = mddev->private;
int err = 0; int err = 0;
int number = rdev->raid_disk; int number = rdev->raid_disk;
struct raid1_info *p = conf->mirrors + number;
if (unlikely(number >= conf->raid_disks)) if (unlikely(number >= conf->raid_disks))
goto abort; goto abort;
struct raid1_info *p = conf->mirrors + number;
if (rdev != p->rdev) if (rdev != p->rdev)
p = conf->mirrors + conf->raid_disks + number; p = conf->mirrors + conf->raid_disks + number;
......
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