md.c (9d66a875ecc7d6dd414121e4508340d6c08f51b0) md.c (1532d9e87e8b2377f12929f9e40724d5fbe6ecc5)
1/*
2 md.c : Multiple Devices driver for Linux
3 Copyright (C) 1998, 1999, 2000 Ingo Molnar
4
5 completely rewritten, based on the MD driver code from Marc Zyngier
6
7 Changes:
8

--- 697 unchanged lines hidden (view full) ---

706
707 rdev_for_each(rdev, mddev)
708 if (rdev->bdev->bd_dev == dev)
709 return rdev;
710
711 return NULL;
712}
713
1/*
2 md.c : Multiple Devices driver for Linux
3 Copyright (C) 1998, 1999, 2000 Ingo Molnar
4
5 completely rewritten, based on the MD driver code from Marc Zyngier
6
7 Changes:
8

--- 697 unchanged lines hidden (view full) ---

706
707 rdev_for_each(rdev, mddev)
708 if (rdev->bdev->bd_dev == dev)
709 return rdev;
710
711 return NULL;
712}
713
714static struct md_rdev *find_rdev_rcu(struct mddev *mddev, dev_t dev)
714struct md_rdev *md_find_rdev_rcu(struct mddev *mddev, dev_t dev)
715{
716 struct md_rdev *rdev;
717
718 rdev_for_each_rcu(rdev, mddev)
719 if (rdev->bdev->bd_dev == dev)
720 return rdev;
721
722 return NULL;
723}
715{
716 struct md_rdev *rdev;
717
718 rdev_for_each_rcu(rdev, mddev)
719 if (rdev->bdev->bd_dev == dev)
720 return rdev;
721
722 return NULL;
723}
724EXPORT_SYMBOL_GPL(md_find_rdev_rcu);
724
725static struct md_personality *find_pers(int level, char *clevel)
726{
727 struct md_personality *pers;
728 list_for_each_entry(pers, &pers_list, list) {
729 if (level != LEVEL_NONE && pers->level == level)
730 return pers;
731 if (strcmp(pers->name, clevel)==0)

--- 4823 unchanged lines hidden (view full) ---

5555 /* may be over-ridden by personality */
5556 mddev->resync_max_sectors = mddev->dev_sectors;
5557
5558 mddev->ok_start_degraded = start_dirty_degraded;
5559
5560 if (start_readonly && mddev->ro == 0)
5561 mddev->ro = 2; /* read-only, but switch on first write */
5562
725
726static struct md_personality *find_pers(int level, char *clevel)
727{
728 struct md_personality *pers;
729 list_for_each_entry(pers, &pers_list, list) {
730 if (level != LEVEL_NONE && pers->level == level)
731 return pers;
732 if (strcmp(pers->name, clevel)==0)

--- 4823 unchanged lines hidden (view full) ---

5556 /* may be over-ridden by personality */
5557 mddev->resync_max_sectors = mddev->dev_sectors;
5558
5559 mddev->ok_start_degraded = start_dirty_degraded;
5560
5561 if (start_readonly && mddev->ro == 0)
5562 mddev->ro = 2; /* read-only, but switch on first write */
5563
5563 /*
5564 * NOTE: some pers->run(), for example r5l_recovery_log(), wakes
5565 * up mddev->thread. It is important to initialize critical
5566 * resources for mddev->thread BEFORE calling pers->run().
5567 */
5568 err = pers->run(mddev);
5569 if (err)
5570 pr_warn("md: pers->run() failed ...\n");
5571 else if (pers->size(mddev, 0, 0) < mddev->array_sectors) {
5572 WARN_ONCE(!mddev->external_size,
5573 "%s: default size too small, but 'external_size' not in effect?\n",
5574 __func__);
5575 pr_warn("md: invalid array_size %llu > default size %llu\n",

--- 97 unchanged lines hidden (view full) ---

5673 if (err) {
5674 bitmap_destroy(mddev);
5675 goto out;
5676 }
5677
5678 if (mddev_is_clustered(mddev))
5679 md_allow_write(mddev);
5680
5564 err = pers->run(mddev);
5565 if (err)
5566 pr_warn("md: pers->run() failed ...\n");
5567 else if (pers->size(mddev, 0, 0) < mddev->array_sectors) {
5568 WARN_ONCE(!mddev->external_size,
5569 "%s: default size too small, but 'external_size' not in effect?\n",
5570 __func__);
5571 pr_warn("md: invalid array_size %llu > default size %llu\n",

--- 97 unchanged lines hidden (view full) ---

5669 if (err) {
5670 bitmap_destroy(mddev);
5671 goto out;
5672 }
5673
5674 if (mddev_is_clustered(mddev))
5675 md_allow_write(mddev);
5676
5677 /* run start up tasks that require md_thread */
5678 md_start(mddev);
5679
5681 md_wakeup_thread(mddev->thread);
5682 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
5683
5684 set_capacity(mddev->gendisk, mddev->array_sectors);
5685 revalidate_disk(mddev->gendisk);
5686 mddev->changed = 1;
5687 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
5688out:
5689 return err;
5690}
5691
5680 md_wakeup_thread(mddev->thread);
5681 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
5682
5683 set_capacity(mddev->gendisk, mddev->array_sectors);
5684 revalidate_disk(mddev->gendisk);
5685 mddev->changed = 1;
5686 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
5687out:
5688 return err;
5689}
5690
5691int md_start(struct mddev *mddev)
5692{
5693 int ret = 0;
5694
5695 if (mddev->pers->start) {
5696 set_bit(MD_RECOVERY_WAIT, &mddev->recovery);
5697 md_wakeup_thread(mddev->thread);
5698 ret = mddev->pers->start(mddev);
5699 clear_bit(MD_RECOVERY_WAIT, &mddev->recovery);
5700 md_wakeup_thread(mddev->sync_thread);
5701 }
5702 return ret;
5703}
5704EXPORT_SYMBOL_GPL(md_start);
5705
5692static int restart_array(struct mddev *mddev)
5693{
5694 struct gendisk *disk = mddev->gendisk;
5695 struct md_rdev *rdev;
5696 bool has_journal = false;
5697 bool has_readonly = false;
5698
5699 /* Complain if it has no devices */

--- 1292 unchanged lines hidden (view full) ---

6992{
6993 struct md_rdev *rdev;
6994 int err = 0;
6995
6996 if (mddev->pers == NULL)
6997 return -ENODEV;
6998
6999 rcu_read_lock();
5706static int restart_array(struct mddev *mddev)
5707{
5708 struct gendisk *disk = mddev->gendisk;
5709 struct md_rdev *rdev;
5710 bool has_journal = false;
5711 bool has_readonly = false;
5712
5713 /* Complain if it has no devices */

--- 1292 unchanged lines hidden (view full) ---

7006{
7007 struct md_rdev *rdev;
7008 int err = 0;
7009
7010 if (mddev->pers == NULL)
7011 return -ENODEV;
7012
7013 rcu_read_lock();
7000 rdev = find_rdev_rcu(mddev, dev);
7014 rdev = md_find_rdev_rcu(mddev, dev);
7001 if (!rdev)
7002 err = -ENODEV;
7003 else {
7004 md_error(mddev, rdev);
7005 if (!test_bit(Faulty, &rdev->flags))
7006 err = -EBUSY;
7007 }
7008 rcu_read_unlock();

--- 1155 unchanged lines hidden (view full) ---

8164 sector_t last_check;
8165 int skipped = 0;
8166 struct md_rdev *rdev;
8167 char *desc, *action = NULL;
8168 struct blk_plug plug;
8169 int ret;
8170
8171 /* just incase thread restarts... */
7015 if (!rdev)
7016 err = -ENODEV;
7017 else {
7018 md_error(mddev, rdev);
7019 if (!test_bit(Faulty, &rdev->flags))
7020 err = -EBUSY;
7021 }
7022 rcu_read_unlock();

--- 1155 unchanged lines hidden (view full) ---

8178 sector_t last_check;
8179 int skipped = 0;
8180 struct md_rdev *rdev;
8181 char *desc, *action = NULL;
8182 struct blk_plug plug;
8183 int ret;
8184
8185 /* just incase thread restarts... */
8172 if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
8186 if (test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
8187 test_bit(MD_RECOVERY_WAIT, &mddev->recovery))
8173 return;
8174 if (mddev->ro) {/* never try to sync a read-only array */
8175 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
8176 return;
8177 }
8178
8179 if (mddev_is_clustered(mddev)) {
8180 ret = md_cluster_ops->resync_start(mddev);

--- 1156 unchanged lines hidden ---
8188 return;
8189 if (mddev->ro) {/* never try to sync a read-only array */
8190 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
8191 return;
8192 }
8193
8194 if (mddev_is_clustered(mddev)) {
8195 ret = md_cluster_ops->resync_start(mddev);

--- 1156 unchanged lines hidden ---