Commit 480f4106 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] raid kdev_t cleanups (part 1)

	* ->error_handler() switched to struct block_device *.
	* md_sync_acct() switched to struct block_device *.
	* raid5 struct disk_info ->dev is gone - we use ->bdev everywhere.
	* bunch of kdev_same() when we have corresponding struct block_device *
and can simply compare them is removed from drivers/md/*.c
parent a99f1593
...@@ -2924,7 +2924,7 @@ int md_error(mddev_t *mddev, struct block_device *bdev) ...@@ -2924,7 +2924,7 @@ int md_error(mddev_t *mddev, struct block_device *bdev)
if (!rrdev || rrdev->faulty) if (!rrdev || rrdev->faulty)
return 0; return 0;
if (!mddev->pers->error_handler if (!mddev->pers->error_handler
|| mddev->pers->error_handler(mddev,rdev) <= 0) { || mddev->pers->error_handler(mddev,bdev) <= 0) {
rrdev->faulty = 1; rrdev->faulty = 1;
} else } else
return 1; return 1;
...@@ -3136,8 +3136,9 @@ mdp_disk_t *get_spare(mddev_t *mddev) ...@@ -3136,8 +3136,9 @@ mdp_disk_t *get_spare(mddev_t *mddev)
} }
static unsigned int sync_io[DK_MAX_MAJOR][DK_MAX_DISK]; static unsigned int sync_io[DK_MAX_MAJOR][DK_MAX_DISK];
void md_sync_acct(kdev_t dev, unsigned long nr_sectors) void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
{ {
kdev_t dev = to_kdev_t(bdev->bd_dev);
unsigned int major = major(dev); unsigned int major = major(dev);
unsigned int index; unsigned int index;
......
...@@ -320,7 +320,7 @@ static void mark_disk_bad (mddev_t *mddev, int failed) ...@@ -320,7 +320,7 @@ static void mark_disk_bad (mddev_t *mddev, int failed)
/* /*
* Careful, this can execute in IRQ contexts as well! * Careful, this can execute in IRQ contexts as well!
*/ */
static int multipath_error (mddev_t *mddev, kdev_t dev) static int multipath_error (mddev_t *mddev, struct block_device *bdev)
{ {
multipath_conf_t *conf = mddev_to_conf(mddev); multipath_conf_t *conf = mddev_to_conf(mddev);
struct multipath_info * multipaths = conf->multipaths; struct multipath_info * multipaths = conf->multipaths;
...@@ -345,7 +345,7 @@ static int multipath_error (mddev_t *mddev, kdev_t dev) ...@@ -345,7 +345,7 @@ static int multipath_error (mddev_t *mddev, kdev_t dev)
* which has just failed. * which has just failed.
*/ */
for (i = 0; i < disks; i++) { for (i = 0; i < disks; i++) {
if (kdev_same(multipaths[i].dev, dev) && !multipaths[i].operational) if (multipaths[i].bdev == bdev && !multipaths[i].operational)
return 0; return 0;
} }
printk (LAST_DISK); printk (LAST_DISK);
...@@ -354,7 +354,7 @@ static int multipath_error (mddev_t *mddev, kdev_t dev) ...@@ -354,7 +354,7 @@ static int multipath_error (mddev_t *mddev, kdev_t dev)
* Mark disk as unusable * Mark disk as unusable
*/ */
for (i = 0; i < disks; i++) { for (i = 0; i < disks; i++) {
if (kdev_same(multipaths[i].dev,dev) && multipaths[i].operational) { if (multipaths[i].bdev == bdev && multipaths[i].operational) {
mark_disk_bad(mddev, i); mark_disk_bad(mddev, i);
break; break;
} }
......
...@@ -592,7 +592,7 @@ static void mark_disk_bad(mddev_t *mddev, int failed) ...@@ -592,7 +592,7 @@ static void mark_disk_bad(mddev_t *mddev, int failed)
printk(DISK_FAILED, partition_name(mirror->dev), conf->working_disks); printk(DISK_FAILED, partition_name(mirror->dev), conf->working_disks);
} }
static int error(mddev_t *mddev, kdev_t dev) static int error(mddev_t *mddev, struct block_device *bdev)
{ {
conf_t *conf = mddev_to_conf(mddev); conf_t *conf = mddev_to_conf(mddev);
mirror_info_t * mirrors = conf->mirrors; mirror_info_t * mirrors = conf->mirrors;
...@@ -607,7 +607,7 @@ static int error(mddev_t *mddev, kdev_t dev) ...@@ -607,7 +607,7 @@ static int error(mddev_t *mddev, kdev_t dev)
* else mark the drive as failed * else mark the drive as failed
*/ */
for (i = 0; i < disks; i++) for (i = 0; i < disks; i++)
if (kdev_same(mirrors[i].dev, dev) && mirrors[i].operational) if (mirrors[i].bdev == bdev && mirrors[i].operational)
break; break;
if (i == disks) if (i == disks)
return 0; return 0;
...@@ -1045,7 +1045,7 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) ...@@ -1045,7 +1045,7 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
if (!mbio) if (!mbio)
continue; continue;
md_sync_acct(to_kdev_t(mbio->bi_bdev->bd_dev), mbio->bi_size >> 9); md_sync_acct(mbio->bi_bdev, mbio->bi_size >> 9);
generic_make_request(mbio); generic_make_request(mbio);
atomic_inc(&conf->mirrors[i].nr_pending); atomic_inc(&conf->mirrors[i].nr_pending);
} }
...@@ -1217,7 +1217,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) ...@@ -1217,7 +1217,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
BUG(); BUG();
r1_bio->read_bio = read_bio; r1_bio->read_bio = read_bio;
md_sync_acct(to_kdev_t(read_bio->bi_bdev->bd_dev), nr_sectors); md_sync_acct(read_bio->bi_bdev, nr_sectors);
generic_make_request(read_bio); generic_make_request(read_bio);
atomic_inc(&conf->mirrors[conf->last_used].nr_pending); atomic_inc(&conf->mirrors[conf->last_used].nr_pending);
......
...@@ -439,8 +439,9 @@ static void raid5_build_block (struct stripe_head *sh, int i) ...@@ -439,8 +439,9 @@ static void raid5_build_block (struct stripe_head *sh, int i)
dev->sector = compute_blocknr(sh, i); dev->sector = compute_blocknr(sh, i);
} }
static int error (mddev_t *mddev, kdev_t dev) static int error(mddev_t *mddev, struct block_device *bdev)
{ {
kdev_t dev = to_kdev_t(bdev->bd_dev);
raid5_conf_t *conf = (raid5_conf_t *) mddev->private; raid5_conf_t *conf = (raid5_conf_t *) mddev->private;
mdp_super_t *sb = mddev->sb; mdp_super_t *sb = mddev->sb;
struct disk_info *disk; struct disk_info *disk;
...@@ -449,33 +450,33 @@ static int error (mddev_t *mddev, kdev_t dev) ...@@ -449,33 +450,33 @@ static int error (mddev_t *mddev, kdev_t dev)
PRINTK("raid5: error called\n"); PRINTK("raid5: error called\n");
for (i = 0, disk = conf->disks; i < conf->raid_disks; i++, disk++) { for (i = 0, disk = conf->disks; i < conf->raid_disks; i++, disk++) {
if (kdev_same(disk->dev, dev)) { if (disk->bdev != bdev)
if (disk->operational) { continue;
disk->operational = 0; if (disk->operational) {
mark_disk_faulty(sb->disks+disk->number); disk->operational = 0;
mark_disk_nonsync(sb->disks+disk->number); mark_disk_faulty(sb->disks+disk->number);
mark_disk_inactive(sb->disks+disk->number); mark_disk_nonsync(sb->disks+disk->number);
sb->active_disks--; mark_disk_inactive(sb->disks+disk->number);
sb->working_disks--; sb->active_disks--;
sb->failed_disks++; sb->working_disks--;
mddev->sb_dirty = 1; sb->failed_disks++;
conf->working_disks--; mddev->sb_dirty = 1;
conf->failed_disks++; conf->working_disks--;
md_wakeup_thread(conf->thread); conf->failed_disks++;
printk (KERN_ALERT md_wakeup_thread(conf->thread);
"raid5: Disk failure on %s, disabling device." printk (KERN_ALERT
" Operation continuing on %d devices\n", "raid5: Disk failure on %s, disabling device."
partition_name (dev), conf->working_disks); " Operation continuing on %d devices\n",
} partition_name (dev), conf->working_disks);
return 0;
} }
return 0;
} }
/* /*
* handle errors in spares (during reconstruction) * handle errors in spares (during reconstruction)
*/ */
if (conf->spare) { if (conf->spare) {
disk = conf->spare; disk = conf->spare;
if (kdev_same(disk->dev, dev)) { if (disk->bdev == bdev) {
printk (KERN_ALERT printk (KERN_ALERT
"raid5: Disk failure on spare %s\n", "raid5: Disk failure on spare %s\n",
partition_name (dev)); partition_name (dev));
...@@ -1017,7 +1018,7 @@ static void handle_stripe(struct stripe_head *sh) ...@@ -1017,7 +1018,7 @@ static void handle_stripe(struct stripe_head *sh)
locked++; locked++;
PRINTK("Reading block %d (sync=%d)\n", i, syncing); PRINTK("Reading block %d (sync=%d)\n", i, syncing);
if (syncing) if (syncing)
md_sync_acct(conf->disks[i].dev, STRIPE_SECTORS); md_sync_acct(conf->disks[i].bdev, STRIPE_SECTORS);
} }
} }
} }
...@@ -1156,9 +1157,9 @@ static void handle_stripe(struct stripe_head *sh) ...@@ -1156,9 +1157,9 @@ static void handle_stripe(struct stripe_head *sh)
locked++; locked++;
set_bit(STRIPE_INSYNC, &sh->state); set_bit(STRIPE_INSYNC, &sh->state);
if (conf->disks[failed_num].operational) if (conf->disks[failed_num].operational)
md_sync_acct(conf->disks[failed_num].dev, STRIPE_SECTORS); md_sync_acct(conf->disks[failed_num].bdev, STRIPE_SECTORS);
else if ((spare=conf->spare)) else if ((spare=conf->spare))
md_sync_acct(spare->dev, STRIPE_SECTORS); md_sync_acct(spare->bdev, STRIPE_SECTORS);
} }
} }
...@@ -1435,7 +1436,6 @@ static int run (mddev_t *mddev) ...@@ -1435,7 +1436,6 @@ static int run (mddev_t *mddev)
} }
disk->number = desc->number; disk->number = desc->number;
disk->raid_disk = raid_disk; disk->raid_disk = raid_disk;
disk->dev = rdev->dev;
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
disk->operational = 0; disk->operational = 0;
...@@ -1462,7 +1462,6 @@ static int run (mddev_t *mddev) ...@@ -1462,7 +1462,6 @@ static int run (mddev_t *mddev)
disk->number = desc->number; disk->number = desc->number;
disk->raid_disk = raid_disk; disk->raid_disk = raid_disk;
disk->dev = rdev->dev;
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
disk->operational = 1; disk->operational = 1;
disk->used_slot = 1; disk->used_slot = 1;
...@@ -1475,7 +1474,6 @@ static int run (mddev_t *mddev) ...@@ -1475,7 +1474,6 @@ static int run (mddev_t *mddev)
printk(KERN_INFO "raid5: spare disk %s\n", partition_name(rdev->dev)); printk(KERN_INFO "raid5: spare disk %s\n", partition_name(rdev->dev));
disk->number = desc->number; disk->number = desc->number;
disk->raid_disk = raid_disk; disk->raid_disk = raid_disk;
disk->dev = rdev->dev;
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
disk->operational = 0; disk->operational = 0;
...@@ -1495,7 +1493,6 @@ static int run (mddev_t *mddev) ...@@ -1495,7 +1493,6 @@ static int run (mddev_t *mddev)
disk->number = desc->number; disk->number = desc->number;
disk->raid_disk = raid_disk; disk->raid_disk = raid_disk;
disk->dev = NODEV;
disk->bdev = NULL; disk->bdev = NULL;
disk->operational = 0; disk->operational = 0;
...@@ -1691,7 +1688,9 @@ static void print_raid5_conf (raid5_conf_t *conf) ...@@ -1691,7 +1688,9 @@ static void print_raid5_conf (raid5_conf_t *conf)
printk(" disk %d, s:%d, o:%d, n:%d rd:%d us:%d dev:%s\n", printk(" disk %d, s:%d, o:%d, n:%d rd:%d us:%d dev:%s\n",
i, tmp->spare,tmp->operational, i, tmp->spare,tmp->operational,
tmp->number,tmp->raid_disk,tmp->used_slot, tmp->number,tmp->raid_disk,tmp->used_slot,
partition_name(tmp->dev)); partition_name(tmp->bdev ?
to_kdev_t(tmp->bdev->bd_dev):
NODEV));
} }
} }
...@@ -1903,7 +1902,7 @@ static int diskop(mddev_t *mddev, mdp_disk_t **d, int state) ...@@ -1903,7 +1902,7 @@ static int diskop(mddev_t *mddev, mdp_disk_t **d, int state)
*d = failed_desc; *d = failed_desc;
if (kdev_none(sdisk->dev)) if (!sdisk->bdev)
sdisk->used_slot = 0; sdisk->used_slot = 0;
/* /*
...@@ -1931,7 +1930,6 @@ static int diskop(mddev_t *mddev, mdp_disk_t **d, int state) ...@@ -1931,7 +1930,6 @@ static int diskop(mddev_t *mddev, mdp_disk_t **d, int state)
err = 1; err = 1;
goto abort; goto abort;
} }
rdisk->dev = NODEV;
rdisk->bdev = NULL; rdisk->bdev = NULL;
rdisk->used_slot = 0; rdisk->used_slot = 0;
...@@ -1949,9 +1947,8 @@ static int diskop(mddev_t *mddev, mdp_disk_t **d, int state) ...@@ -1949,9 +1947,8 @@ static int diskop(mddev_t *mddev, mdp_disk_t **d, int state)
adisk->number = added_desc->number; adisk->number = added_desc->number;
adisk->raid_disk = added_desc->raid_disk; adisk->raid_disk = added_desc->raid_disk;
adisk->dev = mk_kdev(added_desc->major,added_desc->minor);
/* it will be held open by rdev */ /* it will be held open by rdev */
adisk->bdev = bdget(kdev_t_to_nr(adisk->dev)); adisk->bdev = bdget(MKDEV(added_desc->major,added_desc->minor));
adisk->operational = 0; adisk->operational = 0;
adisk->write_only = 0; adisk->write_only = 0;
......
...@@ -77,7 +77,7 @@ extern void md_wakeup_thread(mdk_thread_t *thread); ...@@ -77,7 +77,7 @@ extern void md_wakeup_thread(mdk_thread_t *thread);
extern void md_interrupt_thread (mdk_thread_t *thread); extern void md_interrupt_thread (mdk_thread_t *thread);
extern void md_update_sb (mddev_t *mddev); extern void md_update_sb (mddev_t *mddev);
extern void md_done_sync(mddev_t *mddev, int blocks, int ok); extern void md_done_sync(mddev_t *mddev, int blocks, int ok);
extern void md_sync_acct(kdev_t dev, unsigned long nr_sectors); extern void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors);
extern int md_error (mddev_t *mddev, struct block_device *bdev); extern int md_error (mddev_t *mddev, struct block_device *bdev);
extern int md_run_setup(void); extern int md_run_setup(void);
......
...@@ -213,7 +213,7 @@ struct mdk_personality_s ...@@ -213,7 +213,7 @@ struct mdk_personality_s
int (*run)(mddev_t *mddev); int (*run)(mddev_t *mddev);
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, kdev_t dev); int (*error_handler)(mddev_t *mddev, struct block_device *bdev);
/* /*
* Some personalities (RAID-1, RAID-5) can have disks hot-added and * Some personalities (RAID-1, RAID-5) can have disks hot-added and
......
...@@ -192,7 +192,6 @@ struct stripe_head { ...@@ -192,7 +192,6 @@ struct stripe_head {
struct disk_info { struct disk_info {
kdev_t dev;
struct block_device *bdev; struct block_device *bdev;
int operational; int operational;
int number; int 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