patch-2.4.11-dontuse linux/drivers/md/md.c
Next file: linux/drivers/md/multipath.c
Previous file: linux/drivers/md/linear.c
Back to the patch index
Back to the overall index
- Lines: 1885
- Date:
Wed Oct 3 22:27:48 2001
- Orig file:
v2.4.10/linux/drivers/md/md.c
- Orig date:
Sun Sep 23 11:40:58 2001
diff -u --recursive --new-file v2.4.10/linux/drivers/md/md.c linux/drivers/md/md.c
@@ -140,7 +140,7 @@
*/
dev_mapping_t mddev_map[MAX_MD_DEVS];
-void add_mddev_mapping (mddev_t * mddev, kdev_t dev, void *data)
+void add_mddev_mapping(mddev_t * mddev, kdev_t dev, void *data)
{
unsigned int minor = MINOR(dev);
@@ -148,7 +148,7 @@
MD_BUG();
return;
}
- if (mddev_map[minor].mddev != NULL) {
+ if (mddev_map[minor].mddev) {
MD_BUG();
return;
}
@@ -156,7 +156,7 @@
mddev_map[minor].data = data;
}
-void del_mddev_mapping (mddev_t * mddev, kdev_t dev)
+void del_mddev_mapping(mddev_t * mddev, kdev_t dev)
{
unsigned int minor = MINOR(dev);
@@ -172,7 +172,7 @@
mddev_map[minor].data = NULL;
}
-static int md_make_request (request_queue_t *q, int rw, struct buffer_head * bh)
+static int md_make_request(request_queue_t *q, int rw, struct buffer_head * bh)
{
mddev_t *mddev = kdev_to_mddev(bh->b_rdev);
@@ -184,7 +184,7 @@
}
}
-static mddev_t * alloc_mddev (kdev_t dev)
+static mddev_t * alloc_mddev(kdev_t dev)
{
mddev_t *mddev;
@@ -195,7 +195,7 @@
mddev = (mddev_t *) kmalloc(sizeof(*mddev), GFP_KERNEL);
if (!mddev)
return NULL;
-
+
memset(mddev, 0, sizeof(*mddev));
mddev->__minor = MINOR(dev);
@@ -245,7 +245,7 @@
static MD_LIST_HEAD(device_names);
-char * partition_name (kdev_t dev)
+char * partition_name(kdev_t dev)
{
struct gendisk *hd;
static char nomem [] = "<nomem>";
@@ -282,7 +282,7 @@
return dname->name;
}
-static unsigned int calc_dev_sboffset (kdev_t dev, mddev_t *mddev,
+static unsigned int calc_dev_sboffset(kdev_t dev, mddev_t *mddev,
int persistent)
{
unsigned int size = 0;
@@ -294,7 +294,7 @@
return size;
}
-static unsigned int calc_dev_size (kdev_t dev, mddev_t *mddev, int persistent)
+static unsigned int calc_dev_size(kdev_t dev, mddev_t *mddev, int persistent)
{
unsigned int size;
@@ -308,7 +308,7 @@
return size;
}
-static unsigned int zoned_raid_size (mddev_t *mddev)
+static unsigned int zoned_raid_size(mddev_t *mddev)
{
unsigned int mask;
mdk_rdev_t * rdev;
@@ -338,7 +338,7 @@
* provide data have to be able to deal with loss of individual
* disks, so they do their checking themselves.
*/
-int md_check_ordering (mddev_t *mddev)
+int md_check_ordering(mddev_t *mddev)
{
int i, c;
mdk_rdev_t *rdev;
@@ -349,8 +349,8 @@
*/
ITERATE_RDEV(mddev,rdev,tmp) {
if (rdev->faulty) {
- printk("md: md%d's device %s faulty, aborting.\n",
- mdidx(mddev), partition_name(rdev->dev));
+ printk(KERN_ERR "md: md%d's device %s faulty, aborting.\n",
+ mdidx(mddev), partition_name(rdev->dev));
goto abort;
}
}
@@ -364,7 +364,7 @@
goto abort;
}
if (mddev->nb_dev != mddev->sb->raid_disks) {
- printk("md: md%d, array needs %d disks, has %d, aborting.\n",
+ printk(KERN_ERR "md: md%d, array needs %d disks, has %d, aborting.\n",
mdidx(mddev), mddev->sb->raid_disks, mddev->nb_dev);
goto abort;
}
@@ -378,13 +378,13 @@
c++;
}
if (!c) {
- printk("md: md%d, missing disk #%d, aborting.\n",
- mdidx(mddev), i);
+ printk(KERN_ERR "md: md%d, missing disk #%d, aborting.\n",
+ mdidx(mddev), i);
goto abort;
}
if (c > 1) {
- printk("md: md%d, too many disks #%d, aborting.\n",
- mdidx(mddev), i);
+ printk(KERN_ERR "md: md%d, too many disks #%d, aborting.\n",
+ mdidx(mddev), i);
goto abort;
}
}
@@ -393,7 +393,7 @@
return 1;
}
-static void remove_descriptor (mdp_disk_t *disk, mdp_super_t *sb)
+static void remove_descriptor(mdp_disk_t *disk, mdp_super_t *sb)
{
if (disk_active(disk)) {
sb->working_disks--;
@@ -426,7 +426,7 @@
#define BAD_CSUM KERN_WARNING \
"md: invalid superblock checksum on %s\n"
-static int alloc_array_sb (mddev_t * mddev)
+static int alloc_array_sb(mddev_t * mddev)
{
if (mddev->sb) {
MD_BUG();
@@ -440,14 +440,14 @@
return 0;
}
-static int alloc_disk_sb (mdk_rdev_t * rdev)
+static int alloc_disk_sb(mdk_rdev_t * rdev)
{
if (rdev->sb)
MD_BUG();
rdev->sb = (mdp_super_t *) __get_free_page(GFP_KERNEL);
if (!rdev->sb) {
- printk (OUT_OF_MEM);
+ printk(OUT_OF_MEM);
return -EINVAL;
}
md_clear_page(rdev->sb);
@@ -455,7 +455,7 @@
return 0;
}
-static void free_disk_sb (mdk_rdev_t * rdev)
+static void free_disk_sb(mdk_rdev_t * rdev)
{
if (rdev->sb) {
free_page((unsigned long) rdev->sb);
@@ -468,7 +468,7 @@
}
}
-static int read_disk_sb (mdk_rdev_t * rdev)
+static int read_disk_sb(mdk_rdev_t * rdev)
{
int ret = -EINVAL;
struct buffer_head *bh = NULL;
@@ -479,15 +479,14 @@
if (!rdev->sb) {
MD_BUG();
goto abort;
- }
-
+ }
+
/*
* Calculate the position of the superblock,
* it's at the end of the disk
*/
sb_offset = calc_dev_sboffset(rdev->dev, rdev->mddev, 1);
rdev->sb_offset = sb_offset;
- printk("(read) %s's sb offset: %ld", partition_name(dev), sb_offset);
fsync_dev(dev);
set_blocksize (dev, MD_SB_BYTES);
bh = bread (dev, sb_offset / MD_SB_BLOCKS, MD_SB_BYTES);
@@ -496,10 +495,10 @@
sb = (mdp_super_t *) bh->b_data;
memcpy (rdev->sb, sb, MD_SB_BYTES);
} else {
- printk (NO_SB,partition_name(rdev->dev));
+ printk(NO_SB,partition_name(rdev->dev));
goto abort;
}
- printk(" [events: %08lx]\n", (unsigned long)rdev->sb->events_lo);
+ printk(KERN_INFO " [events: %08lx]\n", (unsigned long)rdev->sb->events_lo);
ret = 0;
abort:
if (bh)
@@ -507,7 +506,7 @@
return ret;
}
-static unsigned int calc_sb_csum (mdp_super_t * sb)
+static unsigned int calc_sb_csum(mdp_super_t * sb)
{
unsigned int disk_csum, csum;
@@ -522,7 +521,7 @@
* Check one RAID superblock for generic plausibility
*/
-static int check_disk_sb (mdk_rdev_t * rdev)
+static int check_disk_sb(mdk_rdev_t * rdev)
{
mdp_super_t *sb;
int ret = -EINVAL;
@@ -534,13 +533,12 @@
}
if (sb->md_magic != MD_SB_MAGIC) {
- printk (BAD_MAGIC, partition_name(rdev->dev));
+ printk(BAD_MAGIC, partition_name(rdev->dev));
goto abort;
}
if (sb->md_minor >= MAX_MD_DEVS) {
- printk (BAD_MINOR, partition_name(rdev->dev),
- sb->md_minor);
+ printk(BAD_MINOR, partition_name(rdev->dev), sb->md_minor);
goto abort;
}
@@ -590,7 +588,7 @@
static MD_LIST_HEAD(all_raid_disks);
static MD_LIST_HEAD(pending_raid_disks);
-static void bind_rdev_to_array (mdk_rdev_t * rdev, mddev_t * mddev)
+static void bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
{
mdk_rdev_t *same_pdev;
@@ -603,16 +601,16 @@
printk( KERN_WARNING
"md%d: WARNING: %s appears to be on the same physical disk as %s. True\n"
" protection against single-disk failure might be compromised.\n",
- mdidx(mddev), partition_name(rdev->dev),
+ mdidx(mddev), partition_name(rdev->dev),
partition_name(same_pdev->dev));
-
+
md_list_add(&rdev->same_set, &mddev->disks);
rdev->mddev = mddev;
mddev->nb_dev++;
- printk("md: bind<%s,%d>\n", partition_name(rdev->dev), mddev->nb_dev);
+ printk(KERN_INFO "md: bind<%s,%d>\n", partition_name(rdev->dev), mddev->nb_dev);
}
-static void unbind_rdev_from_array (mdk_rdev_t * rdev)
+static void unbind_rdev_from_array(mdk_rdev_t * rdev)
{
if (!rdev->mddev) {
MD_BUG();
@@ -621,7 +619,7 @@
md_list_del(&rdev->same_set);
MD_INIT_LIST_HEAD(&rdev->same_set);
rdev->mddev->nb_dev--;
- printk("md: unbind<%s,%d>\n", partition_name(rdev->dev),
+ printk(KERN_INFO "md: unbind<%s,%d>\n", partition_name(rdev->dev),
rdev->mddev->nb_dev);
rdev->mddev = NULL;
}
@@ -633,13 +631,13 @@
* inode is not enough, the SCSI module usage code needs
* an explicit open() on the device]
*/
-static int lock_rdev (mdk_rdev_t *rdev)
+static int lock_rdev(mdk_rdev_t *rdev)
{
int err = 0;
struct block_device *bdev;
bdev = bdget(rdev->dev);
- if (bdev == NULL)
+ if (!bdev)
return -ENOMEM;
err = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_RAW);
if (!err)
@@ -647,7 +645,7 @@
return err;
}
-static void unlock_rdev (mdk_rdev_t *rdev)
+static void unlock_rdev(mdk_rdev_t *rdev)
{
struct block_device *bdev = rdev->bdev;
rdev->bdev = NULL;
@@ -656,11 +654,11 @@
blkdev_put(bdev, BDEV_RAW);
}
-void md_autodetect_dev (kdev_t dev);
+void md_autodetect_dev(kdev_t dev);
-static void export_rdev (mdk_rdev_t * rdev)
+static void export_rdev(mdk_rdev_t * rdev)
{
- printk("md: export_rdev(%s)\n",partition_name(rdev->dev));
+ printk(KERN_INFO "md: export_rdev(%s)\n",partition_name(rdev->dev));
if (rdev->mddev)
MD_BUG();
unlock_rdev(rdev);
@@ -668,7 +666,8 @@
md_list_del(&rdev->all);
MD_INIT_LIST_HEAD(&rdev->all);
if (rdev->pending.next != &rdev->pending) {
- printk("md: (%s was pending)\n",partition_name(rdev->dev));
+ printk(KERN_INFO "md: (%s was pending)\n",
+ partition_name(rdev->dev));
md_list_del(&rdev->pending);
MD_INIT_LIST_HEAD(&rdev->pending);
}
@@ -680,13 +679,13 @@
kfree(rdev);
}
-static void kick_rdev_from_array (mdk_rdev_t * rdev)
+static void kick_rdev_from_array(mdk_rdev_t * rdev)
{
unbind_rdev_from_array(rdev);
export_rdev(rdev);
}
-static void export_array (mddev_t *mddev)
+static void export_array(mddev_t *mddev)
{
struct md_list_head *tmp;
mdk_rdev_t *rdev;
@@ -708,7 +707,7 @@
MD_BUG();
}
-static void free_mddev (mddev_t *mddev)
+static void free_mddev(mddev_t *mddev)
{
if (!mddev) {
MD_BUG();
@@ -751,45 +750,47 @@
{
int i;
- printk("md: SB: (V:%d.%d.%d) ID:<%08x.%08x.%08x.%08x> CT:%08x\n",
+ printk(KERN_INFO "md: SB: (V:%d.%d.%d) ID:<%08x.%08x.%08x.%08x> CT:%08x\n",
sb->major_version, sb->minor_version, sb->patch_version,
sb->set_uuid0, sb->set_uuid1, sb->set_uuid2, sb->set_uuid3,
sb->ctime);
- printk("md: L%d S%08d ND:%d RD:%d md%d LO:%d CS:%d\n", sb->level,
+ printk(KERN_INFO "md: L%d S%08d ND:%d RD:%d md%d LO:%d CS:%d\n", sb->level,
sb->size, sb->nr_disks, sb->raid_disks, sb->md_minor,
sb->layout, sb->chunk_size);
- printk("md: UT:%08x ST:%d AD:%d WD:%d FD:%d SD:%d CSUM:%08x E:%08lx\n",
+ printk(KERN_INFO "md: UT:%08x ST:%d AD:%d WD:%d FD:%d SD:%d CSUM:%08x E:%08lx\n",
sb->utime, sb->state, sb->active_disks, sb->working_disks,
sb->failed_disks, sb->spare_disks,
sb->sb_csum, (unsigned long)sb->events_lo);
+ printk(KERN_INFO);
for (i = 0; i < MD_SB_DISKS; i++) {
mdp_disk_t *desc;
desc = sb->disks + i;
- if (desc->number || desc->major || desc->minor || desc->raid_disk || (desc->state && (desc->state != 4))) {
+ if (desc->number || desc->major || desc->minor ||
+ desc->raid_disk || (desc->state && (desc->state != 4))) {
printk(" D %2d: ", i);
print_desc(desc);
}
}
- printk("md: THIS: ");
+ printk(KERN_INFO "md: THIS: ");
print_desc(&sb->this_disk);
}
static void print_rdev(mdk_rdev_t *rdev)
{
- printk("md: rdev %s: O:%s, SZ:%08ld F:%d DN:%d ",
+ printk(KERN_INFO "md: rdev %s: O:%s, SZ:%08ld F:%d DN:%d ",
partition_name(rdev->dev), partition_name(rdev->old_dev),
rdev->size, rdev->faulty, rdev->desc_nr);
if (rdev->sb) {
- printk("md: rdev superblock:\n");
+ printk(KERN_INFO "md: rdev superblock:\n");
print_sb(rdev->sb);
} else
- printk("md: no rdev superblock!\n");
+ printk(KERN_INFO "md: no rdev superblock!\n");
}
-void md_print_devices (void)
+void md_print_devices(void)
{
struct md_list_head *tmp, *tmp2;
mdk_rdev_t *rdev;
@@ -818,7 +819,7 @@
printk("\n");
}
-static int sb_equal ( mdp_super_t *sb1, mdp_super_t *sb2)
+static int sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
{
int ret;
mdp_super_t *tmp1, *tmp2;
@@ -867,7 +868,7 @@
return 0;
}
-static mdk_rdev_t * find_rdev_all (kdev_t dev)
+static mdk_rdev_t * find_rdev_all(kdev_t dev)
{
struct md_list_head *tmp;
mdk_rdev_t *rdev;
@@ -908,8 +909,8 @@
dev = rdev->dev;
sb_offset = calc_dev_sboffset(dev, rdev->mddev, 1);
if (rdev->sb_offset != sb_offset) {
- printk("%s's sb offset has changed from %ld to %ld, skipping\n",
- partition_name(dev), rdev->sb_offset, sb_offset);
+ printk(KERN_INFO "%s's sb offset has changed from %ld to %ld, skipping\n",
+ partition_name(dev), rdev->sb_offset, sb_offset);
goto skip;
}
/*
@@ -919,12 +920,12 @@
*/
size = calc_dev_size(dev, rdev->mddev, 1);
if (size != rdev->size) {
- printk("%s's size has changed from %ld to %ld since import, skipping\n",
- partition_name(dev), rdev->size, size);
+ printk(KERN_INFO "%s's size has changed from %ld to %ld since import, skipping\n",
+ partition_name(dev), rdev->size, size);
goto skip;
}
- printk("(write) %s's sb offset: %ld\n", partition_name(dev), sb_offset);
+ printk(KERN_INFO "(write) %s's sb offset: %ld\n", partition_name(dev), sb_offset);
fsync_dev(dev);
set_blocksize(dev, MD_SB_BYTES);
bh = getblk(dev, sb_offset / MD_SB_BLOCKS, MD_SB_BYTES);
@@ -945,7 +946,7 @@
skip:
return 0;
}
-#undef GETBLK_FAILED
+#undef GETBLK_FAILED
static void set_this_disk(mddev_t *mddev, mdk_rdev_t *rdev)
{
@@ -1025,7 +1026,7 @@
err = 0;
ITERATE_RDEV(mddev,rdev,tmp) {
- printk("md: ");
+ printk(KERN_INFO "md: ");
if (rdev->faulty)
printk("(skipping faulty ");
if (rdev->alias_device)
@@ -1041,10 +1042,10 @@
}
if (err) {
if (--count) {
- printk("md: errors occurred during superblock update, repeating\n");
+ printk(KERN_ERR "md: errors occurred during superblock update, repeating\n");
goto repeat;
}
- printk("md: excessive errors occurred during superblock update, exiting\n");
+ printk(KERN_ERR "md: excessive errors occurred during superblock update, exiting\n");
}
return 0;
}
@@ -1059,7 +1060,7 @@
*
* a faulty rdev _never_ has rdev->sb set.
*/
-static int md_import_device (kdev_t newdev, int on_disk)
+static int md_import_device(kdev_t newdev, int on_disk)
{
int err;
mdk_rdev_t *rdev;
@@ -1070,13 +1071,13 @@
rdev = (mdk_rdev_t *) kmalloc(sizeof(*rdev), GFP_KERNEL);
if (!rdev) {
- printk("md: could not alloc mem for %s!\n", partition_name(newdev));
+ printk(KERN_ERR "md: could not alloc mem for %s!\n", partition_name(newdev));
return -ENOMEM;
}
memset(rdev, 0, sizeof(*rdev));
if (is_mounted(newdev)) {
- printk("md: can not import %s, has active inodes!\n",
+ printk(KERN_WARNING "md: can not import %s, has active inodes!\n",
partition_name(newdev));
err = -EBUSY;
goto abort_free;
@@ -1087,7 +1088,7 @@
rdev->dev = newdev;
if (lock_rdev(rdev)) {
- printk("md: could not lock %s, zero-size? Marking faulty.\n",
+ printk(KERN_ERR "md: could not lock %s, zero-size? Marking faulty.\n",
partition_name(newdev));
err = -EINVAL;
goto abort_free;
@@ -1099,7 +1100,7 @@
if (blk_size[MAJOR(newdev)])
size = blk_size[MAJOR(newdev)][MINOR(newdev)];
if (!size) {
- printk("md: %s has zero size, marking faulty!\n",
+ printk(KERN_WARNING "md: %s has zero size, marking faulty!\n",
partition_name(newdev));
err = -EINVAL;
goto abort_free;
@@ -1107,13 +1108,13 @@
if (on_disk) {
if ((err = read_disk_sb(rdev))) {
- printk("md: could not read %s's sb, not importing!\n",
- partition_name(newdev));
+ printk(KERN_WARNING "md: could not read %s's sb, not importing!\n",
+ partition_name(newdev));
goto abort_free;
}
if ((err = check_disk_sb(rdev))) {
- printk("md: %s has invalid sb, not importing!\n",
- partition_name(newdev));
+ printk(KERN_WARNING "md: %s has invalid sb, not importing!\n",
+ partition_name(newdev));
goto abort_free;
}
@@ -1162,7 +1163,7 @@
#define UNKNOWN_LEVEL KERN_ERR \
"md: md%d: unsupported raid level %d\n"
-static int analyze_sbs (mddev_t * mddev)
+static int analyze_sbs(mddev_t * mddev)
{
int out_of_date = 0, i, first;
struct md_list_head *tmp, *tmp2;
@@ -1197,7 +1198,7 @@
continue;
}
if (!sb_equal(sb, rdev->sb)) {
- printk (INCONSISTENT, partition_name(rdev->dev));
+ printk(INCONSISTENT, partition_name(rdev->dev));
kick_rdev_from_array(rdev);
continue;
}
@@ -1227,7 +1228,8 @@
rdev->sb->events_hi--;
}
- printk("md: %s's event counter: %08lx\n", partition_name(rdev->dev),
+ printk(KERN_INFO "md: %s's event counter: %08lx\n",
+ partition_name(rdev->dev),
(unsigned long)rdev->sb->events_lo);
if (!freshest) {
freshest = rdev;
@@ -1246,7 +1248,7 @@
}
if (out_of_date) {
printk(OUT_OF_DATE);
- printk("md: freshest: %s\n", partition_name(freshest->dev));
+ printk(KERN_INFO "md: freshest: %s\n", partition_name(freshest->dev));
}
memcpy (sb, freshest->sb, sizeof(*sb));
@@ -1265,7 +1267,7 @@
ev2 = md_event(sb);
++ev1;
if (ev1 < ev2) {
- printk("md: kicking non-fresh %s from array!\n",
+ printk(KERN_WARNING "md: kicking non-fresh %s from array!\n",
partition_name(rdev->dev));
kick_rdev_from_array(rdev);
continue;
@@ -1291,7 +1293,8 @@
((ev1 == ev2) || (ev1 == ev3))) {
mdp_disk_t *desc;
- printk("md: device name has changed from %s to %s since last import!\n", partition_name(rdev->old_dev), partition_name(rdev->dev));
+ printk(KERN_WARNING "md: device name has changed from %s to %s since last import!\n",
+ partition_name(rdev->old_dev), partition_name(rdev->dev));
if (rdev->desc_nr == -1) {
MD_BUG();
goto abort;
@@ -1338,7 +1341,7 @@
ITERATE_RDEV(mddev,rdev,tmp) {
if (rdev->desc_nr != desc->number)
continue;
- printk("md%d: kicking faulty %s!\n",
+ printk(KERN_WARNING "md%d: kicking faulty %s!\n",
mdidx(mddev),partition_name(rdev->dev));
kick_rdev_from_array(rdev);
found = 1;
@@ -1347,7 +1350,7 @@
if (!found) {
if (dev == MKDEV(0,0))
continue;
- printk("md%d: removing former faulty %s!\n",
+ printk(KERN_WARNING "md%d: removing former faulty %s!\n",
mdidx(mddev), partition_name(dev));
}
remove_descriptor(desc, sb);
@@ -1389,7 +1392,8 @@
if (found)
continue;
- printk("md%d: former device %s is unavailable, removing from array!\n", mdidx(mddev), partition_name(dev));
+ printk(KERN_WARNING "md%d: former device %s is unavailable, removing from array!\n",
+ mdidx(mddev), partition_name(dev));
remove_descriptor(desc, sb);
}
@@ -1436,7 +1440,7 @@
first = 0;
}
}
-
+
/*
* Kick all rdevs that are not in the
* descriptor array:
@@ -1445,7 +1449,7 @@
if (rdev->desc_nr == -1)
kick_rdev_from_array(rdev);
}
-
+
/*
* Do a final reality check.
*/
@@ -1484,14 +1488,14 @@
if (sb->major_version != MD_MAJOR_VERSION ||
sb->minor_version > MD_MINOR_VERSION) {
- printk (OLD_VERSION, mdidx(mddev), sb->major_version,
+ printk(OLD_VERSION, mdidx(mddev), sb->major_version,
sb->minor_version, sb->patch_version);
goto abort;
}
if ((sb->state != (1 << MD_SB_CLEAN)) && ((sb->level == 1) ||
(sb->level == 4) || (sb->level == 5)))
- printk (NOT_CLEAN_IGNORE, mdidx(mddev));
+ printk(NOT_CLEAN_IGNORE, mdidx(mddev));
return 0;
abort:
@@ -1503,7 +1507,7 @@
#undef OLD_VERSION
#undef OLD_LEVEL
-static int device_size_calculation (mddev_t * mddev)
+static int device_size_calculation(mddev_t * mddev)
{
int data_disks = 0, persistent;
unsigned int readahead;
@@ -1526,7 +1530,7 @@
}
rdev->size = calc_dev_size(rdev->dev, mddev, persistent);
if (rdev->size < sb->chunk_size / 1024) {
- printk (KERN_WARNING
+ printk(KERN_WARNING
"md: Dev %s smaller than chunk_size: %ldk < %dk\n",
partition_name(rdev->dev),
rdev->size, sb->chunk_size / 1024);
@@ -1560,7 +1564,7 @@
data_disks = sb->raid_disks-1;
break;
default:
- printk (UNKNOWN_LEVEL, mdidx(mddev), sb->level);
+ printk(UNKNOWN_LEVEL, mdidx(mddev), sb->level);
goto abort;
}
if (!md_size[mdidx(mddev)])
@@ -1599,7 +1603,7 @@
#define BAD_CHUNKSIZE KERN_ERR \
"no chunksize specified, see 'man raidtab'\n"
-static int do_md_run (mddev_t * mddev)
+static int do_md_run(mddev_t * mddev)
{
int pnum, err;
int chunk_size;
@@ -1663,7 +1667,8 @@
}
} else
if (chunk_size)
- printk(KERN_INFO "md: RAID level %d does not need chunksize! Continuing anyway.\n", mddev->sb->level);
+ printk(KERN_INFO "md: RAID level %d does not need chunksize! Continuing anyway.\n",
+ mddev->sb->level);
if (pnum >= MAX_PERSONALITY) {
MD_BUG();
@@ -1700,7 +1705,7 @@
continue;
invalidate_device(rdev->dev, 1);
if (get_hardsect_size(rdev->dev)
- > md_hardsect_sizes[mdidx(mddev)])
+ > md_hardsect_sizes[mdidx(mddev)])
md_hardsect_sizes[mdidx(mddev)] =
get_hardsect_size(rdev->dev);
}
@@ -1711,7 +1716,7 @@
err = mddev->pers->run(mddev);
if (err) {
- printk("md: pers->run() failed ...\n");
+ printk(KERN_ERR "md: pers->run() failed ...\n");
mddev->pers = NULL;
return -EINVAL;
}
@@ -1736,7 +1741,7 @@
#define OUT(x) do { err = (x); goto out; } while (0)
-static int restart_array (mddev_t *mddev)
+static int restart_array(mddev_t *mddev)
{
int err = 0;
@@ -1753,7 +1758,7 @@
mddev->ro = 0;
set_device_ro(mddev_to_kdev(mddev), 0);
- printk (KERN_INFO
+ printk(KERN_INFO
"md: md%d switched to read-write mode.\n", mdidx(mddev));
/*
* Kick recovery or resync if necessary
@@ -1762,7 +1767,7 @@
if (mddev->pers->restart_resync)
mddev->pers->restart_resync(mddev);
} else {
- printk (KERN_ERR "md: md%d has no personality assigned.\n",
+ printk(KERN_ERR "md: md%d has no personality assigned.\n",
mdidx(mddev));
err = -EINVAL;
}
@@ -1776,15 +1781,15 @@
#define STILL_IN_USE \
"md: md%d still in use.\n"
-static int do_md_stop (mddev_t * mddev, int ro)
+static int do_md_stop(mddev_t * mddev, int ro)
{
int err = 0, resync_interrupted = 0;
kdev_t dev = mddev_to_kdev(mddev);
- if (atomic_read(&mddev->active)>1) {
- printk(STILL_IN_USE, mdidx(mddev));
- OUT(-EBUSY);
- }
+ if (atomic_read(&mddev->active)>1) {
+ printk(STILL_IN_USE, mdidx(mddev));
+ OUT(-EBUSY);
+ }
if (mddev->pers) {
/*
@@ -1831,7 +1836,7 @@
* interrupted.
*/
if (!mddev->recovery_running && !resync_interrupted) {
- printk("md: marking sb clean...\n");
+ printk(KERN_INFO "md: marking sb clean...\n");
mddev->sb->state |= 1 << MD_SB_CLEAN;
}
md_update_sb(mddev);
@@ -1844,12 +1849,11 @@
* Free resources if final stop
*/
if (!ro) {
- printk (KERN_INFO "md: md%d stopped.\n", mdidx(mddev));
+ printk(KERN_INFO "md: md%d stopped.\n", mdidx(mddev));
free_mddev(mddev);
} else
- printk (KERN_INFO
- "md: md%d switched to read-only mode.\n", mdidx(mddev));
+ printk(KERN_INFO "md: md%d switched to read-only mode.\n", mdidx(mddev));
out:
return err;
}
@@ -1859,7 +1863,7 @@
/*
* We have to safely support old arrays too.
*/
-int detect_old_array (mdp_super_t *sb)
+int detect_old_array(mdp_super_t *sb)
{
if (sb->major_version > 0)
return 0;
@@ -1870,7 +1874,7 @@
}
-static void autorun_array (mddev_t *mddev)
+static void autorun_array(mddev_t *mddev)
{
mdk_rdev_t *rdev;
struct md_list_head *tmp;
@@ -1881,7 +1885,7 @@
return;
}
- printk("md: running: ");
+ printk(KERN_INFO "md: running: ");
ITERATE_RDEV(mddev,rdev,tmp) {
printk("<%s>", partition_name(rdev->dev));
@@ -1890,7 +1894,7 @@
err = do_md_run (mddev);
if (err) {
- printk("md :do_md_run() returned %d\n", err);
+ printk(KERN_WARNING "md :do_md_run() returned %d\n", err);
/*
* prevent the writeback of an unrunnable array
*/
@@ -1911,7 +1915,7 @@
*
* If "unit" is allocated, then bump its reference count
*/
-static void autorun_devices (kdev_t countdev)
+static void autorun_devices(kdev_t countdev)
{
struct md_list_head candidates;
struct md_list_head *tmp;
@@ -1920,20 +1924,22 @@
kdev_t md_kdev;
- printk("md: autorun ...\n");
+ printk(KERN_INFO "md: autorun ...\n");
while (pending_raid_disks.next != &pending_raid_disks) {
rdev0 = md_list_entry(pending_raid_disks.next,
mdk_rdev_t, pending);
- printk("md: considering %s ...\n", partition_name(rdev0->dev));
+ printk(KERN_INFO "md: considering %s ...\n", partition_name(rdev0->dev));
MD_INIT_LIST_HEAD(&candidates);
ITERATE_RDEV_PENDING(rdev,tmp) {
if (uuid_equal(rdev0, rdev)) {
if (!sb_equal(rdev0->sb, rdev->sb)) {
- printk("md: %s has same UUID as %s, but superblocks differ ...\n", partition_name(rdev->dev), partition_name(rdev0->dev));
+ printk(KERN_WARNING
+ "md: %s has same UUID as %s, but superblocks differ ...\n",
+ partition_name(rdev->dev), partition_name(rdev0->dev));
continue;
}
- printk("md: adding %s ...\n", partition_name(rdev->dev));
+ printk(KERN_INFO "md: adding %s ...\n", partition_name(rdev->dev));
md_list_del(&rdev->pending);
md_list_add(&rdev->pending, &candidates);
}
@@ -1946,20 +1952,20 @@
md_kdev = MKDEV(MD_MAJOR, rdev0->sb->md_minor);
mddev = kdev_to_mddev(md_kdev);
if (mddev) {
- printk("md: md%d already running, cannot run %s\n",
- mdidx(mddev), partition_name(rdev0->dev));
+ printk(KERN_WARNING "md: md%d already running, cannot run %s\n",
+ mdidx(mddev), partition_name(rdev0->dev));
ITERATE_RDEV_GENERIC(candidates,pending,rdev,tmp)
export_rdev(rdev);
continue;
}
mddev = alloc_mddev(md_kdev);
- if (mddev == NULL) {
- printk("md: cannot allocate memory for md drive.\n");
- break;
- }
- if (md_kdev == countdev)
- atomic_inc(&mddev->active);
- printk("md: created md%d\n", mdidx(mddev));
+ if (!mddev) {
+ printk(KERN_ERR "md: cannot allocate memory for md drive.\n");
+ break;
+ }
+ if (md_kdev == countdev)
+ atomic_inc(&mddev->active);
+ printk(KERN_INFO "md: created md%d\n", mdidx(mddev));
ITERATE_RDEV_GENERIC(candidates,pending,rdev,tmp) {
bind_rdev_to_array(rdev, mddev);
md_list_del(&rdev->pending);
@@ -1967,7 +1973,7 @@
}
autorun_array(mddev);
}
- printk("md: ... autorun DONE.\n");
+ printk(KERN_INFO "md: ... autorun DONE.\n");
}
/*
@@ -2002,14 +2008,14 @@
#define AUTORUNNING KERN_INFO \
"md: auto-running md%d.\n"
-static int autostart_array (kdev_t startdev, kdev_t countdev)
+static int autostart_array(kdev_t startdev, kdev_t countdev)
{
int err = -EINVAL, i;
mdp_super_t *sb = NULL;
mdk_rdev_t *start_rdev = NULL, *rdev;
if (md_import_device(startdev, 1)) {
- printk("md: could not import %s!\n", partition_name(startdev));
+ printk(KERN_WARNING "md: could not import %s!\n", partition_name(startdev));
goto abort;
}
@@ -2019,7 +2025,7 @@
goto abort;
}
if (start_rdev->faulty) {
- printk("md: can not autostart based on faulty %s!\n",
+ printk(KERN_WARNING "md: can not autostart based on faulty %s!\n",
partition_name(startdev));
goto abort;
}
@@ -2029,7 +2035,9 @@
err = detect_old_array(sb);
if (err) {
- printk("md: array version is too old to be autostarted, use raidtools 0.90 mkraid --upgrade\nto upgrade the array without data loss!\n");
+ printk(KERN_WARNING "md: array version is too old to be autostarted ,"
+ "use raidtools 0.90 mkraid --upgrade to upgrade the array "
+ "without data loss!\n");
goto abort;
}
@@ -2045,7 +2053,8 @@
if (dev == startdev)
continue;
if (md_import_device(dev, 1)) {
- printk("md: could not import %s, trying to run array nevertheless.\n", partition_name(dev));
+ printk(KERN_WARNING "md: could not import %s, trying to run array nevertheless.\n",
+ partition_name(dev));
continue;
}
rdev = find_rdev_all(dev);
@@ -2078,7 +2087,7 @@
#undef AUTORUNNING
-static int get_version (void * arg)
+static int get_version(void * arg)
{
mdu_version_t ver;
@@ -2093,7 +2102,7 @@
}
#define SET_FROM_SB(x) info.x = mddev->sb->x
-static int get_array_info (mddev_t * mddev, void * arg)
+static int get_array_info(mddev_t * mddev, void * arg)
{
mdu_array_info_t info;
@@ -2131,7 +2140,7 @@
#undef SET_FROM_SB
#define SET_FROM_SB(x) info.x = mddev->sb->disks[nr].x
-static int get_disk_info (mddev_t * mddev, void * arg)
+static int get_disk_info(mddev_t * mddev, void * arg)
{
mdu_disk_info_t info;
unsigned int nr;
@@ -2160,7 +2169,7 @@
#define SET_SB(x) mddev->sb->disks[nr].x = info->x
-static int add_new_disk (mddev_t * mddev, mdu_disk_info_t *info)
+static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
{
int err, size, persistent;
mdk_rdev_t *rdev;
@@ -2169,15 +2178,15 @@
dev = MKDEV(info->major,info->minor);
if (find_rdev_all(dev)) {
- printk("md: device %s already used in a RAID array!\n",
- partition_name(dev));
+ printk(KERN_WARNING "md: device %s already used in a RAID array!\n",
+ partition_name(dev));
return -EBUSY;
}
if (!mddev->sb) {
/* expecting a device which has a superblock */
err = md_import_device(dev, 1);
if (err) {
- printk("md: md_import_device returned %d\n", err);
+ printk(KERN_WARNING "md: md_import_device returned %d\n", err);
return -EINVAL;
}
rdev = find_rdev_all(dev);
@@ -2189,12 +2198,14 @@
mdk_rdev_t *rdev0 = md_list_entry(mddev->disks.next,
mdk_rdev_t, same_set);
if (!uuid_equal(rdev0, rdev)) {
- printk("md: %s has different UUID to %s\n", partition_name(rdev->dev), partition_name(rdev0->dev));
+ printk(KERN_WARNING "md: %s has different UUID to %s\n",
+ partition_name(rdev->dev), partition_name(rdev0->dev));
export_rdev(rdev);
return -EINVAL;
}
if (!sb_equal(rdev0->sb, rdev->sb)) {
- printk("md: %s has same UUID but different superblock to %s\n", partition_name(rdev->dev), partition_name(rdev0->dev));
+ printk(KERN_WARNING "md: %s has same UUID but different superblock to %s\n",
+ partition_name(rdev->dev), partition_name(rdev0->dev));
export_rdev(rdev);
return -EINVAL;
}
@@ -2219,7 +2230,7 @@
if ((info->state & (1<<MD_DISK_FAULTY))==0) {
err = md_import_device (dev, 0);
if (err) {
- printk("md: error, md_import_device() returned %d\n", err);
+ printk(KERN_WARNING "md: error, md_import_device() returned %d\n", err);
return -EINVAL;
}
rdev = find_rdev_all(dev);
@@ -2235,7 +2246,7 @@
persistent = !mddev->sb->not_persistent;
if (!persistent)
- printk("md: nonpersistent superblock ...\n");
+ printk(KERN_INFO "md: nonpersistent superblock ...\n");
size = calc_dev_size(dev, mddev, persistent);
rdev->sb_offset = calc_dev_sboffset(dev, mddev, persistent);
@@ -2253,24 +2264,24 @@
}
#undef SET_SB
-static int hot_generate_error (mddev_t * mddev, kdev_t dev)
+static int hot_generate_error(mddev_t * mddev, kdev_t dev)
{
struct request_queue *q;
mdk_rdev_t *rdev;
mdp_disk_t *disk;
-
+
if (!mddev->pers)
return -ENODEV;
-
- printk("md: trying to generate %s error in md%d ... \n",
+
+ printk(KERN_INFO "md: trying to generate %s error in md%d ... \n",
partition_name(dev), mdidx(mddev));
-
+
rdev = find_rdev(mddev, dev);
if (!rdev) {
MD_BUG();
return -ENXIO;
}
-
+
if (rdev->desc_nr == -1) {
MD_BUG();
return -EINVAL;
@@ -2278,19 +2289,19 @@
disk = &mddev->sb->disks[rdev->desc_nr];
if (!disk_active(disk))
return -ENODEV;
-
+
q = blk_get_queue(rdev->dev);
if (!q) {
MD_BUG();
return -ENODEV;
}
- printk("md: okay, generating error!\n");
+ printk(KERN_INFO "md: okay, generating error!\n");
// q->oneshot_error = 1; // disabled for now
-
+
return 0;
}
-static int hot_remove_disk (mddev_t * mddev, kdev_t dev)
+static int hot_remove_disk(mddev_t * mddev, kdev_t dev)
{
int err;
mdk_rdev_t *rdev;
@@ -2299,12 +2310,12 @@
if (!mddev->pers)
return -ENODEV;
- printk("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));
if (!mddev->pers->diskop) {
- printk("md%d: personality does not support diskops!\n",
- mdidx(mddev));
+ printk(KERN_WARNING "md%d: personality does not support diskops!\n",
+ mdidx(mddev));
return -EINVAL;
}
@@ -2325,7 +2336,7 @@
MD_BUG();
return -EINVAL;
}
-
+
err = mddev->pers->diskop(mddev, &disk, DISKOP_HOT_REMOVE_DISK);
if (err == -EBUSY) {
MD_BUG();
@@ -2343,12 +2354,12 @@
return 0;
busy:
- printk("md: cannot remove active disk %s from md%d ... \n",
+ printk(KERN_WARNING "md: cannot remove active disk %s from md%d ... \n",
partition_name(dev), mdidx(mddev));
return -EBUSY;
}
-static int hot_add_disk (mddev_t * mddev, kdev_t dev)
+static int hot_add_disk(mddev_t * mddev, kdev_t dev)
{
int i, err, persistent;
unsigned int size;
@@ -2358,12 +2369,12 @@
if (!mddev->pers)
return -ENODEV;
- printk("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));
if (!mddev->pers->diskop) {
- printk("md%d: personality does not support diskops!\n",
- mdidx(mddev));
+ printk(KERN_WARNING "md%d: personality does not support diskops!\n",
+ mdidx(mddev));
return -EINVAL;
}
@@ -2371,7 +2382,7 @@
size = calc_dev_size(dev, mddev, persistent);
if (size < mddev->sb->size) {
- printk("md%d: disk size %d blocks < array size %d\n",
+ printk(KERN_WARNING "md%d: disk size %d blocks < array size %d\n",
mdidx(mddev), size, mddev->sb->size);
return -ENOSPC;
}
@@ -2382,7 +2393,7 @@
err = md_import_device (dev, 0);
if (err) {
- printk("md: error, md_import_device() returned %d\n", err);
+ printk(KERN_WARNING "md: error, md_import_device() returned %d\n", err);
return -EINVAL;
}
rdev = find_rdev_all(dev);
@@ -2391,7 +2402,7 @@
return -EINVAL;
}
if (rdev->faulty) {
- printk("md: can not hot-add faulty %s disk to md%d!\n",
+ printk(KERN_WARNING "md: can not hot-add faulty %s disk to md%d!\n",
partition_name(dev), mdidx(mddev));
err = -EINVAL;
goto abort_export;
@@ -2416,7 +2427,8 @@
break;
}
if (i == MD_SB_DISKS) {
- printk("md%d: can not hot-add to full array!\n", mdidx(mddev));
+ printk(KERN_WARNING "md%d: can not hot-add to full array!\n",
+ mdidx(mddev));
err = -EBUSY;
goto abort_unbind_export;
}
@@ -2470,7 +2482,7 @@
}
#define SET_SB(x) mddev->sb->x = info->x
-static int set_array_info (mddev_t * mddev, mdu_array_info_t *info)
+static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
{
if (alloc_array_sb(mddev))
@@ -2511,37 +2523,37 @@
}
#undef SET_SB
-static int set_disk_info (mddev_t * mddev, void * arg)
+static int set_disk_info(mddev_t * mddev, void * arg)
{
- printk("md: not yet");
+ printk(KERN_INFO "md: not yet");
return -EINVAL;
}
-static int clear_array (mddev_t * mddev)
+static int clear_array(mddev_t * mddev)
{
- printk("md: not yet");
+ printk(KERN_INFO "md: not yet");
return -EINVAL;
}
-static int write_raid_info (mddev_t * mddev)
+static int write_raid_info(mddev_t * mddev)
{
- printk("md: not yet");
+ printk(KERN_INFO "md: not yet");
return -EINVAL;
}
-static int protect_array (mddev_t * mddev)
+static int protect_array(mddev_t * mddev)
{
- printk("md: not yet");
+ printk(KERN_INFO "md: not yet");
return -EINVAL;
}
-static int unprotect_array (mddev_t * mddev)
+static int unprotect_array(mddev_t * mddev)
{
- printk("md: not yet");
+ printk(KERN_INFO "md: not yet");
return -EINVAL;
}
-static int set_disk_faulty (mddev_t *mddev, kdev_t dev)
+static int set_disk_faulty(mddev_t *mddev, kdev_t dev)
{
int ret;
@@ -2549,7 +2561,7 @@
return ret;
}
-static int md_ioctl (struct inode *inode, struct file *file,
+static int md_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
unsigned int minor;
@@ -2627,7 +2639,7 @@
case SET_ARRAY_INFO:
case START_ARRAY:
if (mddev) {
- printk("md: array md%d already exists!\n",
+ printk(KERN_WARNING "md: array md%d already exists!\n",
mdidx(mddev));
err = -EEXIST;
goto abort;
@@ -2649,12 +2661,13 @@
*/
err = lock_mddev(mddev);
if (err) {
- printk("md: ioctl, reason %d, cmd %d\n", err, cmd);
+ printk(KERN_WARNING "md: ioctl, reason %d, cmd %d\n",
+ err, cmd);
goto abort;
}
if (mddev->sb) {
- printk("md: array md%d already has a superblock!\n",
+ printk(KERN_WARNING "md: array md%d already has a superblock!\n",
mdidx(mddev));
err = -EBUSY;
goto abort_unlock;
@@ -2667,7 +2680,7 @@
}
err = set_array_info(mddev, &info);
if (err) {
- printk("md: couldnt set array info. %d\n", err);
+ printk(KERN_WARNING "md: couldnt set array info. %d\n", err);
goto abort_unlock;
}
}
@@ -2679,7 +2692,7 @@
*/
err = autostart_array((kdev_t)arg, dev);
if (err) {
- printk("md: autostart %s failed!\n",
+ printk(KERN_WARNING "md: autostart %s failed!\n",
partition_name((kdev_t)arg));
goto abort;
}
@@ -2698,7 +2711,7 @@
}
err = lock_mddev(mddev);
if (err) {
- printk("md: ioctl lock interrupted, reason %d, cmd %d\n",err, cmd);
+ printk(KERN_INFO "md: ioctl lock interrupted, reason %d, cmd %d\n",err, cmd);
goto abort;
}
/* if we don't have a superblock yet, only ADD_NEW_DISK or STOP_ARRAY is allowed */
@@ -2839,7 +2852,9 @@
}
default:
- printk(KERN_WARNING "md: %s(pid %d) used obsolete MD ioctl, upgrade your software to use new ictls.\n", current->comm, current->pid);
+ printk(KERN_WARNING "md: %s(pid %d) used obsolete MD ioctl, "
+ "upgrade your software to use new ictls.\n",
+ current->comm, current->pid);
err = -EINVAL;
goto abort_unlock;
}
@@ -2852,12 +2867,12 @@
return err;
done:
if (err)
- printk("md: huh12?\n");
+ MD_BUG();
abort:
return err;
}
-static int md_open (struct inode *inode, struct file *file)
+static int md_open(struct inode *inode, struct file *file)
{
/*
* Always succeed, but increment the usage count
@@ -2868,7 +2883,7 @@
return (0);
}
-static int md_release (struct inode *inode, struct file * file)
+static int md_release(struct inode *inode, struct file * file)
{
mddev_t *mddev = kdev_to_mddev(inode->i_rdev);
if (mddev)
@@ -2937,11 +2952,8 @@
run(thread->data);
run_task_queue(&tq_disk);
}
- if (md_signal_pending(current)) {
- printk("md: %8s(%d) flushing signals.\n", current->comm,
- current->pid);
+ if (md_signal_pending(current))
md_flush_signals();
- }
}
complete(thread->event);
return 0;
@@ -2954,22 +2966,22 @@
wake_up(&thread->wqueue);
}
-mdk_thread_t *md_register_thread (void (*run) (void *),
+mdk_thread_t *md_register_thread(void (*run) (void *),
void *data, const char *name)
{
mdk_thread_t *thread;
int ret;
struct completion event;
-
+
thread = (mdk_thread_t *) kmalloc
(sizeof(mdk_thread_t), GFP_KERNEL);
if (!thread)
return NULL;
-
+
memset(thread, 0, sizeof(mdk_thread_t));
md_init_waitqueue_head(&thread->wqueue);
- init_completion(&event);
+ init_completion(&event);
thread->event = &event;
thread->run = run;
thread->data = data;
@@ -2983,22 +2995,22 @@
return thread;
}
-void md_interrupt_thread (mdk_thread_t *thread)
+void md_interrupt_thread(mdk_thread_t *thread)
{
if (!thread->tsk) {
MD_BUG();
return;
}
- printk("md: interrupting MD-thread pid %d\n", thread->tsk->pid);
+ dprintk("interrupting MD-thread pid %d\n", thread->tsk->pid);
send_sig(SIGKILL, thread->tsk, 1);
}
-void md_unregister_thread (mdk_thread_t *thread)
+void md_unregister_thread(mdk_thread_t *thread)
{
struct completion event;
init_completion(&event);
-
+
thread->event = &event;
thread->run = NULL;
thread->name = NULL;
@@ -3007,7 +3019,7 @@
kfree(thread);
}
-void md_recover_arrays (void)
+void md_recover_arrays(void)
{
if (!md_recovery_thread) {
MD_BUG();
@@ -3017,12 +3029,15 @@
}
-int md_error (mddev_t *mddev, kdev_t rdev)
+int md_error(mddev_t *mddev, kdev_t rdev)
{
mdk_rdev_t * rrdev;
-/* printk("md_error dev:(%d:%d), rdev:(%d:%d), (caller: %p,%p,%p,%p).\n",MAJOR(dev),MINOR(dev),MAJOR(rdev),MINOR(rdev), __builtin_return_address(0),__builtin_return_address(1),__builtin_return_address(2),__builtin_return_address(3));
- */
+ dprintk("md_error dev:(%d:%d), rdev:(%d:%d), (caller: %p,%p,%p,%p).\n",
+ MAJOR(dev),MINOR(dev),MAJOR(rdev),MINOR(rdev),
+ __builtin_return_address(0),__builtin_return_address(1),
+ __builtin_return_address(2),__builtin_return_address(3));
+
if (!mddev) {
MD_BUG();
return 0;
@@ -3030,7 +3045,7 @@
rrdev = find_rdev(mddev, rdev);
if (!rrdev || rrdev->faulty)
return 0;
- if (mddev->pers->error_handler == NULL
+ if (!mddev->pers->error_handler
|| mddev->pers->error_handler(mddev,rdev) <= 0) {
free_disk_sb(rrdev);
rrdev->faulty = 1;
@@ -3048,7 +3063,7 @@
return 0;
}
-static int status_unused (char * page)
+static int status_unused(char * page)
{
int sz = 0, i = 0;
mdk_rdev_t *rdev;
@@ -3074,7 +3089,7 @@
}
-static int status_resync (char * page, mddev_t * mddev)
+static int status_resync(char * page, mddev_t * mddev)
{
int sz = 0;
unsigned long max_blocks, resync, res, dt, db, rt;
@@ -3084,7 +3099,7 @@
/*
* Should not happen.
- */
+ */
if (!max_blocks) {
MD_BUG();
return 0;
@@ -3126,7 +3141,7 @@
if (!dt) dt++;
db = resync - (mddev->resync_mark_cnt/2);
rt = (dt * ((max_blocks-resync) / (db/100+1)))/100;
-
+
sz += sprintf(page + sz, " finish=%lu.%lumin", rt / 60, (rt % 60)/6);
sz += sprintf(page + sz, " speed=%ldK/sec", db/dt);
@@ -3160,7 +3175,7 @@
sz += sprintf(page + sz, "md%d : %sactive", mdidx(mddev),
mddev->pers ? "" : "in");
if (mddev->pers) {
- if (mddev->ro)
+ if (mddev->ro)
sz += sprintf(page + sz, " (read-only)");
sz += sprintf(page + sz, " %s", mddev->pers->name);
}
@@ -3200,12 +3215,12 @@
}
sz += sprintf(page + sz, "\n");
}
- sz += status_unused (page + sz);
+ sz += status_unused(page + sz);
return sz;
}
-int register_md_personality (int pnum, mdk_personality_t *p)
+int register_md_personality(int pnum, mdk_personality_t *p)
{
if (pnum >= MAX_PERSONALITY) {
MD_BUG();
@@ -3222,7 +3237,7 @@
return 0;
}
-int unregister_md_personality (int pnum)
+int unregister_md_personality(int pnum)
{
if (pnum >= MAX_PERSONALITY) {
MD_BUG();
@@ -3273,7 +3288,7 @@
sync_io[major][index] += nr_sectors;
}
-static int is_mddev_idle (mddev_t *mddev)
+static int is_mddev_idle(mddev_t *mddev)
{
mdk_rdev_t * rdev;
struct md_list_head *tmp;
@@ -3291,9 +3306,7 @@
curr_events = kstat.dk_drive_rblk[major][idx] +
kstat.dk_drive_wblk[major][idx] ;
curr_events -= sync_io[major][idx];
-// printk("md: events(major: %d, idx: %d): %ld\n", major, idx, curr_events);
if ((curr_events - rdev->last_events) > 32) {
-// printk("!I(%ld)%x", curr_events - rdev->last_events, rdev->dev);
rdev->last_events = curr_events;
idle = 0;
}
@@ -3321,7 +3334,7 @@
unsigned int max_sectors, currspeed,
j, window, err, serialize;
unsigned long mark[SYNC_MARKS];
- unsigned long mark_cnt[SYNC_MARKS];
+ unsigned long mark_cnt[SYNC_MARKS];
int last_mark,m;
struct md_list_head *tmp;
unsigned long last_check;
@@ -3337,7 +3350,9 @@
if (mddev2 == mddev)
continue;
if (mddev2->curr_resync && match_mddev_units(mddev,mddev2)) {
- printk(KERN_INFO "md: delaying resync of md%d until md%d has finished resync (they share one or more physical units)\n", mdidx(mddev), mdidx(mddev2));
+ printk(KERN_INFO "md: delaying resync of md%d until md%d "
+ "has finished resync (they share one or more physical units)\n",
+ mdidx(mddev), mdidx(mddev2));
serialize = 1;
break;
}
@@ -3359,7 +3374,9 @@
printk(KERN_INFO "md: syncing RAID array md%d\n", mdidx(mddev));
printk(KERN_INFO "md: minimum _guaranteed_ reconstruction speed: %d KB/sec/disc.\n",
sysctl_speed_limit_min);
- printk(KERN_INFO "md: using maximum available idle IO bandwith (but not more than %d KB/sec) for reconstruction.\n", sysctl_speed_limit_max);
+ printk(KERN_INFO "md: using maximum available idle IO bandwith "
+ "(but not more than %d KB/sec) for reconstruction.\n",
+ sysctl_speed_limit_max);
/*
* Resync has low priority.
@@ -3379,7 +3396,8 @@
* Tune reconstruction:
*/
window = MAX_READAHEAD*(PAGE_SIZE/512);
- printk(KERN_INFO "md: using %dk window, over a total of %d blocks.\n",window/2,max_sectors/2);
+ printk(KERN_INFO "md: using %dk window, over a total of %d blocks.\n",
+ window/2,max_sectors/2);
atomic_set(&mddev->recovery_active, 0);
init_waitqueue_head(&mddev->recovery_wait);
@@ -3401,14 +3419,14 @@
continue;
last_check = j;
-
+
run_task_queue(&tq_disk);
repeat:
if (jiffies >= mark[last_mark] + SYNC_MARK_STEP ) {
/* step marks */
int next = (last_mark+1) % SYNC_MARKS;
-
+
mddev->resync_mark = mark[next];
mddev->resync_mark_cnt = mark_cnt[next];
mark[next] = jiffies;
@@ -3422,7 +3440,7 @@
* got a signal, exit.
*/
mddev->curr_resync = 0;
- printk("md: md_do_sync() got signal ... exiting\n");
+ printk(KERN_INFO "md: md_do_sync() got signal ... exiting\n");
md_flush_signals();
err = -EINTR;
goto out;
@@ -3476,7 +3494,7 @@
* of my root partition with the first 0.5 gigs of my /home partition ... so
* i'm a bit nervous ;)
*/
-void md_do_recovery (void *data)
+void md_do_recovery(void *data)
{
int err;
mddev_t *mddev;
@@ -3495,15 +3513,18 @@
if (sb->active_disks == sb->raid_disks)
continue;
if (!sb->spare_disks) {
- printk(KERN_ERR "md%d: no spare disk to reconstruct array! -- continuing in degraded mode\n", mdidx(mddev));
+ printk(KERN_ERR "md%d: no spare disk to reconstruct array! "
+ "-- continuing in degraded mode\n", mdidx(mddev));
continue;
}
/*
* now here we get the spare and resync it.
*/
- if ((spare = get_spare(mddev)) == NULL)
+ spare = get_spare(mddev);
+ if (!spare)
continue;
- printk(KERN_INFO "md%d: resyncing spare disk %s to replace failed disk\n", mdidx(mddev), partition_name(MKDEV(spare->major,spare->minor)));
+ printk(KERN_INFO "md%d: resyncing spare disk %s to replace failed disk\n",
+ mdidx(mddev), partition_name(MKDEV(spare->major,spare->minor)));
if (!mddev->pers->diskop)
continue;
if (mddev->pers->diskop(mddev, &spare, DISKOP_SPARE_WRITE))
@@ -3512,7 +3533,8 @@
mddev->recovery_running = 1;
err = md_do_sync(mddev, spare);
if (err == -EIO) {
- printk(KERN_INFO "md%d: spare disk %s failed, skipping to next spare.\n", mdidx(mddev), partition_name(MKDEV(spare->major,spare->minor)));
+ printk(KERN_INFO "md%d: spare disk %s failed, skipping to next spare.\n",
+ mdidx(mddev), partition_name(MKDEV(spare->major,spare->minor)));
if (!disk_faulty(spare)) {
mddev->pers->diskop(mddev,&spare,DISKOP_SPARE_INACTIVE);
mark_disk_faulty(spare);
@@ -3556,7 +3578,7 @@
goto restart;
}
printk(KERN_INFO "md: recovery thread finished ...\n");
-
+
}
int md_notify_reboot(struct notifier_block *this,
@@ -3589,7 +3611,7 @@
priority: INT_MAX, /* before any real devices */
};
-static void md_geninit (void)
+static void md_geninit(void)
{
int i;
@@ -3611,18 +3633,18 @@
#endif
}
-int md__init md_init (void)
+int md__init md_init(void)
{
static char * name = "mdrecoveryd";
int minor;
-
- printk (KERN_INFO "md: md driver %d.%d.%d MAX_MD_DEVS=%d, MD_SB_DISKS=%d\n",
+
+ printk(KERN_INFO "md: md driver %d.%d.%d MAX_MD_DEVS=%d, MD_SB_DISKS=%d\n",
MD_MAJOR_VERSION, MD_MINOR_VERSION,
MD_PATCHLEVEL_VERSION, MAX_MD_DEVS, MD_SB_DISKS);
if (devfs_register_blkdev (MAJOR_NR, "md", &md_fops))
{
- printk (KERN_ALERT "md: Unable to get major %d for md\n", MAJOR_NR);
+ printk(KERN_ALERT "md: Unable to get major %d for md\n", MAJOR_NR);
return (-1);
}
devfs_handle = devfs_mk_dir (NULL, "md", NULL);
@@ -3637,7 +3659,7 @@
/* forward all md request to md_make_request */
blk_queue_make_request(BLK_DEFAULT_QUEUE(MAJOR_NR), md_make_request);
-
+
read_ahead[MAJOR_NR] = INT_MAX;
@@ -3678,14 +3700,14 @@
static int detected_devices[128];
static int dev_cnt;
-void md_autodetect_dev (kdev_t dev)
+void md_autodetect_dev(kdev_t dev)
{
if (dev_cnt >= 0 && dev_cnt < 127)
detected_devices[dev_cnt++] = dev;
}
-static void autostart_arrays (void)
+static void autostart_arrays(void)
{
mdk_rdev_t *rdev;
int i;
@@ -3753,21 +3775,22 @@
char *str1 = str;
if (get_option(&str, &minor) != 2) { /* MD Number */
- printk("md: Too few arguments supplied to md=.\n");
+ printk(KERN_WARNING "md: Too few arguments supplied to md=.\n");
return 0;
}
if (minor >= MAX_MD_DEVS) {
- printk ("md: md=%d, Minor device number too high.\n", minor);
+ printk(KERN_WARNING "md: md=%d, Minor device number too high.\n", minor);
return 0;
} else if (md_setup_args.device_names[minor]) {
- printk ("md: md=%d, Specified more then once. Replacing previous definition.\n", minor);
+ printk(KERN_WARNING "md: md=%d, Specified more then once. "
+ "Replacing previous definition.\n", minor);
}
switch (get_option(&str, &level)) { /* RAID Personality */
case 2: /* could be 0 or -1.. */
if (level == 0 || level == -1) {
if (get_option(&str, &factor) != 2 || /* Chunk Size */
get_option(&str, &fault) != 2) {
- printk("md: Too few arguments supplied to md=.\n");
+ printk(KERN_WARNING "md: Too few arguments supplied to md=.\n");
return 0;
}
md_setup_args.pers[minor] = level;
@@ -3782,8 +3805,9 @@
pername = "raid0";
break;
default:
- printk ("md: The kernel has not been configured for raid%d"
- " support!\n", level);
+ printk(KERN_WARNING
+ "md: The kernel has not been configured for raid%d support!\n",
+ level);
return 0;
}
md_setup_args.pers[minor] = level;
@@ -3797,11 +3821,11 @@
md_setup_args.pers[minor] = 0;
pername="super-block";
}
-
- printk ("md: Will configure md%d (%s) from %s, below.\n",
+
+ printk(KERN_INFO "md: Will configure md%d (%s) from %s, below.\n",
minor, pername, str);
md_setup_args.device_names[minor] = str;
-
+
return 1;
}
@@ -3819,13 +3843,14 @@
mdu_disk_info_t dinfo;
if ((devname = md_setup_args.device_names[minor]) == 0) continue;
-
+
for (i = 0; i < MD_SB_DISKS && devname != 0; i++) {
char *p;
void *handle;
-
- if ((p = strchr(devname, ',')) != NULL)
+
+ p = strchr(devname, ',');
+ if (p)
*p++ = 0;
dev = name_to_kdev_t(devname);
@@ -3837,29 +3862,31 @@
dev = MKDEV(major, minor);
}
if (dev == 0) {
- printk ("md: Unknown device name: %s\n", devname);
+ printk(KERN_WARNING "md: Unknown device name: %s\n", devname);
break;
}
-
+
devices[i] = dev;
md_setup_args.device_set[minor] = 1;
-
+
devname = p;
}
devices[i] = 0;
-
+
if (md_setup_args.device_set[minor] == 0)
continue;
-
+
if (mddev_map[minor].mddev) {
- printk("md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n", minor);
+ printk(KERN_WARNING
+ "md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n",
+ minor);
continue;
}
- printk("md: Loading md%d: %s\n", minor, md_setup_args.device_names[minor]);
-
+ printk(KERN_INFO "md: Loading md%d: %s\n", minor, md_setup_args.device_names[minor]);
+
mddev = alloc_mddev(MKDEV(MD_MAJOR,minor));
- if (mddev == NULL) {
- printk("md: kmalloc failed - cannot start array %d\n", minor);
+ if (!mddev) {
+ printk(KERN_ERR "md: kmalloc failed - cannot start array %d\n", minor);
continue;
}
if (md_setup_args.pers[minor]) {
@@ -3905,7 +3932,7 @@
if (err) {
mddev->sb_dirty = 0;
do_md_stop(mddev, 0);
- printk("md: starting md%d failed\n", minor);
+ printk(KERN_WARNING "md: starting md%d failed\n", minor);
}
}
}
@@ -3950,7 +3977,7 @@
#else /* It is a MODULE */
-int init_module (void)
+int init_module(void)
{
return md_init();
}
@@ -3965,7 +3992,7 @@
}
-void cleanup_module (void)
+void cleanup_module(void)
{
md_unregister_thread(md_recovery_thread);
devfs_unregister(devfs_handle);
@@ -3984,7 +4011,7 @@
blk_size[MAJOR_NR] = NULL;
max_readahead[MAJOR_NR] = NULL;
hardsect_size[MAJOR_NR] = NULL;
-
+
free_device_names();
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)