Commit f3ddcd6b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] raid ->diskop() splitup

	* ->diskop() split into individual methods; prototypes cleaned
up.  In particular, handling of hot_add_disk() gets mdk_rdev_t * of
the component we are adding as an argument instead of playing the games
with major/minor.  Code cleaned up.
parent 480f4106
...@@ -1741,8 +1741,7 @@ static int do_md_stop(mddev_t * mddev, int ro) ...@@ -1741,8 +1741,7 @@ static int do_md_stop(mddev_t * mddev, int ro)
md_unregister_thread(mddev->sync_thread); md_unregister_thread(mddev->sync_thread);
mddev->sync_thread = NULL; mddev->sync_thread = NULL;
if (mddev->spare) { if (mddev->spare) {
mddev->pers->diskop(mddev, &mddev->spare, mddev->pers->spare_inactive(mddev);
DISKOP_SPARE_INACTIVE);
mddev->spare = NULL; mddev->spare = NULL;
} }
} }
...@@ -2250,7 +2249,7 @@ static int hot_remove_disk(mddev_t * mddev, kdev_t dev) ...@@ -2250,7 +2249,7 @@ static int hot_remove_disk(mddev_t * mddev, kdev_t dev)
printk(KERN_INFO "md: trying to remove %s from md%d ... \n", printk(KERN_INFO "md: trying to remove %s from md%d ... \n",
partition_name(dev), mdidx(mddev)); partition_name(dev), mdidx(mddev));
if (!mddev->pers->diskop) { if (!mddev->pers->hot_remove_disk) {
printk(KERN_WARNING "md%d: personality does not support diskops!\n", printk(KERN_WARNING "md%d: personality does not support diskops!\n",
mdidx(mddev)); mdidx(mddev));
return -EINVAL; return -EINVAL;
...@@ -2274,7 +2273,7 @@ static int hot_remove_disk(mddev_t * mddev, kdev_t dev) ...@@ -2274,7 +2273,7 @@ static int hot_remove_disk(mddev_t * mddev, kdev_t dev)
return -EINVAL; return -EINVAL;
} }
err = mddev->pers->diskop(mddev, &disk, DISKOP_HOT_REMOVE_DISK); err = mddev->pers->hot_remove_disk(mddev, disk->number);
if (err == -EBUSY) { if (err == -EBUSY) {
MD_BUG(); MD_BUG();
goto busy; goto busy;
...@@ -2308,7 +2307,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev) ...@@ -2308,7 +2307,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev)
printk(KERN_INFO "md: trying to hot-add %s to md%d ... \n", printk(KERN_INFO "md: trying to hot-add %s to md%d ... \n",
partition_name(dev), mdidx(mddev)); partition_name(dev), mdidx(mddev));
if (!mddev->pers->diskop) { if (!mddev->pers->hot_add_disk) {
printk(KERN_WARNING "md%d: personality does not support diskops!\n", printk(KERN_WARNING "md%d: personality does not support diskops!\n",
mdidx(mddev)); mdidx(mddev));
return -EINVAL; return -EINVAL;
...@@ -2388,7 +2387,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev) ...@@ -2388,7 +2387,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev)
disk->major = major(dev); disk->major = major(dev);
disk->minor = minor(dev); disk->minor = minor(dev);
if (mddev->pers->diskop(mddev, &disk, DISKOP_HOT_ADD_DISK)) { if (mddev->pers->hot_add_disk(mddev, disk, rdev)) {
MD_BUG(); MD_BUG();
err = -EINVAL; err = -EINVAL;
goto abort_unbind_export; goto abort_unbind_export;
...@@ -3370,7 +3369,7 @@ void md_do_recovery(void *data) ...@@ -3370,7 +3369,7 @@ void md_do_recovery(void *data)
ITERATE_MDDEV(mddev,tmp) if (mddev_lock(mddev)==0) { ITERATE_MDDEV(mddev,tmp) if (mddev_lock(mddev)==0) {
sb = mddev->sb; sb = mddev->sb;
if (!sb || !mddev->pers || !mddev->pers->diskop || mddev->ro) if (!sb || !mddev->pers || mddev->ro)
goto unlock; goto unlock;
if (mddev->recovery_running > 0) if (mddev->recovery_running > 0)
/* resync/recovery still happening */ /* resync/recovery still happening */
...@@ -3384,16 +3383,19 @@ void md_do_recovery(void *data) ...@@ -3384,16 +3383,19 @@ void md_do_recovery(void *data)
* If we were doing a reconstruction, * If we were doing a reconstruction,
* we need to retrieve the spare * we need to retrieve the spare
*/ */
if (!mddev->pers->spare_inactive)
goto unlock;
if (mddev->spare) { if (mddev->spare) {
mddev->pers->diskop(mddev, &mddev->spare, mddev->pers->spare_inactive(mddev);
DISKOP_SPARE_INACTIVE);
mddev->spare = NULL; mddev->spare = NULL;
} }
} else { } else {
if (!mddev->pers->spare_active)
goto unlock;
/* success...*/ /* success...*/
if (mddev->spare) { if (mddev->spare) {
mddev->pers->diskop(mddev, &mddev->spare, mddev->pers->spare_active(mddev,
DISKOP_SPARE_ACTIVE); &mddev->spare);
mark_disk_sync(mddev->spare); mark_disk_sync(mddev->spare);
mark_disk_active(mddev->spare); mark_disk_active(mddev->spare);
sb->active_disks++; sb->active_disks++;
...@@ -3432,12 +3434,13 @@ void md_do_recovery(void *data) ...@@ -3432,12 +3434,13 @@ void md_do_recovery(void *data)
if (!mddev->sync_thread) { if (!mddev->sync_thread) {
printk(KERN_ERR "md%d: could not start resync thread...\n", mdidx(mddev)); printk(KERN_ERR "md%d: could not start resync thread...\n", mdidx(mddev));
if (mddev->spare) if (mddev->spare)
mddev->pers->diskop(mddev, &mddev->spare, DISKOP_SPARE_INACTIVE); mddev->pers->spare_inactive(mddev);
mddev->spare = NULL; mddev->spare = NULL;
mddev->recovery_running = 0; mddev->recovery_running = 0;
} else { } else {
if (mddev->spare) if (mddev->spare)
mddev->pers->diskop(mddev, &mddev->spare, DISKOP_SPARE_WRITE); mddev->pers->spare_write(mddev,
mddev->spare->number);
mddev->recovery_running = 1; mddev->recovery_running = 1;
md_wakeup_thread(mddev->sync_thread); md_wakeup_thread(mddev->sync_thread);
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -13,14 +13,9 @@ ...@@ -13,14 +13,9 @@
* Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl} * Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl}
*/ */
#include <linux/config.h> #include <linux/init.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/init.h>
#include <linux/raid/md.h>
#include <linux/buffer_head.h> /* for invalidate_bdev() */ #include <linux/buffer_head.h> /* for invalidate_bdev() */
#include "check.h" #include "check.h"
......
...@@ -160,16 +160,6 @@ struct mdk_rdev_s ...@@ -160,16 +160,6 @@ struct mdk_rdev_s
int desc_nr; /* descriptor index in the superblock */ int desc_nr; /* descriptor index in the superblock */
}; };
/*
* disk operations in a working array:
*/
#define DISKOP_SPARE_INACTIVE 0
#define DISKOP_SPARE_WRITE 1
#define DISKOP_SPARE_ACTIVE 2
#define DISKOP_HOT_REMOVE_DISK 3
#define DISKOP_HOT_ADD_DISK 4
typedef struct mdk_personality_s mdk_personality_t; typedef struct mdk_personality_s mdk_personality_t;
struct mddev_s struct mddev_s
...@@ -214,18 +204,11 @@ struct mdk_personality_s ...@@ -214,18 +204,11 @@ struct mdk_personality_s
int (*stop)(mddev_t *mddev); int (*stop)(mddev_t *mddev);
int (*status)(char *page, mddev_t *mddev); int (*status)(char *page, mddev_t *mddev);
int (*error_handler)(mddev_t *mddev, struct block_device *bdev); int (*error_handler)(mddev_t *mddev, struct block_device *bdev);
int (*hot_add_disk) (mddev_t *mddev, mdp_disk_t *descriptor, mdk_rdev_t *rdev);
/* int (*hot_remove_disk) (mddev_t *mddev, int number);
* Some personalities (RAID-1, RAID-5) can have disks hot-added and int (*spare_write) (mddev_t *mddev, int number);
* hot-removed. Hot removal is different from failure. (failure marks int (*spare_inactive) (mddev_t *mddev);
* a disk inactive, but the disk is still part of the array) The interface int (*spare_active) (mddev_t *mddev, mdp_disk_t **descriptor);
* to such operations is the 'pers->diskop()' function, can be NULL.
*
* the diskop function can change the pointer pointing to the incoming
* descriptor, but must do so very carefully. (currently only
* SPARE_ACTIVE expects such a change)
*/
int (*diskop) (mddev_t *mddev, mdp_disk_t **descriptor, int state);
int (*sync_request)(mddev_t *mddev, sector_t sector_nr, int go_faster); int (*sync_request)(mddev_t *mddev, sector_t sector_nr, int go_faster);
}; };
......
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