mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.194 (3eaec3046yAItB06JdZkroeL7XKJxA)
xl_ide.c, xl_block.h, xl_block.c, defconfig: Fix Xenolinux to use major 22 for /dev/hdc and /dev/hdd. Added TMPFS to defconfig.
This commit is contained in:
1 parent
455321c200
commit
4ecf7e405c
4 files changed
+145
-113
No files matched your search
@@ -157,7 +157,7 @@ CONFIG_JBD=y
|
||||
# CONFIG_JFFS_FS is not set
|
||||
# CONFIG_JFFS2_FS is not set
|
||||
# CONFIG_CRAMFS is not set
|
||||
# CONFIG_TMPFS is not set
|
||||
CONFIG_TMPFS=y
|
||||
CONFIG_RAMFS=y
|
||||
CONFIG_ISO9660_FS=y
|
||||
CONFIG_JOLIET=y
|
||||
|
||||
@@ -49,10 +49,16 @@ inline unsigned short xldev_to_physdev(kdev_t xldev)
|
||||
|
||||
switch ( MAJOR(xldev) )
|
||||
{
|
||||
case XLIDE_MAJOR:
|
||||
physdev = XENDEV_IDE + (MINOR(xldev) >> XLIDE_PARTN_SHIFT);
|
||||
case XLIDE_MAJOR_0:
|
||||
physdev = XENDEV_IDE + (0*XLIDE_DEVS_PER_MAJOR) +
|
||||
(MINOR(xldev) >> XLIDE_PARTN_SHIFT);
|
||||
break;
|
||||
|
||||
|
||||
case XLIDE_MAJOR_1:
|
||||
physdev = XENDEV_IDE + (1*XLIDE_DEVS_PER_MAJOR) +
|
||||
(MINOR(xldev) >> XLIDE_PARTN_SHIFT);
|
||||
break;
|
||||
|
||||
case XLSCSI_MAJOR:
|
||||
physdev = XENDEV_SCSI + (MINOR(xldev) >> XLSCSI_PARTN_SHIFT);
|
||||
break;
|
||||
@@ -74,8 +80,12 @@ static inline struct gendisk *xldev_to_gendisk(kdev_t xldev)
|
||||
|
||||
switch ( MAJOR(xldev) )
|
||||
{
|
||||
case XLIDE_MAJOR:
|
||||
gd = xlide_gendisk;
|
||||
case XLIDE_MAJOR_0:
|
||||
gd = xlide_gendisk[0];
|
||||
break;
|
||||
|
||||
case XLIDE_MAJOR_1:
|
||||
gd = xlide_gendisk[1];
|
||||
break;
|
||||
|
||||
case XLSCSI_MAJOR:
|
||||
@@ -157,7 +167,7 @@ int xenolinux_block_ioctl(struct inode *inode, struct file *filep,
|
||||
case BLKSSZGET:
|
||||
switch ( MAJOR(dev) )
|
||||
{
|
||||
case XLIDE_MAJOR:
|
||||
case XLIDE_MAJOR_0:
|
||||
DPRINTK_IOCTL(" BLKSSZGET: %x 0x%x\n", BLKSSZGET,
|
||||
xlide_hwsect(MINOR(dev)));
|
||||
return xlide_hwsect(MINOR(dev));
|
||||
|
||||
@@ -40,18 +40,33 @@
|
||||
#endif
|
||||
|
||||
/* XL IDE and SCSI use same major/minor numbers as normal Linux devices. */
|
||||
#define XLIDE_MAJOR IDE0_MAJOR
|
||||
#define XLIDE_MAJOR_0 IDE0_MAJOR
|
||||
#define XLIDE_MAJOR_1 IDE1_MAJOR
|
||||
#define XLSCSI_MAJOR SCSI_DISK0_MAJOR
|
||||
|
||||
/* IDE has < 64 partitions per device. VIRT and SCSI have < 16. */
|
||||
#define PARTN_SHIFT(_dev) ((MAJOR(_dev)==IDE0_MAJOR) ? 6 : 4)
|
||||
#define XLIDE_PARTN_SHIFT 6
|
||||
#define XLSCSI_PARTN_SHIFT 4
|
||||
#define XLVIRT_PARTN_SHIFT 4
|
||||
|
||||
#define XLIDE_DEVS_PER_MAJOR (256 >> XLIDE_PARTN_SHIFT)
|
||||
#define XLSCSI_DEVS_PER_MAJOR (256 >> XLSCSI_PARTN_SHIFT)
|
||||
#define XLVIRT_DEVS_PER_MAJOR (256 >> XLVIRT_PARTN_SHIFT)
|
||||
static inline int PARTN_SHIFT(kdev_t dev)
|
||||
{
|
||||
switch ( MAJOR(dev) )
|
||||
{
|
||||
case XLIDE_MAJOR_0:
|
||||
case XLIDE_MAJOR_1:
|
||||
return XLIDE_PARTN_SHIFT;
|
||||
case XLSCSI_MAJOR:
|
||||
return XLSCSI_PARTN_SHIFT;
|
||||
case XLVIRT_MAJOR:
|
||||
return XLVIRT_PARTN_SHIFT;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
}
|
||||
|
||||
#define XLIDE_DEVS_PER_MAJOR 2
|
||||
#define XLSCSI_DEVS_PER_MAJOR 16
|
||||
#define XLVIRT_DEVS_PER_MAJOR 16
|
||||
|
||||
/*
|
||||
* We have one of these per XL-IDE, XL-SCSI, and XL-VIRT device.
|
||||
@@ -77,7 +92,7 @@ extern void do_xlblk_request (request_queue_t *rq);
|
||||
extern int xlide_init(xen_disk_info_t *xdi);
|
||||
extern int xlide_hwsect(int minor);
|
||||
extern void xlide_cleanup(void);
|
||||
extern struct gendisk *xlide_gendisk;
|
||||
extern struct gendisk *xlide_gendisk[];
|
||||
|
||||
/* Fake SCSI subsystem. */
|
||||
extern int xlscsi_init(xen_disk_info_t *xdi);
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
*/
|
||||
|
||||
#include "xl_block.h"
|
||||
|
||||
#define MAJOR_NR XLIDE_MAJOR
|
||||
#include <linux/blk.h>
|
||||
|
||||
#define XLIDE_MAX 256
|
||||
@@ -15,7 +13,7 @@ static int xlide_blksize_size[XLIDE_MAX];
|
||||
static int xlide_hardsect_size[XLIDE_MAX];
|
||||
static int xlide_max_sectors[XLIDE_MAX];
|
||||
|
||||
struct gendisk *xlide_gendisk = NULL;
|
||||
struct gendisk *xlide_gendisk[2] = { NULL };
|
||||
|
||||
static struct block_device_operations xlide_block_fops =
|
||||
{
|
||||
@@ -31,63 +29,41 @@ int xlide_hwsect(int minor)
|
||||
return xlide_hardsect_size[minor];
|
||||
}
|
||||
|
||||
|
||||
int xlide_init(xen_disk_info_t *xdi)
|
||||
static int get_major(int major)
|
||||
{
|
||||
int i, result, units, minors, disk;
|
||||
int r = register_blkdev(major, XLIDE_MAJOR_NAME, &xlide_block_fops);
|
||||
if ( r < 0 )
|
||||
printk (KERN_ALERT "XL IDE: can't get major %d\n", XLIDE_MAJOR_0);
|
||||
return r;
|
||||
}
|
||||
|
||||
static struct gendisk *setup_major(xen_disk_info_t *xdi, int base, int major)
|
||||
{
|
||||
int i, minors, disk, units = 2;
|
||||
unsigned short minor;
|
||||
unsigned char buf[64];
|
||||
struct gendisk *gd;
|
||||
char buf[64];
|
||||
|
||||
/* If we don't have any usable IDE devices we may as well bail now. */
|
||||
units = 0;
|
||||
for ( i = 0; i < xdi->count; i++ )
|
||||
if ( IS_IDE_XENDEV(xdi->disks[i].device) &&
|
||||
((xdi->disks[i].device & XENDEV_IDX_MASK) <
|
||||
XLIDE_DEVS_PER_MAJOR) )
|
||||
units++;
|
||||
if ( units == 0 ) return 0;
|
||||
blk_size[major] = NULL;
|
||||
blksize_size[major] = xlide_blksize_size + base*XLIDE_DEVS_PER_MAJOR;
|
||||
hardsect_size[major] = xlide_hardsect_size + base*XLIDE_DEVS_PER_MAJOR;
|
||||
max_sectors[major] = xlide_max_sectors + base*XLIDE_DEVS_PER_MAJOR;
|
||||
read_ahead[major] = 8;
|
||||
|
||||
SET_MODULE_OWNER(&xlide_block_fops);
|
||||
|
||||
result = register_blkdev(XLIDE_MAJOR, XLIDE_MAJOR_NAME,
|
||||
&xlide_block_fops);
|
||||
if ( result < 0 )
|
||||
{
|
||||
printk (KERN_ALERT "XL IDE: can't get major %d\n", XLIDE_MAJOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Initialize global arrays. */
|
||||
for ( i = 0; i < XLIDE_MAX; i++ )
|
||||
{
|
||||
xlide_blksize_size[i] = 512;
|
||||
xlide_hardsect_size[i] = 512;
|
||||
xlide_max_sectors[i] = 128;
|
||||
}
|
||||
|
||||
blk_size[XLIDE_MAJOR] = NULL;
|
||||
blksize_size[XLIDE_MAJOR] = xlide_blksize_size;
|
||||
hardsect_size[XLIDE_MAJOR] = xlide_hardsect_size;
|
||||
max_sectors[XLIDE_MAJOR] = xlide_max_sectors;
|
||||
read_ahead[XLIDE_MAJOR] = 8;
|
||||
|
||||
blk_init_queue(BLK_DEFAULT_QUEUE(XLIDE_MAJOR), do_xlblk_request);
|
||||
blk_init_queue(BLK_DEFAULT_QUEUE(major), do_xlblk_request);
|
||||
|
||||
/*
|
||||
* Turn off barking 'headactive' mode. We dequeue buffer heads as
|
||||
* soon as we pass them down to Xen.
|
||||
* Turn off barking 'headactive' mode. We dequeue buffer heads as soon as
|
||||
* we pass them down to Xen.
|
||||
*/
|
||||
blk_queue_headactive(BLK_DEFAULT_QUEUE(XLIDE_MAJOR), 0);
|
||||
|
||||
units = XLIDE_MAX >> XLIDE_PARTN_SHIFT;
|
||||
blk_queue_headactive(BLK_DEFAULT_QUEUE(major), 0);
|
||||
|
||||
/* Construct an appropriate gendisk structure. */
|
||||
minors = units * (1<<XLIDE_PARTN_SHIFT);
|
||||
gd = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
|
||||
gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
|
||||
gd->part = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
|
||||
gd->major = XLIDE_MAJOR;
|
||||
gd->major = major;
|
||||
gd->major_name = XLIDE_MAJOR_NAME;
|
||||
gd->minor_shift = XLIDE_PARTN_SHIFT;
|
||||
gd->max_p = 1<<XLIDE_PARTN_SHIFT;
|
||||
@@ -102,92 +78,123 @@ int xlide_init(xen_disk_info_t *xdi)
|
||||
memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
|
||||
memset(gd->flags, 0, sizeof(*gd->flags) * units);
|
||||
memset(gd->real_devices, 0, sizeof(xl_disk_t) * units);
|
||||
xlide_gendisk = gd;
|
||||
add_gendisk(gd);
|
||||
|
||||
/* Now register each disk in turn. */
|
||||
for ( i = 0; i < xdi->count; i++ )
|
||||
{
|
||||
disk = xdi->disks[i].device & XENDEV_IDX_MASK;
|
||||
minor = disk << XLIDE_PARTN_SHIFT;
|
||||
minor = (disk-base) << XLIDE_PARTN_SHIFT;
|
||||
|
||||
|
||||
if ( !IS_IDE_XENDEV(xdi->disks[i].device) ||
|
||||
(disk >= XLIDE_DEVS_PER_MAJOR) )
|
||||
if ( !IS_IDE_XENDEV(xdi->disks[i].device) ||
|
||||
(disk < base) || (disk >= (base + XLIDE_DEVS_PER_MAJOR)) )
|
||||
continue;
|
||||
|
||||
((xl_disk_t *)gd->real_devices)[disk].capacity =
|
||||
xdi->disks[i].capacity;
|
||||
|
||||
switch (xdi->disks[i].type)
|
||||
{
|
||||
case XD_TYPE_CDROM:
|
||||
set_device_ro(MKDEV(major, minor), 1);
|
||||
|
||||
switch (xdi->disks[i].type) {
|
||||
case XD_TYPE_CDROM:
|
||||
set_device_ro(MKDEV(XLIDE_MAJOR, minor), 1);
|
||||
// fall through
|
||||
|
||||
case XD_TYPE_FLOPPY:
|
||||
case XD_TYPE_TAPE:
|
||||
gd->flags[disk] = GENHD_FL_REMOVABLE;
|
||||
printk(KERN_ALERT "Skipping partition check on %s /dev/%s\n",
|
||||
xdi->disks[i].type == XD_TYPE_CDROM ? "cdrom" :
|
||||
(xdi->disks[i].type == XD_TYPE_TAPE ? "tape" : "floppy"),
|
||||
disk_name(gd, minor, buf));
|
||||
break;
|
||||
|
||||
case XD_TYPE_DISK:
|
||||
register_disk(gd, MKDEV(XLIDE_MAJOR, minor), 1<<XLIDE_PARTN_SHIFT,
|
||||
&xlide_block_fops, xdi->disks[i].capacity);
|
||||
break;
|
||||
|
||||
default:
|
||||
printk(KERN_ALERT "XenoLinux: unknown ide device type %d\n",
|
||||
xdi->disks[i].type);
|
||||
break;
|
||||
}
|
||||
case XD_TYPE_FLOPPY:
|
||||
case XD_TYPE_TAPE:
|
||||
gd->flags[disk] = GENHD_FL_REMOVABLE;
|
||||
printk(KERN_ALERT "Skipping partition check on %s /dev/%s\n",
|
||||
xdi->disks[i].type==XD_TYPE_CDROM ? "cdrom" :
|
||||
(xdi->disks[i].type==XD_TYPE_TAPE ? "tape" : "floppy"),
|
||||
disk_name(gd, minor, buf));
|
||||
break;
|
||||
|
||||
case XD_TYPE_DISK:
|
||||
register_disk(gd,
|
||||
MKDEV(major, minor),
|
||||
1<<XLIDE_PARTN_SHIFT,
|
||||
&xlide_block_fops, xdi->disks[i].capacity);
|
||||
break;
|
||||
|
||||
default:
|
||||
printk(KERN_ALERT "XenoLinux: unknown ide device type %d\n",
|
||||
xdi->disks[i].type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printk(KERN_ALERT
|
||||
"XenoLinux Virtual IDE Device Driver installed [device: %d]\n",
|
||||
XLIDE_MAJOR);
|
||||
return gd;
|
||||
}
|
||||
|
||||
|
||||
int xlide_init(xen_disk_info_t *xdi)
|
||||
{
|
||||
int i, units;
|
||||
|
||||
/* If we don't have any usable IDE devices we may as well bail now. */
|
||||
units = 0;
|
||||
for ( i = 0; i < xdi->count; i++ )
|
||||
if ( IS_IDE_XENDEV(xdi->disks[i].device) &&
|
||||
((xdi->disks[i].device & XENDEV_IDX_MASK) <
|
||||
XLIDE_DEVS_PER_MAJOR) )
|
||||
units++;
|
||||
if ( units == 0 ) return 0;
|
||||
|
||||
SET_MODULE_OWNER(&xlide_block_fops);
|
||||
|
||||
if ( get_major(XLIDE_MAJOR_0) < 0 )
|
||||
return 0;
|
||||
if ( get_major(XLIDE_MAJOR_1) < 0 )
|
||||
{
|
||||
(void)unregister_blkdev(XLIDE_MAJOR_0, XLIDE_MAJOR_NAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize global arrays. */
|
||||
for ( i = 0; i < XLIDE_MAX; i++ )
|
||||
{
|
||||
xlide_blksize_size[i] = 512;
|
||||
xlide_hardsect_size[i] = 512;
|
||||
xlide_max_sectors[i] = 128;
|
||||
}
|
||||
|
||||
xlide_gendisk[0] = setup_major(xdi, 0, XLIDE_MAJOR_0);
|
||||
xlide_gendisk[1] = setup_major(xdi, 2, XLIDE_MAJOR_1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void xlide_cleanup(void)
|
||||
static void cleanup_major(int major)
|
||||
{
|
||||
if ( xlide_gendisk == NULL ) return;
|
||||
blk_cleanup_queue(BLK_DEFAULT_QUEUE(major));
|
||||
|
||||
blk_cleanup_queue(BLK_DEFAULT_QUEUE(XLIDE_MAJOR));
|
||||
read_ahead[major] = 0;
|
||||
|
||||
xlide_gendisk = NULL;
|
||||
|
||||
read_ahead[XLIDE_MAJOR] = 0;
|
||||
|
||||
if ( blksize_size[XLIDE_MAJOR] != NULL )
|
||||
if ( blksize_size[major] != NULL )
|
||||
{
|
||||
kfree(blksize_size[XLIDE_MAJOR]);
|
||||
blksize_size[XLIDE_MAJOR] = NULL;
|
||||
kfree(blksize_size[major]);
|
||||
blksize_size[major] = NULL;
|
||||
}
|
||||
|
||||
if ( hardsect_size[XLIDE_MAJOR] != NULL )
|
||||
if ( hardsect_size[major] != NULL )
|
||||
{
|
||||
kfree(hardsect_size[XLIDE_MAJOR]);
|
||||
hardsect_size[XLIDE_MAJOR] = NULL;
|
||||
kfree(hardsect_size[major]);
|
||||
hardsect_size[major] = NULL;
|
||||
}
|
||||
|
||||
if ( max_sectors[XLIDE_MAJOR] != NULL )
|
||||
if ( max_sectors[major] != NULL )
|
||||
{
|
||||
kfree(max_sectors[XLIDE_MAJOR]);
|
||||
max_sectors[XLIDE_MAJOR] = NULL;
|
||||
kfree(max_sectors[major]);
|
||||
max_sectors[major] = NULL;
|
||||
}
|
||||
|
||||
if ( unregister_blkdev(XLIDE_MAJOR, XLIDE_MAJOR_NAME) != 0 )
|
||||
{
|
||||
printk(KERN_ALERT
|
||||
"XenoLinux Virtual IDE Device Driver uninstalled w/ errs\n");
|
||||
}
|
||||
(void)unregister_blkdev(major, XLIDE_MAJOR_NAME);
|
||||
}
|
||||
|
||||
void xlide_cleanup(void)
|
||||
{
|
||||
if ( xlide_gendisk[0] == NULL ) return;
|
||||
xlide_gendisk[0] = NULL;
|
||||
cleanup_major(XLIDE_MAJOR_0);
|
||||
cleanup_major(XLIDE_MAJOR_1);
|
||||
}
|
||||
|
||||