Hi,
The patch below cleans up the struct gendisk handling in the block
device layer for 2.3.40-1. It adds generic [un]register_gendisk
functions, allows the gendisk to be registered automatically during
register_blockdev(), and forces gendisk removal on
unregister_blockdev().
It also adds in a forgotten gendisk registration in the i2o stack.
This code is a prerequisite for the "sard" advanced disk IO accounting
patch, which accumulates disk stats in the gendisk arrays.
--Stephen
----------------------------------------------------------------
--- linux-2.3.39-gendisk/arch/m68k/atari/stram.c.~1~ Thu Jan 13 15:04:51 2000
+++ linux-2.3.39-gendisk/arch/m68k/atari/stram.c Thu Jan 13 15:08:50 2000
@@ -1246,7 +1246,7 @@
/* swapping not enabled */
return( -ENXIO );
- if (register_blkdev( STRAM_MAJOR, "stram", &stram_fops)) {
+ if (register_blkdev( STRAM_MAJOR, "stram", &stram_fops, NULL)) {
printk( KERN_ERR "stram: Unable to get major %d\n", STRAM_MAJOR );
return( -ENXIO );
}
--- linux-2.3.39-gendisk/drivers/acorn/block/fd1772.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/acorn/block/fd1772.c Thu Jan 13 15:08:50 2000
@@ -1580,7 +1580,7 @@
{
int i;
- if (register_blkdev(MAJOR_NR, "fd", &floppy_fops)) {
+ if (register_blkdev(MAJOR_NR, "fd", &floppy_fops,NULL)) {
printk("Unable to get major %d for floppy\n", MAJOR_NR);
return 1;
}
--- linux-2.3.39-gendisk/drivers/acorn/block/mfmhd.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/acorn/block/mfmhd.c Thu Jan 13 15:08:50 2000
@@ -1421,7 +1421,7 @@
{
unsigned char irqmask;
- if (register_blkdev(MAJOR_NR, "mfm", &mfm_fops)) {
+ if (register_blkdev(MAJOR_NR, "mfm", &mfm_fops, &mfm_gendisk)) {
printk("mfm_init: unable to get major number %d\n", MAJOR_NR);
return -1;
}
@@ -1458,11 +1458,6 @@
blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;
read_ahead[MAJOR_NR] = 8; /* 8 sector (4kB?) read ahread */
-
-#ifndef MODULE
- mfm_gendisk.next = gendisk_head;
- gendisk_head = &mfm_gendisk;
-#endif
Busy = 0;
lastspecifieddrive = -1;
--- linux-2.3.39-gendisk/drivers/ap1000/ap.c.~1~ Thu Jan 13 15:04:51 2000
+++ linux-2.3.39-gendisk/drivers/ap1000/ap.c Thu Jan 13 15:08:50 2000
@@ -258,7 +258,7 @@
if (done) return(1);
- if (register_blkdev(MAJOR_NR,"apblock",&ap_fops)) {
+ if (register_blkdev(MAJOR_NR,"apblock",&ap_fops,NULL)) {
printk("ap: unable to get major %d for ap block dev\n",MAJOR_NR);
return -1;
}
--- linux-2.3.39-gendisk/drivers/ap1000/ddv.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/ap1000/ddv.c Thu Jan 13 15:08:50 2000
@@ -917,7 +917,7 @@
cid = mpp_cid();
- if (register_blkdev(MAJOR_NR,DEVICE_NAME,&ddv_fops)) {
+ if (register_blkdev(MAJOR_NR,DEVICE_NAME,&ddv_fops, &ddv_gendisk)) {
printk("ap: unable to get major %d for ap block dev\n",
MAJOR_NR);
return -1;
@@ -928,8 +928,6 @@
read_ahead[MAJOR_NR] = DDV_READ_AHEAD;
bif_add_debug_key('d',ddv_status,"DDV status");
- ddv_gendisk.next = gendisk_head;
- gendisk_head = &ddv_gendisk;
num_options = mpp_num_cells();
this_option = mpp_cid();
@@ -1002,11 +1000,6 @@
OPT_IO(PRST) = PRST_IRST;
unregister_blkdev( MAJOR_NR, DEVICE_NAME );
- for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next))
- if (*gdp == &ddv_gendisk)
- break;
- if (*gdp)
- *gdp = (*gdp)->next;
free_irq(APOPT0_IRQ, NULL);
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
}
--- linux-2.3.39-gendisk/drivers/block/ataflop.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/ataflop.c Thu Jan 13 15:08:57 2000
@@ -1974,7 +1974,7 @@
/* Hades doesn't have Atari-compatible floppy */
return -ENXIO;
- if (register_blkdev(MAJOR_NR,"fd",&floppy_fops)) {
+ if (register_blkdev(MAJOR_NR,"fd",&floppy_fops,NULL)) {
printk(KERN_ERR "Unable to get major %d for floppy\n",MAJOR_NR);
return -EBUSY;
}
--- linux-2.3.39-gendisk/drivers/block/blkpg.c.~1~ Wed May 26 17:30:31 1999
+++ linux-2.3.39-gendisk/drivers/block/blkpg.c Thu Jan 13 15:28:03 2000
@@ -55,21 +55,53 @@
*/
/* a linear search, superfluous when dev is a pointer */
-static struct gendisk *get_gendisk(kdev_t dev) {
- struct gendisk *g;
- int m = MAJOR(dev);
+struct gendisk *get_gendisk(int major) {
+ struct gendisk *gd;
+
+ for (gd = gendisk_head; gd; gd = gd->next)
+ if (gd->major == major)
+ break;
+ return gd;
+}
+
+/* Generic function to register a major device's gendisk structure on
+ * the global list. register_blkdev() calls this automatically if given
+ * a non-NULL gendisk. */
+
+void register_gendisk(unsigned int major, struct gendisk *gendisk)
+{
+ if (get_gendisk(major))
+ return;
+ gendisk->major = major;
+ gendisk->next = gendisk_head;
+ gendisk_head = gendisk;
+}
+
+/* Generic function to unregister a major device's gendisk
+ * structure. Called automatically by unregister_blkdev. */
+
+void unregister_gendisk(unsigned int major)
+{
+ struct gendisk *gd, **gdp;
- for (g = gendisk_head; g; g = g->next)
- if (g->major == m)
+ for (gdp = &gendisk_head; ; gdp = &(gd->next)) {
+ gd = *gdp;
+ if (!gd)
+ return;
+ if (gd->major == major)
break;
- return g;
+ }
+
+ *gdp = gd->next;
+ gd->next = NULL;
}
+
/* moved here from md.c - will be discarded later */
char *partition_name (kdev_t dev) {
static char name[40]; /* kdevname returns 32 bytes */
/* disk_name requires 32 bytes */
- struct gendisk *hd = get_gendisk (dev);
+ struct gendisk *hd = get_gendisk (MAJOR(dev));
if (!hd) {
sprintf (name, "[dev %s]", kdevname(dev));
@@ -104,7 +136,7 @@
return -EINVAL;
/* find the drive major */
- g = get_gendisk(dev);
+ g = get_gendisk(MAJOR(dev));
if (!g)
return -ENXIO;
@@ -154,7 +186,7 @@
int drive, first_minor, minor;
/* find the drive major */
- g = get_gendisk(dev);
+ g = get_gendisk(MAJOR(dev));
if (!g)
return -ENXIO;
@@ -265,7 +297,7 @@
case BLKGETSIZE:
/* Today get_gendisk() requires a linear scan;
add this when dev has pointer type. */
- g = get_gendisk(dev);
+ g = get_gendisk(MAJOR(dev));
if (!g)
longval = 0;
else
--- linux-2.3.39-gendisk/drivers/block/cpqarray.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/cpqarray.c Thu Jan 13 15:08:57 2000
@@ -343,17 +343,6 @@
remove_proc_entry(hba[i]->devname, proc_array);
kfree(hba[i]->cmd_pool);
kfree(hba[i]->cmd_pool_bits);
-
- if (gendisk_head == &ida_gendisk[i]) {
- gendisk_head = ida_gendisk[i].next;
- } else {
- for(g=gendisk_head; g; g=g->next) {
- if (g->next == &ida_gendisk[i]) {
- g->next = ida_gendisk[i].next;
- break;
- }
- }
- }
}
kfree(ida);
@@ -422,7 +411,7 @@
hba[i]->intr, hba[i]->devname);
continue;
}
- if (register_blkdev(MAJOR_NR+i, hba[i]->devname, &ida_fops)) {
+ if (register_blkdev(MAJOR_NR+i, hba[i]->devname, &ida_fops, NULL)) {
printk("Unable to get major number %d for ida\n",
MAJOR_NR+i);
continue;
@@ -478,8 +467,7 @@
read_ahead[MAJOR_NR+i] = READ_AHEAD;
/* Get on the disk list */
- ida_gendisk[i].next = gendisk_head;
- gendisk_head = &ida_gendisk[i];
+ register_gendisk(MAJOR_NR + i, &ida_gendisk[i]);
init_timer(&hba[i]->timer);
hba[i]->timer.expires = jiffies + IDA_TIMER;
--- linux-2.3.39-gendisk/drivers/block/DAC960.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/DAC960.c Thu Jan 13 15:08:57 2000
@@ -1027,7 +1027,7 @@
/*
Register the Block Device Major Number for this DAC960 Controller.
*/
- if (register_blkdev(MajorNumber, "rd", &DAC960_FileOperations) < 0)
+ if (register_blkdev(MajorNumber, "rd", &DAC960_FileOperations, NULL) < 0)
{
DAC960_Error("UNABLE TO ACQUIRE MAJOR NUMBER %d - DETACHING\n",
Controller, MajorNumber);
@@ -1074,13 +1074,7 @@
/*
Install the Generic Disk Information structure at the end of the list.
*/
- if ((GenericDiskInfo = gendisk_head) != NULL)
- {
- while (GenericDiskInfo->next != NULL)
- GenericDiskInfo = GenericDiskInfo->next;
- GenericDiskInfo->next = &Controller->GenericDiskInfo;
- }
- else gendisk_head = &Controller->GenericDiskInfo;
+ register_gendisk(MajorNumber, &Controller->GenericDiskInfo);
/*
Indicate the Block Device Registration completed successfully,
*/
@@ -1114,19 +1108,6 @@
blksize_size[MajorNumber] = NULL;
max_sectors[MajorNumber] = NULL;
max_segments[MajorNumber] = NULL;
- /*
- Remove the Generic Disk Information structure from the list.
- */
- if (gendisk_head != &Controller->GenericDiskInfo)
- {
- GenericDiskInfo_T *GenericDiskInfo = gendisk_head;
- while (GenericDiskInfo != NULL &&
- GenericDiskInfo->next != &Controller->GenericDiskInfo)
- GenericDiskInfo = GenericDiskInfo->next;
- if (GenericDiskInfo != NULL)
- GenericDiskInfo->next = GenericDiskInfo->next->next;
- }
- else gendisk_head = Controller->GenericDiskInfo.next;
}
--- linux-2.3.39-gendisk/drivers/block/floppy.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/floppy.c Thu Jan 13 15:08:57 2000
@@ -4053,7 +4053,7 @@
raw_cmd = 0;
- if (register_blkdev(MAJOR_NR,"fd",&floppy_fops)) {
+ if (register_blkdev(MAJOR_NR,"fd",&floppy_fops,NULL)) {
printk("Unable to get major %d for floppy\n",MAJOR_NR);
return -EBUSY;
}
--- linux-2.3.39-gendisk/drivers/block/hd.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/hd.c Thu Jan 13 15:10:14 2000
@@ -798,14 +798,12 @@
int __init hd_init(void)
{
- if (register_blkdev(MAJOR_NR,"hd",&hd_fops)) {
+ if (register_blkdev(MAJOR_NR,"hd",&hd_fops,&hd_gendisk)) {
printk("hd: unable to get major %d for hard disk\n",MAJOR_NR);
return -1;
}
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
read_ahead[MAJOR_NR] = 8; /* 8 sector (4kB) read-ahead */
- hd_gendisk.next = gendisk_head;
- gendisk_head = &hd_gendisk;
timer_table[HD_TIMER].fn = hd_times_out;
return 0;
}
--- linux-2.3.39-gendisk/drivers/block/ide.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/ide.c Thu Jan 13 15:11:28 2000
@@ -1879,7 +1879,7 @@
void ide_unregister (unsigned int index)
{
- struct gendisk *gd, **gdp;
+ struct gendisk *gd;
ide_drive_t *drive, *d;
ide_hwif_t *hwif, *g;
ide_hwgroup_t *hwgroup;
@@ -1989,6 +1989,7 @@
/*
* Remove us from the kernel's knowledge
*/
+ gd = get_gendisk(hwif->major);
unregister_blkdev(hwif->major, hwif->name);
kfree(blksize_size[hwif->major]);
kfree(max_sectors[hwif->major]);
@@ -1997,13 +1998,9 @@
blk_dev[hwif->major].data = NULL;
blk_dev[hwif->major].queue = NULL;
blksize_size[hwif->major] = NULL;
- for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next))
- if (*gdp == hwif->gd)
- break;
- if (*gdp == NULL)
+ if (gd == NULL)
printk("gd not in disk chain!\n");
else {
- gd = *gdp; *gdp = gd->next;
kfree(gd->sizes);
kfree(gd->part);
kfree(gd);
--- linux-2.3.39-gendisk/drivers/block/ide-probe.c.~1~ Wed Jan 5 12:06:48 2000
+++ linux-2.3.39-gendisk/drivers/block/ide-probe.c Thu Jan 13 15:08:57 2000
@@ -647,7 +647,7 @@
*/
static void init_gendisk (ide_hwif_t *hwif)
{
- struct gendisk *gd, **gdp;
+ struct gendisk *gd;
unsigned int unit, units, minors;
int *bs, *max_sect, *max_ra;
@@ -693,8 +693,8 @@
gd->real_devices= hwif; /* ptr to internal data */
gd->next = NULL; /* linked list of major devs */
- for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next)) ;
- hwif->gd = *gdp = gd; /* link onto tail of list */
+ hwif->gd = gd; /* link onto tail of list */
+ register_gendisk(hwif->major, gd);
for (unit = 0; unit < units; ++unit) {
if (hwif->drives[unit].present)
@@ -757,7 +757,7 @@
printk("%s: request_fn NOT DEFINED\n", hwif->name);
return (hwif->present = 0);
}
- if (register_blkdev (hwif->major, hwif->name, ide_fops)) {
+ if (register_blkdev (hwif->major, hwif->name, ide_fops, NULL)) {
printk("%s: UNABLE TO GET MAJOR NUMBER %d\n", hwif->name, hwif->major);
return (hwif->present = 0);
}
--- linux-2.3.39-gendisk/drivers/block/loop.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/loop.c Thu Jan 13 15:08:57 2000
@@ -715,7 +715,7 @@
{
int i;
- if (register_blkdev(MAJOR_NR, "loop", &lo_fops)) {
+ if (register_blkdev(MAJOR_NR, "loop", &lo_fops, NULL)) {
printk(KERN_WARNING "Unable to get major number %d for loop device\n",
MAJOR_NR);
return -EIO;
--- linux-2.3.39-gendisk/drivers/block/md.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/md.c Thu Jan 13 15:08:57 2000
@@ -1235,7 +1235,7 @@
MD_MAJOR_VERSION, MD_MINOR_VERSION, MD_PATCHLEVEL_VERSION,
MAX_MD_DEV, MAX_REAL);
- if (register_blkdev (MD_MAJOR, "md", &md_fops))
+ if (register_blkdev (MD_MAJOR, "md", &md_fops, &md_gendisk))
{
printk ("Unable to get major %d for md\n", MD_MAJOR);
return (-1);
@@ -1244,9 +1244,6 @@
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
read_ahead[MD_MAJOR]=INT_MAX;
memset(md_dev, 0, MAX_MD_DEV * sizeof (struct md_dev));
- md_gendisk.next=gendisk_head;
-
- gendisk_head=&md_gendisk;
#if SUPPORT_RECONSTRUCTION
if ((md_sync_thread = md_register_thread(mdsyncd, NULL)) == NULL)
--- linux-2.3.39-gendisk/drivers/block/nbd.c.~1~ Thu Jan 13 15:05:23 2000
+++ linux-2.3.39-gendisk/drivers/block/nbd.c Thu Jan 13 15:08:57 2000
@@ -469,7 +469,7 @@
return -EIO;
}
- if (register_blkdev(MAJOR_NR, "nbd", &nbd_fops)) {
+ if (register_blkdev(MAJOR_NR, "nbd", &nbd_fops, NULL)) {
printk("Unable to get major number %d for NBD\n",
MAJOR_NR);
return -EIO;
--- linux-2.3.39-gendisk/drivers/block/paride/pcd.c.~1~ Tue Dec 21 14:42:06 1999
+++ linux-2.3.39-gendisk/drivers/block/paride/pcd.c Thu Jan 13 15:08:57 2000
@@ -335,7 +335,7 @@
/* get the atapi capabilities page */
pcd_probe_capabilities();
- if (register_blkdev(MAJOR_NR,name,&cdrom_fops)) {
+ if (register_blkdev(MAJOR_NR,name,&cdrom_fops,NULL)) {
printk("pcd: unable to get major number %d\n",MAJOR_NR);
return -1;
}
--- linux-2.3.39-gendisk/drivers/block/paride/pd.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/block/paride/pd.c Thu Jan 13 15:08:57 2000
@@ -390,7 +390,7 @@
if (disable) return -1;
- if (register_blkdev(MAJOR_NR,name,&pd_fops)) {
+ if (register_blkdev(MAJOR_NR,name,&pd_fops,&pd_gendisk)) {
printk("%s: unable to get major number %d\n",
name,major);
return -1;
@@ -400,8 +400,6 @@
pd_gendisk.major = major;
pd_gendisk.major_name = name;
- pd_gendisk.next = gendisk_head;
- gendisk_head = &pd_gendisk;
for(i=0;i<PD_DEVS;i++) pd_blocksizes[i] = 1024;
blksize_size[MAJOR_NR] = pd_blocksizes;
@@ -608,14 +606,9 @@
void cleanup_module(void)
-{ struct gendisk **gdp;
- int unit;
+{ int unit;
unregister_blkdev(MAJOR_NR,name);
-
- for(gdp=&gendisk_head;*gdp;gdp=&((*gdp)->next))
- if (*gdp == &pd_gendisk) break;
- if (*gdp) *gdp = (*gdp)->next;
for (unit=0;unit<PD_UNITS;unit++)
if (PD.present) pi_release(PI);
--- linux-2.3.39-gendisk/drivers/block/paride/pf.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/block/paride/pf.c Thu Jan 13 15:08:57 2000
@@ -350,7 +350,7 @@
if (pf_detect()) return -1;
pf_busy = 0;
- if (register_blkdev(MAJOR_NR,name,&pf_fops)) {
+ if (register_blkdev(MAJOR_NR,name,&pf_fops,NULL)) {
printk("pf_init: unable to get major number %d\n",
major);
return -1;
--- linux-2.3.39-gendisk/drivers/block/ps2esdi.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/block/ps2esdi.c Thu Jan 13 15:08:57 2000
@@ -175,7 +175,7 @@
/* register the device - pass the name, major number and operations
vector . */
- if (register_blkdev(MAJOR_NR, "ed", &ps2esdi_fops)) {
+ if (register_blkdev(MAJOR_NR, "ed", &ps2esdi_fops, &ps2esdi_gendisk)) {
printk("%s: Unable to get major number %d\n", DEVICE_NAME, MAJOR_NR);
return -1;
}
@@ -183,9 +183,6 @@
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
read_ahead[MAJOR_NR] = 8; /* 8 sector (4kB) read ahead */
- /* some minor housekeeping - setup the global gendisk structure */
- ps2esdi_gendisk.next = gendisk_head;
- gendisk_head = &ps2esdi_gendisk;
return 0;
} /* ps2esdi_init */
--- linux-2.3.39-gendisk/drivers/block/rd.c.~1~ Thu Jan 13 15:04:53 2000
+++ linux-2.3.39-gendisk/drivers/block/rd.c Thu Jan 13 15:12:15 2000
@@ -379,7 +379,7 @@
return 0;
}
-static struct block_device_operations fd_fops = {
+static struct block_device_operations rd_fops = {
open: rd_open,
release: rd_release,
ioctl: rd_ioctl,
@@ -410,7 +410,7 @@
rd_blocksize = BLOCK_SIZE;
}
- if (register_blkdev(MAJOR_NR, "ramdisk", &fd_fops)) {
+ if (register_blkdev(MAJOR_NR, "ramdisk", &rd_fops, NULL)) {
printk("RAMDISK: Could not get major %d", MAJOR_NR);
return -EIO;
}
--- linux-2.3.39-gendisk/drivers/block/swim3.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/block/swim3.c Thu Jan 13 15:08:57 2000
@@ -1056,7 +1056,7 @@
if (floppy_count > 0)
{
- if (register_blkdev(MAJOR_NR, "fd", &floppy_fops)) {
+ if (register_blkdev(MAJOR_NR, "fd", &floppy_fops, NULL)) {
printk(KERN_ERR "Unable to get major %d for floppy\n",
MAJOR_NR);
return -EBUSY;
--- linux-2.3.39-gendisk/drivers/block/swim_iop.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/block/swim_iop.c Thu Jan 13 15:08:57 2000
@@ -146,7 +146,7 @@
if (!iop_ism_present) return -ENODEV;
- if (register_blkdev(MAJOR_NR, "fd", &floppy_fops)) {
+ if (register_blkdev(MAJOR_NR, "fd", &floppy_fops, NULL)) {
printk(KERN_ERR "SWIM-IOP: Unable to get major %d for floppy\n",
MAJOR_NR);
return -EBUSY;
--- linux-2.3.39-gendisk/drivers/block/xd.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/block/xd.c Thu Jan 13 15:12:45 2000
@@ -173,14 +173,12 @@
/* xd_init: register the block device number and set up pointer tables */
int __init xd_init (void)
{
- if (register_blkdev(MAJOR_NR,"xd",&xd_fops)) {
+ if (register_blkdev(MAJOR_NR,"xd",&xd_fops,&xd_gendisk)) {
printk("xd: Unable to get major number %d\n",MAJOR_NR);
return -1;
}
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
read_ahead[MAJOR_NR] = 8; /* 8 sector (4kB) read ahead */
- xd_gendisk.next = gendisk_head;
- gendisk_head = &xd_gendisk;
return 0;
}
--- linux-2.3.39-gendisk/drivers/block/z2ram.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/block/z2ram.c Thu Jan 13 15:08:57 2000
@@ -342,7 +342,7 @@
if ( !MACH_IS_AMIGA )
return -ENXIO;
- if ( register_blkdev( MAJOR_NR, DEVICE_NAME, &z2_fops ) )
+ if ( register_blkdev( MAJOR_NR, DEVICE_NAME, &z2_fops, NULL ) )
{
printk( KERN_ERR DEVICE_NAME ": Unable to get major %d\n",
MAJOR_NR );
--- linux-2.3.39-gendisk/drivers/cdrom/aztcd.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/cdrom/aztcd.c Thu Jan 13 15:08:57 2000
@@ -1785,7 +1785,7 @@
return -EIO;
}
}
- if (register_blkdev(MAJOR_NR, "aztcd", &azt_fops) != 0)
+ if (register_blkdev(MAJOR_NR, "aztcd", &azt_fops, NULL) != 0)
{
printk("aztcd: Unable to get major %d for Aztech CD-ROM\n",
MAJOR_NR);
--- linux-2.3.39-gendisk/drivers/cdrom/cdu31a.c.~1~ Tue Dec 21 14:42:06 1999
+++ linux-2.3.39-gendisk/drivers/cdrom/cdu31a.c Thu Jan 13 15:08:57 2000
@@ -3441,7 +3441,7 @@
request_region(cdu31a_port, 4,"cdu31a");
- if (register_blkdev(MAJOR_NR,"cdu31a",&cdrom_fops))
+ if (register_blkdev(MAJOR_NR,"cdu31a",&cdrom_fops,NULL))
{
printk("Unable to get major %d for CDU-31a\n", MAJOR_NR);
goto errout2;
--- linux-2.3.39-gendisk/drivers/cdrom/cm206.c.~1~ Tue Dec 21 14:42:06 1999
+++ linux-2.3.39-gendisk/drivers/cdrom/cm206.c Thu Jan 13 15:08:57 2000
@@ -1390,7 +1390,7 @@
return -EIO;
}
printk(".\n");
- if (register_blkdev(MAJOR_NR, "cm206", &cdrom_fops) != 0) {
+ if (register_blkdev(MAJOR_NR, "cm206", &cdrom_fops, NULL) != 0) {
printk(KERN_INFO "Cannot register for major %d!\n", MAJOR_NR);
cleanup(3);
return -EIO;
--- linux-2.3.39-gendisk/drivers/cdrom/gscd.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/cdrom/gscd.c Thu Jan 13 15:08:57 2000
@@ -1067,7 +1067,7 @@
i++;
}
- if (register_blkdev(MAJOR_NR, "gscd", &gscd_fops) != 0)
+ if (register_blkdev(MAJOR_NR, "gscd", &gscd_fops, NULL) != 0)
{
printk("GSCD: Unable to get major %d for GoldStar CD-ROM\n",
MAJOR_NR);
--- linux-2.3.39-gendisk/drivers/cdrom/mcd.c.~1~ Tue Dec 21 14:42:06 1999
+++ linux-2.3.39-gendisk/drivers/cdrom/mcd.c Thu Jan 13 15:08:57 2000
@@ -1181,7 +1181,7 @@
return -EIO;
}
- if (register_blkdev(MAJOR_NR, "mcd", &cdrom_fops) != 0)
+ if (register_blkdev(MAJOR_NR, "mcd", &cdrom_fops, NULL) != 0)
{
printk("Unable to get major %d for Mitsumi CD-ROM\n",
MAJOR_NR);
--- linux-2.3.39-gendisk/drivers/cdrom/mcdx.c.~1~ Tue Dec 21 14:42:06 1999
+++ linux-2.3.39-gendisk/drivers/cdrom/mcdx.c Thu Jan 13 15:08:57 2000
@@ -1123,7 +1123,7 @@
}
xtrace(INIT, "init() register blkdev\n");
- if (register_blkdev(MAJOR_NR, "mcdx", &cdrom_fops) != 0) {
+ if (register_blkdev(MAJOR_NR, "mcdx", &cdrom_fops, NULL) != 0) {
xwarn("%s=0x%3p,%d: Init failed. Can't get major %d.\n",
MCDX,
stuffp->wreg_data, stuffp->irq, MAJOR_NR);
--- linux-2.3.39-gendisk/drivers/cdrom/optcd.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/cdrom/optcd.c Thu Jan 13 15:08:57 2000
@@ -2061,7 +2061,7 @@
DEBUG((DEBUG_VFS, "exec_cmd COMINITDOUBLE: %02x", -status));
return -EIO;
}
- if (register_blkdev(MAJOR_NR, "optcd", &opt_fops) != 0)
+ if (register_blkdev(MAJOR_NR, "optcd", &opt_fops, NULL) != 0)
{
printk(KERN_ERR "optcd: unable to get major %d\n", MAJOR_NR);
return -EIO;
--- linux-2.3.39-gendisk/drivers/cdrom/sbpcd.c.~1~ Tue Dec 21 14:42:06 1999
+++ linux-2.3.39-gendisk/drivers/cdrom/sbpcd.c Thu Jan 13 15:08:57 2000
@@ -5731,7 +5731,7 @@
OUT(MIXER_data,0xCC); /* one nibble per channel, max. value: 0xFF */
#endif SOUND_BASE
- if (register_blkdev(MAJOR_NR, major_name, &cdrom_fops) != 0)
+ if (register_blkdev(MAJOR_NR, major_name, &cdrom_fops, NULL) != 0)
{
msg(DBG_INF, "Can't get MAJOR %d for Matsushita CDROM\n", MAJOR_NR);
#ifdef MODULE
--- linux-2.3.39-gendisk/drivers/cdrom/sjcd.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/cdrom/sjcd.c Thu Jan 13 15:08:57 2000
@@ -1471,7 +1471,7 @@
hardsect_size[MAJOR_NR] = &secsize;
blksize_size[MAJOR_NR] = &blksize;
- if( register_blkdev( MAJOR_NR, "sjcd", &sjcd_fops ) != 0 ){
+ if( register_blkdev( MAJOR_NR, "sjcd", &sjcd_fops, NULL ) != 0 ){
printk( "SJCD: Unable to get major %d for Sanyo CD-ROM\n", MAJOR_NR );
return( -EIO );
}
--- linux-2.3.39-gendisk/drivers/cdrom/sonycd535.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/cdrom/sonycd535.c Thu Jan 13 15:08:57 2000
@@ -1590,7 +1590,7 @@
printk("IRQ%d, ", tmp_irq);
printk("using %d byte buffer\n", sony_buffer_size);
- if (register_blkdev(MAJOR_NR, CDU535_HANDLE, &cdu_fops)) {
+ if (register_blkdev(MAJOR_NR, CDU535_HANDLE, &cdu_fops, NULL)) {
printk("Unable to get major %d for %s\n",
MAJOR_NR, CDU535_MESSAGE_NAME);
return -EIO;
--- linux-2.3.39-gendisk/drivers/i2o/i2o_block.c.~1~ Thu Jan 13 15:05:24 2000
+++ linux-2.3.39-gendisk/drivers/i2o/i2o_block.c Thu Jan 13 15:08:57 2000
@@ -1056,7 +1056,7 @@
* Register the block device interfaces
*/
- if (register_blkdev(MAJOR_NR, "i2o_block", &i2ob_fops)) {
+ if (register_blkdev(MAJOR_NR, "i2o_block", &i2ob_fops, &i2ob_gendisk)) {
printk("Unable to get major number %d for i2o_block\n",
MAJOR_NR);
return -EIO;
@@ -1157,14 +1157,5 @@
*/
if (unregister_blkdev(MAJOR_NR, "i2o_block") != 0)
printk("i2o_block: cleanup_module failed\n");
-
- /*
- * Why isnt register/unregister gendisk in the kernel ???
- */
-
- for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next))
- if (*gdp == &i2ob_gendisk)
- break;
-
}
#endif
--- linux-2.3.39-gendisk/drivers/scsi/sd.c.~1~ Thu Jan 13 15:05:25 2000
+++ linux-2.3.39-gendisk/drivers/scsi/sd.c Thu Jan 13 15:19:04 2000
@@ -975,7 +975,7 @@
if (!sd_registered) {
for (i = 0; i <= (sd_template.dev_max - 1) / SCSI_DISKS_PER_MAJOR; i++) {
- if (register_blkdev(SD_MAJOR(i), "sd", &sd_fops)) {
+ if (register_blkdev(SD_MAJOR(i), "sd", &sd_fops, NULL)) {
printk("Unable to get major %d for SCSI disk\n", SD_MAJOR(i));
return 1;
}
@@ -1023,32 +1023,23 @@
sd_gendisks[i].part = sd + (i * SCSI_DISKS_PER_MAJOR << 4);
sd_gendisks[i].sizes = sd_sizes + (i * SCSI_DISKS_PER_MAJOR << 4);
sd_gendisks[i].nr_real = 0;
- sd_gendisks[i].next = sd_gendisks + i + 1;
sd_gendisks[i].real_devices =
(void *) (rscsi_disks + i * SCSI_DISKS_PER_MAJOR);
}
LAST_SD_GENDISK.max_nr =
(sd_template.dev_max - 1) % SCSI_DISKS_PER_MAJOR + 1;
- LAST_SD_GENDISK.next = NULL;
return 0;
}
static void sd_finish()
{
- struct gendisk *gendisk;
int i;
for (i = 0; i <= (sd_template.dev_max - 1) / SCSI_DISKS_PER_MAJOR; i++) {
blk_dev[SD_MAJOR(i)].queue = sd_find_queue;
- }
- for (gendisk = gendisk_head; gendisk != NULL; gendisk = gendisk->next)
- if (gendisk == sd_gendisks)
- break;
- if (gendisk == NULL) {
- LAST_SD_GENDISK.next = gendisk_head;
- gendisk_head = sd_gendisks;
+ register_gendisk(SD_MAJOR(i), sd_gendisks+i);
}
for (i = 0; i < sd_template.dev_max; ++i)
if (!rscsi_disks[i].capacity &&
@@ -1256,23 +1247,6 @@
scsi_init_free((char *) sd_hardsizes, sd_template.dev_max * sizeof(int));
scsi_init_free((char *) sd,
(sd_template.dev_max << 4) * sizeof(struct hd_struct));
-
- /*
- * Now remove sd_gendisks from the linked list
- */
- prev_sdgd_link = &gendisk_head;
- while ((sdgd = *prev_sdgd_link) != NULL) {
- if (sdgd >= sd_gendisks && sdgd <= &LAST_SD_GENDISK) {
- removed++;
- *prev_sdgd_link = sdgd->next;
- continue;
- }
- prev_sdgd_link = &sdgd->next;
- }
-
- if (removed != N_USED_SD_MAJORS)
- printk("%s %d sd_gendisks in disk chain",
- removed > N_USED_SD_MAJORS ? "total" : "just", removed);
}
for (i = 0; i <= (sd_template.dev_max - 1) / SCSI_DISKS_PER_MAJOR; i++) {
--- linux-2.3.39-gendisk/drivers/scsi/sr.c.~1~ Thu Jan 13 15:04:59 2000
+++ linux-2.3.39-gendisk/drivers/scsi/sr.c Thu Jan 13 15:08:58 2000
@@ -705,7 +705,7 @@
return 0;
if (!sr_registered) {
- if (register_blkdev(MAJOR_NR, "sr", &cdrom_fops)) {
+ if (register_blkdev(MAJOR_NR, "sr", &cdrom_fops, NULL)) {
printk("Unable to get major %d for SCSI-CD\n", MAJOR_NR);
return 1;
}
--- linux-2.3.39-gendisk/fs/block_dev.c.~1~ Thu Jan 13 15:05:26 2000
+++ linux-2.3.39-gendisk/fs/block_dev.c Thu Jan 13 15:19:47 2000
@@ -458,7 +458,7 @@
return ret;
}
-int register_blkdev(unsigned int major, const char * name, struct block_device_operations *bdops)
+int register_blkdev(unsigned int major, const char * name, struct block_device_operations *bdops, struct gendisk *gendisk)
{
if (major == 0) {
for (major = MAX_BLKDEV-1; major > 0; major--) {
@@ -476,6 +476,10 @@
return -EBUSY;
blkdevs[major].name = name;
blkdevs[major].bdops = bdops;
+
+ if (gendisk)
+ register_gendisk(major, gendisk);
+
return 0;
}
@@ -489,6 +493,7 @@
return -EINVAL;
blkdevs[major].name = NULL;
blkdevs[major].bdops = NULL;
+ unregister_gendisk(major);
return 0;
}
--- linux-2.3.39-gendisk/include/linux/fs.h.~1~ Thu Jan 13 15:05:44 2000
+++ linux-2.3.39-gendisk/include/linux/fs.h Thu Jan 13 15:29:19 2000
@@ -767,8 +767,9 @@
#define putname(name) free_page((unsigned long)(name))
enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};
+struct gendisk;
extern void kill_fasync(struct fasync_struct *, int, int);
-extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);
+extern int register_blkdev(unsigned int, const char *, struct block_device_operations *, struct gendisk *);
extern int unregister_blkdev(unsigned int, const char *);
extern struct block_device *bdget(dev_t);
extern void bdput(struct block_device *);
--- linux-2.3.39-gendisk/include/linux/genhd.h.~1~ Tue Sep 7 19:28:53 1999
+++ linux-2.3.39-gendisk/include/linux/genhd.h Thu Jan 13 15:21:16 2000
@@ -218,6 +218,10 @@
char *disk_name (struct gendisk *hd, int minor, char *buf);
int get_hardsect_size(kdev_t dev);
+struct gendisk *get_gendisk(int major);
+void register_gendisk(unsigned int major, struct gendisk *gendisk);
+void unregister_gendisk(unsigned int major);
+
#endif
#endif
--- linux-2.3.39-gendisk/kernel/ksyms.c.~1~ Thu Jan 13 15:05:31 2000
+++ linux-2.3.39-gendisk/kernel/ksyms.c Thu Jan 13 15:08:58 2000
@@ -261,6 +261,8 @@
EXPORT_SYMBOL(blkdev_put);
EXPORT_SYMBOL(ioctl_by_bdev);
EXPORT_SYMBOL(gendisk_head);
+EXPORT_SYMBOL(register_gendisk);
+EXPORT_SYMBOL(unregister_gendisk);
EXPORT_SYMBOL(resetup_one_dev);
EXPORT_SYMBOL(unplug_device);
EXPORT_SYMBOL(make_request);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:22 EST