diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2001-03-09 20:33:35 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2001-03-09 20:33:35 +0000 |
commit | 116674acc97ba75a720329996877077d988443a2 (patch) | |
tree | 6a3f2ff0b612ae2ee8a3f3509370c9e6333a53b3 /drivers/md | |
parent | 71118c319fcae4a138f16e35b4f7e0a6d53ce2ca (diff) |
Merge with Linux 2.4.2.
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/linear.c | 2 | ||||
-rw-r--r-- | drivers/md/md.c | 208 | ||||
-rw-r--r-- | drivers/md/raid1.c | 2 | ||||
-rw-r--r-- | drivers/md/raid5.c | 22 |
4 files changed, 124 insertions, 110 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index e6b50b84d..52583645f 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c @@ -19,7 +19,7 @@ #include <linux/module.h> #include <linux/raid/md.h> -#include <linux/malloc.h> +#include <linux/slab.h> #include <linux/raid/linear.h> diff --git a/drivers/md/md.c b/drivers/md/md.c index 5d4bab6c9..b2ed89dcc 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -61,6 +61,10 @@ extern asmlinkage long sys_setsid(void); # define dprintk(x...) do { } while(0) #endif +#ifndef MODULE +static void autostart_arrays (void); +#endif + static mdk_personality_t *pers[MAX_PERSONALITY]; /* @@ -2030,70 +2034,6 @@ abort: #undef AUTOADDING #undef AUTORUNNING -struct { - int set; - int noautodetect; -} raid_setup_args md__initdata; - -void md_setup_drive (void) md__init; - -/* - * Searches all registered partitions for autorun RAID arrays - * at boot time. - */ -static int detected_devices[128] md__initdata; -static int dev_cnt; - -void md_autodetect_dev(kdev_t dev) -{ - if (dev_cnt >= 0 && dev_cnt < 127) - detected_devices[dev_cnt++] = dev; -} - - -static void autostart_arrays (void) -{ - mdk_rdev_t *rdev; - int i; - - printk(KERN_INFO "autodetecting RAID arrays\n"); - - for (i=0; i<dev_cnt; i++) { - kdev_t dev = detected_devices[i]; - - if (md_import_device(dev,1)) { - printk(KERN_ALERT "could not import %s!\n", - partition_name(dev)); - continue; - } - /* - * Sanity checks: - */ - rdev = find_rdev_all(dev); - if (!rdev) { - MD_BUG(); - continue; - } - if (rdev->faulty) { - MD_BUG(); - continue; - } - md_list_add(&rdev->pending, &pending_raid_disks); - } - - autorun_devices(-1); -} - -int md__init md_run_setup(void) -{ - if (raid_setup_args.noautodetect) - printk(KERN_INFO "skipping autodetection of RAID arrays\n"); - else - autostart_arrays(); - dev_cnt = -1; /* make sure further calls to md_autodetect_dev are ignored */ - md_setup_drive(); - return 0; -} static int get_version (void * arg) { @@ -2555,10 +2495,12 @@ static int md_ioctl (struct inode *inode, struct file *file, md_print_devices(); goto done_unlock; +#ifndef MODULE case RAID_AUTORUN: err = 0; autostart_arrays(); goto done; +#endif case BLKGETSIZE: /* Return device size */ if (!arg) { @@ -2590,7 +2532,7 @@ static int md_ioctl (struct inode *inode, struct file *file, err = md_put_user (read_ahead[ MAJOR(dev)], (long *) arg); goto done; - default: + default:; } /* @@ -2609,7 +2551,7 @@ static int md_ioctl (struct inode *inode, struct file *file, err = -EEXIST; goto abort; } - default: + default:; } switch (cmd) { @@ -2662,7 +2604,7 @@ static int md_ioctl (struct inode *inode, struct file *file, } goto done; - default: + default:; } /* @@ -3556,30 +3498,7 @@ struct notifier_block md_notifier = { NULL, 0 }; -#ifndef MODULE -static int md__init raid_setup(char *str) -{ - int len, pos; - - len = strlen(str) + 1; - pos = 0; - - while (pos < len) { - char *comma = strchr(str+pos, ','); - int wlen; - if (comma) - wlen = (comma-str)-pos; - else wlen = (len-1)-pos; - if (strncmp(str, "noautodetect", wlen) == 0) - raid_setup_args.noautodetect = 1; - pos += wlen+1; - } - raid_setup_args.set = 1; - return 1; -} -__setup("raid=", raid_setup); -#endif static void md_geninit (void) { int i; @@ -3641,6 +3560,70 @@ int md__init md_init (void) return (0); } + +#ifndef MODULE + +/* + * When md (and any require personalities) are compiled into the kernel + * (not a module), arrays can be assembles are boot time using with AUTODETECT + * where specially marked partitions are registered with md_autodetect_dev(), + * and with MD_BOOT where devices to be collected are given on the boot line + * with md=..... + * The code for that is here. + */ + +struct { + int set; + int noautodetect; +} raid_setup_args md__initdata; + +/* + * Searches all registered partitions for autorun RAID arrays + * at boot time. + */ +static int detected_devices[128] md__initdata; +static int dev_cnt; + +void md_autodetect_dev(kdev_t dev) +{ + if (dev_cnt >= 0 && dev_cnt < 127) + detected_devices[dev_cnt++] = dev; +} + + +static void autostart_arrays (void) +{ + mdk_rdev_t *rdev; + int i; + + printk(KERN_INFO "autodetecting RAID arrays\n"); + + for (i=0; i<dev_cnt; i++) { + kdev_t dev = detected_devices[i]; + + if (md_import_device(dev,1)) { + printk(KERN_ALERT "could not import %s!\n", + partition_name(dev)); + continue; + } + /* + * Sanity checks: + */ + rdev = find_rdev_all(dev); + if (!rdev) { + MD_BUG(); + continue; + } + if (rdev->faulty) { + MD_BUG(); + continue; + } + md_list_add(&rdev->pending, &pending_raid_disks); + } + + autorun_devices(-1); +} + static struct { char device_set [MAX_MD_DEVS]; int pers[MAX_MD_DEVS]; @@ -3665,6 +3648,7 @@ static struct { * elements in device-list are read by name_to_kdev_t so can be * a hex number or something like /dev/hda1 /dev/sdb */ +#ifndef MODULE extern kdev_t name_to_kdev_t(char *line) md__init; static int md__init md_setup(char *str) { @@ -3740,6 +3724,7 @@ static int md__init md_setup(char *str) md_setup_args.device_set[minor] = 1; return 1; } +#endif /* !MODULE */ void md__init md_setup_drive(void) { @@ -3807,9 +3792,47 @@ void md__init md_setup_drive(void) } } +static int md__init raid_setup(char *str) +{ + int len, pos; + + len = strlen(str) + 1; + pos = 0; + + while (pos < len) { + char *comma = strchr(str+pos, ','); + int wlen; + if (comma) + wlen = (comma-str)-pos; + else wlen = (len-1)-pos; + + if (strncmp(str, "noautodetect", wlen) == 0) + raid_setup_args.noautodetect = 1; + pos += wlen+1; + } + raid_setup_args.set = 1; + return 1; +} + +int md__init md_run_setup(void) +{ + if (raid_setup_args.noautodetect) + printk(KERN_INFO "skipping autodetection of RAID arrays\n"); + else + autostart_arrays(); + dev_cnt = -1; /* make sure further calls to md_autodetect_dev are ignored */ + md_setup_drive(); + return 0; +} + +__setup("raid=", raid_setup); __setup("md=", md_setup); -#ifdef MODULE +__initcall(md_init); +__initcall(md_run_setup); + +#else /* It is a MODULE */ + int init_module (void) { return md_init(); @@ -3858,9 +3881,6 @@ void cleanup_module (void) } #endif -__initcall(md_init); -__initcall(md_run_setup); - MD_EXPORT_SYMBOL(md_size); MD_EXPORT_SYMBOL(register_md_personality); MD_EXPORT_SYMBOL(unregister_md_personality); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 3a381b6a2..358cb7cac 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -23,7 +23,7 @@ */ #include <linux/module.h> -#include <linux/malloc.h> +#include <linux/slab.h> #include <linux/raid/raid1.h> #include <asm/atomic.h> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 3ad3940a9..d00cda6d4 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -19,7 +19,7 @@ #include <linux/config.h> #include <linux/module.h> #include <linux/locks.h> -#include <linux/malloc.h> +#include <linux/slab.h> #include <linux/raid/raid5.h> #include <asm/bitops.h> #include <asm/atomic.h> @@ -381,7 +381,7 @@ static void raid5_end_read_request (struct buffer_head * bh, int uptodate) if (bh == sh->bh_cache[i]) break; - PRINTK("end_read_request %lu/%d, %d, count: %d, uptodate %d.\n", sh->sector, i, atomic_read(&sh->count), uptodate); + PRINTK("end_read_request %lu/%d, count: %d, uptodate %d.\n", sh->sector, i, atomic_read(&sh->count), uptodate); if (i == disks) { BUG(); return; @@ -680,7 +680,6 @@ static void compute_parity(struct stripe_head *sh, int method) count = 1; bh_ptr[0] = sh->bh_cache[pd_idx]; - spin_lock_irq(&conf->device_lock); switch(method) { case READ_MODIFY_WRITE: if (!buffer_uptodate(sh->bh_cache[pd_idx])) @@ -707,13 +706,11 @@ static void compute_parity(struct stripe_head *sh, int method) sh->bh_write[i] = sh->bh_write[i]->b_reqnext; chosen[i]->b_reqnext = sh->bh_written[i]; sh->bh_written[i] = chosen[i]; - check_xor(); } break; case CHECK_PARITY: break; } - spin_unlock_irq(&conf->device_lock); if (count>1) { xor_block(count, bh_ptr); count = 1; @@ -723,7 +720,6 @@ static void compute_parity(struct stripe_head *sh, int method) if (chosen[i]) { struct buffer_head *bh = sh->bh_cache[i]; char *bdata; - mark_buffer_clean(chosen[i]); /* NO FIXME */ bdata = bh_kmap(chosen[i]); memcpy(bh->b_data, bdata,sh->size); @@ -766,6 +762,7 @@ static void add_stripe_bh (struct stripe_head *sh, struct buffer_head *bh, int d PRINTK("adding bh b#%lu to stripe s#%lu\n", bh->b_blocknr, sh->sector); + spin_lock(&sh->lock); spin_lock_irq(&conf->device_lock); bh->b_reqnext = NULL; if (rw == READ) @@ -778,6 +775,7 @@ static void add_stripe_bh (struct stripe_head *sh, struct buffer_head *bh, int d } *bhp = bh; spin_unlock_irq(&conf->device_lock); + spin_unlock(&sh->lock); PRINTK("added bh b#%lu to stripe s#%lu, disk %d.\n", bh->b_blocknr, sh->sector, dd_idx); } @@ -827,7 +825,7 @@ static void handle_stripe(struct stripe_head *sh) for (i=disks; i--; ) { bh = sh->bh_cache[i]; - PRINTK("check %d: state %lx read %p write %p written %p\n", i, bh->b_state, sh->bh_read[i], sh->bh_write[i], sh->bh_written[i]); + PRINTK("check %d: state 0x%lx read %p write %p written %p\n", i, bh->b_state, sh->bh_read[i], sh->bh_write[i], sh->bh_written[i]); /* maybe we can reply to a read */ if (buffer_uptodate(bh) && sh->bh_read[i]) { struct buffer_head *rbh, *rbh2; @@ -867,7 +865,6 @@ static void handle_stripe(struct stripe_head *sh) * need to be failed */ if (failed > 1 && to_read+to_write) { - spin_lock_irq(&conf->device_lock); for (i=disks; i--; ) { /* fail all writes first */ if (sh->bh_write[i]) to_write--; @@ -878,15 +875,16 @@ static void handle_stripe(struct stripe_head *sh) } /* fail any reads if this device is non-operational */ if (!conf->disks[i].operational) { + spin_lock_irq(&conf->device_lock); if (sh->bh_read[i]) to_read--; while ((bh = sh->bh_read[i])) { sh->bh_read[i] = bh->b_reqnext; bh->b_reqnext = return_fail; return_fail = bh; } + spin_unlock_irq(&conf->device_lock); } } - spin_unlock_irq(&conf->device_lock); if (syncing) { md_done_sync(conf->mddev, (sh->size>>10) - sh->sync_redone,0); clear_bit(STRIPE_SYNCING, &sh->state); @@ -911,10 +909,8 @@ static void handle_stripe(struct stripe_head *sh) /* maybe we can return some write requests */ struct buffer_head *wbh, *wbh2; PRINTK("Return write for disc %d\n", i); - spin_lock_irq(&conf->device_lock); wbh = sh->bh_written[i]; sh->bh_written[i] = NULL; - spin_unlock_irq(&conf->device_lock); while (wbh) { wbh2 = wbh->b_reqnext; wbh->b_reqnext = return_ok; @@ -1076,7 +1072,7 @@ static void handle_stripe(struct stripe_head *sh) bh->b_end_io(bh, 1); } while ((bh=return_fail)) { - return_ok = bh->b_reqnext; + return_fail = bh->b_reqnext; bh->b_reqnext = NULL; bh->b_end_io(bh, 0); } @@ -1092,8 +1088,6 @@ static void handle_stripe(struct stripe_head *sh) bh->b_dev = conf->disks[i].dev; else if (conf->spare && action[i] == WRITE+1) bh->b_dev = conf->spare->dev; - else if (action[i] == READ+1) - BUG(); else skip=1; if (!skip) { PRINTK("for %ld schedule op %d on disc %d\n", sh->sector, action[i]-1, i); |