ia64/xen-unstable

changeset 894:92d4612dd1bc

bitkeeper revision 1.562 (3fa8e5aaqKhimMpbH8Bdw8wPYE1UaA)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/local/scratch/smh22/xeno.bk
author smh22@labyrinth.cl.cam.ac.uk
date Wed Nov 05 11:57:30 2003 +0000 (2003-11-05)
parents 9d372131886a 211811259dff
children e50a38309067
files .rootkeys BitKeeper/etc/ignore tools/internal/Makefile tools/internal/dom0_defs.h tools/internal/xi_phys_grant.c tools/internal/xi_phys_probe.c tools/internal/xi_phys_revoke.c tools/misc/Makefile xen/common/domain.c xen/drivers/block/xen_block.c xen/drivers/block/xen_vbd.c xen/drivers/ide/ide-xeno.c xen/drivers/scsi/sd.c xen/include/hypervisor-ifs/block.h xen/include/hypervisor-ifs/vbd.h xen/include/xeno/sched.h xen/include/xeno/vbd.h xenolinux-2.4.22-sparse/arch/xeno/drivers/block/Makefile xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.h xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_ide.c xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_scsi.c xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c xenolinux-2.4.22-sparse/arch/xeno/drivers/dom0/dom0_core.c xenolinux-2.4.22-sparse/fs/partitions/Config.in xenolinux-2.4.22-sparse/fs/partitions/Makefile xenolinux-2.4.22-sparse/fs/partitions/check.c xenolinux-2.4.22-sparse/fs/partitions/xeno.c xenolinux-2.4.22-sparse/fs/partitions/xeno.h xenolinux-2.4.22-sparse/include/asm-xeno/proc_cmd.h
line diff
     1.1 --- a/.rootkeys	Wed Nov 05 11:50:12 2003 +0000
     1.2 +++ b/.rootkeys	Wed Nov 05 11:57:30 2003 +0000
     1.3 @@ -169,8 +169,6 @@ 3eb781fdcJ0fF7rWfzAOArW-x4-gwA tools/int
     1.4  3ec43c5dmQxGDvgJJXbV1yLxT30Y1A tools/internal/xi_helper
     1.5  3f108ad5wQm0ZaQ4GXFoUhH1W1aW9w tools/internal/xi_list.c
     1.6  3f0458aaXhD8BQAggO81gv30RQ-ifA tools/internal/xi_phys_grant.c
     1.7 -3f0458aaJHmlzkDwf0qxEzAcjX55sg tools/internal/xi_phys_probe.c
     1.8 -3f0458aaVAbFSwptQbQAnDOiZlwQ3w tools/internal/xi_phys_revoke.c
     1.9  3f108adb2b5OkKL6-faG3lMiOYDf_w tools/internal/xi_sched_domain.c
    1.10  3f108ade1v8weyh1sKx890VTd240Hw tools/internal/xi_sched_global.c
    1.11  3eb781fd8oRfPgH7qTh7xvgmwD6NgA tools/internal/xi_start.c
    1.12 @@ -571,8 +569,6 @@ 3e5a4e65iHEuC5sjFhj42XALYbLVRw xenolinux
    1.13  3f689056Vxx_8K8DQTRysOxx_ikmLg xenolinux-2.4.22-sparse/arch/xeno/drivers/block/info.c
    1.14  3e5a4e65pP5spJErBW69pJxSSdK9RA xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c
    1.15  3e67f822FOPwqHiaRKbrskgWgoNL5g xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.h
    1.16 -3e677190SjkzJIvFifRVeYpIZOCtYA xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_ide.c
    1.17 -3e677193nOKKTLJzcAu4SYdbZaia8g xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_scsi.c
    1.18  3e676eb5RXnHzSHgA1BvM0B1aIm4qg xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c
    1.19  3e5a4e65G3e2s0ghPMgiJ-gBTUJ0uQ xenolinux-2.4.22-sparse/arch/xeno/drivers/console/Makefile
    1.20  3e5a4e651TH-SXHoufurnWjgl5bfOA xenolinux-2.4.22-sparse/arch/xeno/drivers/console/console.c
    1.21 @@ -607,11 +603,6 @@ 3e5a4e66mrtlmV75L1tjKDg8RaM5gA xenolinux
    1.22  3f108aeaLcGDgQdFAANLTUEid0a05w xenolinux-2.4.22-sparse/drivers/char/mem.c
    1.23  3e5a4e66rw65CxyolW9PKz4GG42RcA xenolinux-2.4.22-sparse/drivers/char/tty_io.c
    1.24  3e5a4e669uzIE54VwucPYtGwXLAbzA xenolinux-2.4.22-sparse/fs/exec.c
    1.25 -3f05a939l8s0eQb_fpMvYiI06cTGlA xenolinux-2.4.22-sparse/fs/partitions/Config.in
    1.26 -3f05a939W65febbeWrBtuQgsQDK2Bg xenolinux-2.4.22-sparse/fs/partitions/Makefile
    1.27 -3f05a939phguW4R5PelNQZ8o_EcYZA xenolinux-2.4.22-sparse/fs/partitions/check.c
    1.28 -3f05a939ZSKN7gX2sfTLzPcYJvPkcQ xenolinux-2.4.22-sparse/fs/partitions/xeno.c
    1.29 -3f05a939_I9vPADPgyVBwUDUxtoeOQ xenolinux-2.4.22-sparse/fs/partitions/xeno.h
    1.30  3e5a4e66wbeCpsJgVf_U8Jde-CNcsA xenolinux-2.4.22-sparse/include/asm-xeno/bugs.h
    1.31  3e5a4e66HdSkvIV6SJ1evG_xmTmXHA xenolinux-2.4.22-sparse/include/asm-xeno/desc.h
    1.32  3e5a4e66SYp_UpAVcF8Lc1wa3Qtgzw xenolinux-2.4.22-sparse/include/asm-xeno/fixmap.h
     2.1 --- a/BitKeeper/etc/ignore	Wed Nov 05 11:50:12 2003 +0000
     2.2 +++ b/BitKeeper/etc/ignore	Wed Nov 05 11:57:30 2003 +0000
     2.3 @@ -480,3 +480,4 @@ tools/misc/xen_log
     2.4  tools/misc/xen_refresh_dev
     2.5  xenolinux-2.4.22-sparse/arch/xeno/drivers/block/device
     2.6  xen/common/debug.c~
     2.7 +xen/common/debug.o
     3.1 --- a/tools/internal/Makefile	Wed Nov 05 11:50:12 2003 +0000
     3.2 +++ b/tools/internal/Makefile	Wed Nov 05 11:57:30 2003 +0000
     3.3 @@ -8,7 +8,7 @@ SRCS     = $(wildcard *.c)
     3.4  OBJS     = $(patsubst %.c,%.o,$(SRCS))
     3.5  
     3.6  TARGETS  = xi_create xi_start xi_stop xi_destroy xi_build 
     3.7 -TARGETS += xi_phys_grant xi_phys_revoke xi_phys_probe xi_list 
     3.8 +TARGETS += xi_phys_grant xi_list 
     3.9  TARGETS += xi_sched_global xi_sched_domain xi_usage xi_vif_params
    3.10  INSTALL  = $(TARGETS) xi_vifinit xi_helper
    3.11  
     4.1 --- a/tools/internal/dom0_defs.h	Wed Nov 05 11:50:12 2003 +0000
     4.2 +++ b/tools/internal/dom0_defs.h	Wed Nov 05 11:57:30 2003 +0000
     4.3 @@ -58,18 +58,6 @@ static inline int do_privcmd(unsigned in
     4.4      return ret;
     4.5  }
     4.6  
     4.7 -static inline int xldev_to_physdev(int xldev)
     4.8 -{
     4.9 -    return do_privcmd(IOCTL_PRIVCMD_LINDEV_TO_XENDEV, 
    4.10 -                      (unsigned long)xldev);
    4.11 -}
    4.12 -
    4.13 -static inline int physdev_to_xldev(int physdev)
    4.14 -{
    4.15 -    return do_privcmd(IOCTL_PRIVCMD_XENDEV_TO_LINDEV, 
    4.16 -                      (unsigned long)physdev);
    4.17 -}
    4.18 -
    4.19  static inline int do_xen_blkmsg(privcmd_blkmsg_t *blkmsg)
    4.20  {
    4.21      return do_privcmd(IOCTL_PRIVCMD_BLKMSG, (unsigned long)blkmsg);
    4.22 @@ -133,4 +121,28 @@ static inline int do_network_op(network_
    4.23   out1: return ret;
    4.24  }
    4.25  
    4.26 +
    4.27 +static inline int do_block_io_op(block_io_op_t *op)
    4.28 +{
    4.29 +    int ret = -1;
    4.30 +    privcmd_hypercall_t hypercall;
    4.31 +
    4.32 +    hypercall.op     = __HYPERVISOR_block_io_op;
    4.33 +    hypercall.arg[0] = (unsigned long)op;
    4.34 +
    4.35 +    if ( mlock(op, sizeof(*op)) != 0 )
    4.36 +    {
    4.37 +        PERROR("Could not lock memory for Xen hypercall");
    4.38 +        goto out1;
    4.39 +    }
    4.40 +
    4.41 +    if ( do_xen_hypercall(&hypercall) < 0 )
    4.42 +        goto out2;
    4.43 +
    4.44 +    ret = 0;
    4.45 +
    4.46 + out2: (void)munlock(op, sizeof(*op));
    4.47 + out1: return ret;
    4.48 +}
    4.49 +
    4.50  #endif /* __DOM0_DEFS_H__ */
     5.1 --- a/tools/internal/xi_phys_grant.c	Wed Nov 05 11:50:12 2003 +0000
     5.2 +++ b/tools/internal/xi_phys_grant.c	Wed Nov 05 11:57:30 2003 +0000
     5.3 @@ -2,42 +2,67 @@
     5.4  #define _GNU_SOURCE
     5.5  #include "dom0_defs.h"
     5.6  
     5.7 +
     5.8  int main(int argc, char *argv[])
     5.9  {
    5.10 -    privcmd_blkmsg_t blkmsg;
    5.11 -    xp_disk_t        xpd;
    5.12 +    block_io_op_t op; 
    5.13 +    unsigned int domain; 
    5.14 +    unsigned short vdevice, device; 
    5.15 +    int ret; 
    5.16  
    5.17      if ( argc != 7 )
    5.18      {
    5.19 -	fprintf(stderr, "Usage: xi_physdev_grant <r/rw> <domain> "
    5.20 +	fprintf(stderr, "Usage: xi_physdev_grant_new <r/rw> <domain> "
    5.21                  "<device> <start sector> <n_sectors> <partition>\n");
    5.22  	return 1;
    5.23      }
    5.24  
    5.25 -    xpd.mode = 0;
    5.26 -    if ( strchr(argv[1], 'r') )
    5.27 -	xpd.mode |= PHYSDISK_MODE_R;
    5.28 -    if ( strchr(argv[1], 'w') )
    5.29 -        xpd.mode |= PHYSDISK_MODE_W;
    5.30  
    5.31 -    xpd.domain     = atol(argv[2]);
    5.32 -    xpd.device     = xldev_to_physdev(atol(argv[3]));
    5.33 -    xpd.start_sect = atol(argv[4]);
    5.34 -    xpd.n_sectors  = atol(argv[5]);
    5.35 -    xpd.partition  = atol(argv[6]);
    5.36 +    /* 
    5.37 +    ** XXX SMH: guests can refer to 'real' devices as anything; however 
    5.38 +    ** for this particular use ("physdisk access") we want to use the 
    5.39 +    ** same device number in the guest as is used in xen => both 'vdevice' 
    5.40 +    ** (XL name) and "device" (Xen name) are the same. 
    5.41 +    */
    5.42 +    domain  = atoi(argv[2]); 
    5.43 +    device  = atoi(argv[3]); 
    5.44 +	/* XXX SMH: hack -- generate device name by addition ptn number */
    5.45 +    vdevice = device + atoi(argv[6]);
    5.46 +    
    5.47 +    op.cmd = BLOCK_IO_OP_VBD_CREATE; 
    5.48 +    op.u.create_info.domain  = domain; 
    5.49 +    op.u.create_info.vdevice = vdevice; 
    5.50  
    5.51 -    if ( xpd.device == 0 )
    5.52 -    {
    5.53 -        ERROR("Unrecognised device");
    5.54 -        return 1;
    5.55 +    ret = do_block_io_op(&op);
    5.56 +
    5.57 +    if(ret < 0) { 
    5.58 +	fprintf(stderr, "error %d attempting to create VBD %04x\n", ret, 
    5.59 +		atoi(argv[2])); 
    5.60 +	return ret; 
    5.61      }
    5.62  
    5.63 -    blkmsg.op       = XEN_BLOCK_PHYSDEV_GRANT;
    5.64 -    blkmsg.buf      = &xpd;
    5.65 -    blkmsg.buf_size = sizeof(xpd);
    5.66  
    5.67 -    if ( do_xen_blkmsg(&blkmsg) < 0 )
    5.68 -        return 1;
    5.69 +    op.cmd = BLOCK_IO_OP_VBD_ADD; 
    5.70 +    op.u.add_info.domain  = domain; 
    5.71 +    op.u.add_info.vdevice = vdevice;
    5.72 +
    5.73 +    op.u.add_info.extent.device       = device; 
    5.74 +    op.u.add_info.extent.start_sector = atol(argv[4]);
    5.75 +    op.u.add_info.extent.nr_sectors   = atol(argv[5]);
    5.76 +    op.u.add_info.extent.mode         = 0; 
    5.77 +    if ( strchr(argv[1], 'r') )
    5.78 +	op.u.add_info.extent.mode |= PHYSDISK_MODE_R;
    5.79 +    if ( strchr(argv[1], 'w') )
    5.80 +        op.u.add_info.extent.mode |= PHYSDISK_MODE_W;
    5.81 +
    5.82 +    
    5.83 +    ret = do_block_io_op(&op);
    5.84 +
    5.85 +    if(ret < 0) { 
    5.86 +	fprintf(stderr, "error %d attempting to add extent to VBD %04x\n", 
    5.87 +		ret, atoi(argv[2])); 
    5.88 +	return ret; 
    5.89 +    }
    5.90  
    5.91      return 0;
    5.92  }
     6.1 --- a/tools/internal/xi_phys_probe.c	Wed Nov 05 11:50:12 2003 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,46 +0,0 @@
     6.4 -
     6.5 -#define _GNU_SOURCE
     6.6 -#include "dom0_defs.h"
     6.7 -
     6.8 -int main(int argc, char *argv[])
     6.9 -{
    6.10 -    privcmd_blkmsg_t    blkmsg;
    6.11 -    physdisk_probebuf_t buf;
    6.12 -    int                 i;
    6.13 -
    6.14 -    if ( argc != 2 )
    6.15 -    {
    6.16 -	fprintf(stderr, "Usage: xi_phys_probe <domain_nr>\n");
    6.17 -	return 1;
    6.18 -    }
    6.19 -
    6.20 -    memset(&buf, 0, sizeof(buf));
    6.21 -
    6.22 -    do {
    6.23 -        buf.domain      = atol(argv[1]);
    6.24 -	buf.n_aces      = PHYSDISK_MAX_ACES_PER_REQUEST;
    6.25 -
    6.26 -        blkmsg.op       = XEN_BLOCK_PHYSDEV_PROBE;
    6.27 -        blkmsg.buf      = &buf;
    6.28 -        blkmsg.buf_size = sizeof(buf);
    6.29 -
    6.30 -        if ( do_xen_blkmsg(&blkmsg) < 0 )
    6.31 -            return 1;
    6.32 -        
    6.33 -	for ( i = 0; i < buf.n_aces; i++ )
    6.34 -        {
    6.35 -	    char read = (buf.entries[i].mode & 1 ? 'r' : ' ');
    6.36 -	    char write = (buf.entries[i].mode & 2 ? 'w' : ' ');
    6.37 -	    printf("%x %x %lx %lx %c%c\n", 
    6.38 -                   physdev_to_xldev(buf.entries[i].device),
    6.39 -		   buf.entries[i].partition,
    6.40 -		   buf.entries[i].start_sect,
    6.41 -		   buf.entries[i].n_sectors, read, write);
    6.42 -	}
    6.43 -
    6.44 -	buf.start_ind += buf.n_aces;
    6.45 -    } 
    6.46 -    while ( buf.n_aces == PHYSDISK_MAX_ACES_PER_REQUEST );
    6.47 -
    6.48 -    return 0;
    6.49 -}
     7.1 --- a/tools/internal/xi_phys_revoke.c	Wed Nov 05 11:50:12 2003 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,37 +0,0 @@
     7.4 -
     7.5 -#define _GNU_SOURCE
     7.6 -#include "dom0_defs.h"
     7.7 -
     7.8 -int main(int argc, char *argv[])
     7.9 -{
    7.10 -    privcmd_blkmsg_t blkmsg;
    7.11 -    xp_disk_t        xpd;
    7.12 -
    7.13 -    if ( argc != 5 )
    7.14 -    {
    7.15 -	fprintf(stderr, "Usage: xi_physdev_revoke <domain> "
    7.16 -                "<device> <start sector> <n_sectors>\n");
    7.17 -	return 1;
    7.18 -    }
    7.19 -
    7.20 -    xpd.mode       = 0;
    7.21 -    xpd.domain     = atol(argv[1]);
    7.22 -    xpd.device     = xldev_to_physdev(atol(argv[2]));
    7.23 -    xpd.start_sect = atol(argv[3]);
    7.24 -    xpd.n_sectors  = atol(argv[4]);
    7.25 -
    7.26 -    if ( xpd.device == 0 )
    7.27 -    {
    7.28 -        ERROR("Unrecognised device");
    7.29 -        return 1;
    7.30 -    }
    7.31 -
    7.32 -    blkmsg.op       = XEN_BLOCK_PHYSDEV_GRANT;
    7.33 -    blkmsg.buf      = &xpd;
    7.34 -    blkmsg.buf_size = sizeof(xpd);
    7.35 -
    7.36 -    if ( do_xen_blkmsg(&blkmsg) < 0 )
    7.37 -        return 1;
    7.38 -
    7.39 -    return 0;
    7.40 -}
     8.1 --- a/tools/misc/Makefile	Wed Nov 05 11:50:12 2003 +0000
     8.2 +++ b/tools/misc/Makefile	Wed Nov 05 11:57:30 2003 +0000
     8.3 @@ -9,7 +9,7 @@ OBJS     = $(patsubst %.c,%.o,$(SRCS))
     8.4  
     8.5  TARGETS  = xen_read_console xen_log xen_cpuperf xen_refresh_dev
     8.6  
     8.7 -INSTALL  = $(TARGETS) xen-mkdevnodes xen-clone xen_log
     8.8 +INSTALL  = $(TARGETS) xen-mkdevnodes xen-clone 
     8.9  
    8.10  all: $(TARGETS)
    8.11  	$(MAKE) -C miniterm	
     9.1 --- a/xen/common/domain.c	Wed Nov 05 11:50:12 2003 +0000
     9.2 +++ b/xen/common/domain.c	Wed Nov 05 11:57:30 2003 +0000
     9.3 @@ -132,8 +132,10 @@ void __kill_domain(struct task_struct *p
     9.4  
     9.5      unlink_blkdev_info(p);
     9.6  
     9.7 +#if 0
     9.8      for ( i = 0; i < XEN_MAX_VBDS; i++ )
     9.9  	xen_vbd_delete(p, i);
    9.10 +#endif
    9.11  
    9.12      for ( i = 0; i < MAX_DOMAIN_VIFS; i++ )
    9.13          unlink_net_vif(p->net_vif_list[i]);
    9.14 @@ -305,8 +307,10 @@ void release_task(struct task_struct *p)
    9.15       */
    9.16      destroy_blkdev_info(p);
    9.17  
    9.18 +#if 0
    9.19      /* Free up the physdisk access control info */
    9.20      destroy_physdisk_aces(p);
    9.21 +#endif
    9.22  
    9.23      /* Free all memory associated with this domain. */
    9.24      free_page((unsigned long)p->mm.perdomain_pt);
    10.1 --- a/xen/drivers/block/xen_block.c	Wed Nov 05 11:50:12 2003 +0000
    10.2 +++ b/xen/drivers/block/xen_block.c	Wed Nov 05 11:57:30 2003 +0000
    10.3 @@ -20,7 +20,7 @@
    10.4  #include <xeno/vbd.h>
    10.5  #include <xeno/slab.h>
    10.6  
    10.7 -#if 0
    10.8 +#if 1
    10.9  #define DPRINTK(_f, _a...) printk( _f , ## _a )
   10.10  #else
   10.11  #define DPRINTK(_f, _a...) ((void)0)
   10.12 @@ -58,33 +58,6 @@ static spinlock_t pend_prod_lock = SPIN_
   10.13  static kmem_cache_t *buffer_head_cachep;
   10.14  static atomic_t nr_pending;
   10.15  
   10.16 -#define NR_IDE_DEVS  20
   10.17 -#define NR_SCSI_DEVS 16
   10.18 -
   10.19 -static kdev_t ide_devs[NR_IDE_DEVS] = { 
   10.20 -    MKDEV(IDE0_MAJOR, 0), MKDEV(IDE0_MAJOR, 64),                /* hda, hdb */
   10.21 -    MKDEV(IDE1_MAJOR, 0), MKDEV(IDE1_MAJOR, 64),                /* hdc, hdd */
   10.22 -    MKDEV(IDE2_MAJOR, 0), MKDEV(IDE2_MAJOR, 64),                /* hde, hdf */
   10.23 -    MKDEV(IDE3_MAJOR, 0), MKDEV(IDE3_MAJOR, 64),                /* hdg, hdh */
   10.24 -    MKDEV(IDE4_MAJOR, 0), MKDEV(IDE4_MAJOR, 64),                /* hdi, hdj */
   10.25 -    MKDEV(IDE5_MAJOR, 0), MKDEV(IDE5_MAJOR, 64),                /* hdk, hdl */
   10.26 -    MKDEV(IDE6_MAJOR, 0), MKDEV(IDE6_MAJOR, 64),                /* hdm, hdn */
   10.27 -    MKDEV(IDE7_MAJOR, 0), MKDEV(IDE7_MAJOR, 64),                /* hdo, hdp */
   10.28 -    MKDEV(IDE8_MAJOR, 0), MKDEV(IDE8_MAJOR, 64),                /* hdq, hdr */
   10.29 -    MKDEV(IDE9_MAJOR, 0), MKDEV(IDE9_MAJOR, 64)                 /* hds, hdt */
   10.30 -};
   10.31 -
   10.32 -static kdev_t scsi_devs[NR_SCSI_DEVS] = { 
   10.33 -    MKDEV(SCSI_DISK0_MAJOR,   0), MKDEV(SCSI_DISK0_MAJOR,  16), /* sda, sdb */
   10.34 -    MKDEV(SCSI_DISK0_MAJOR,  32), MKDEV(SCSI_DISK0_MAJOR,  48), /* sdc, sdd */
   10.35 -    MKDEV(SCSI_DISK0_MAJOR,  64), MKDEV(SCSI_DISK0_MAJOR,  80), /* sde, sdf */
   10.36 -    MKDEV(SCSI_DISK0_MAJOR,  96), MKDEV(SCSI_DISK0_MAJOR, 112), /* sdg, sdh */
   10.37 -    MKDEV(SCSI_DISK0_MAJOR, 128), MKDEV(SCSI_DISK0_MAJOR, 144), /* sdi, sdj */
   10.38 -    MKDEV(SCSI_DISK0_MAJOR, 160), MKDEV(SCSI_DISK0_MAJOR, 176), /* sdk, sdl */
   10.39 -    MKDEV(SCSI_DISK0_MAJOR, 192), MKDEV(SCSI_DISK0_MAJOR, 208), /* sdm, sdn */
   10.40 -    MKDEV(SCSI_DISK0_MAJOR, 224), MKDEV(SCSI_DISK0_MAJOR, 240), /* sdo, sdp */
   10.41 -};
   10.42 -
   10.43  static int __buffer_is_valid(struct task_struct *p, 
   10.44                               unsigned long buffer, 
   10.45                               unsigned short size,
   10.46 @@ -102,10 +75,6 @@ static int do_block_io_op_domain(struct 
   10.47  static void dispatch_rw_block_io(struct task_struct *p, int index);
   10.48  static void dispatch_probe(struct task_struct *p, int index);
   10.49  static void dispatch_debug_block_io(struct task_struct *p, int index);
   10.50 -static void dispatch_create_vbd(struct task_struct *p, int index);
   10.51 -static void dispatch_delete_vbd(struct task_struct *p, int index);
   10.52 -static void dispatch_grant_physdev(struct task_struct *p, int index);
   10.53 -static void dispatch_probe_physdev(struct task_struct *p, int index);
   10.54  static void make_response(struct task_struct *p, unsigned long id, 
   10.55                            unsigned short op, unsigned long st);
   10.56  
   10.57 @@ -232,14 +201,6 @@ static void end_block_io_op(struct buffe
   10.58  
   10.59      kmem_cache_free(buffer_head_cachep, bh);
   10.60  }
   10.61 -
   10.62 -
   10.63 -long vbd_attach(vbd_attach_t *info) 
   10.64 -{
   10.65 -    printk("vbd_attach called!!!\n"); 
   10.66 -    return -ENOSYS; 
   10.67 -}
   10.68 -
   10.69  /* ----[ Syscall Interface ]------------------------------------------------*/
   10.70  
   10.71  long do_block_io_op(block_io_op_t *u_block_io_op)
   10.72 @@ -259,13 +220,6 @@ long do_block_io_op(block_io_op_t *u_blo
   10.73  	maybe_trigger_io_schedule();
   10.74  	break; 
   10.75  
   10.76 -    case BLOCK_IO_OP_ATTACH_VBD:  
   10.77 -	/* attach a VBD to a given domain; caller must be privileged  */
   10.78 -	if( !IS_PRIV(p) )
   10.79 -	    return -EPERM; 
   10.80 -	ret = vbd_attach(&op.u.attach_info); 
   10.81 -	break; 
   10.82 -
   10.83      case BLOCK_IO_OP_RESET:
   10.84          /* Avoid a race with the tasklet. */
   10.85          remove_from_blkdev_list(p);
   10.86 @@ -286,6 +240,34 @@ long do_block_io_op(block_io_op_t *u_blo
   10.87          ret = copy_to_user(u_block_io_op, &op, sizeof(op)) ? -EFAULT : 0;
   10.88          break;
   10.89  
   10.90 +    case BLOCK_IO_OP_VBD_CREATE:  
   10.91 +	/* create a new VBD for a given domain; caller must be privileged  */
   10.92 +	if(!IS_PRIV(p))
   10.93 +	    return -EPERM; 
   10.94 +	ret = vbd_create(&op.u.create_info); 
   10.95 +	break; 
   10.96 +
   10.97 +    case BLOCK_IO_OP_VBD_ADD:  
   10.98 +	/* add an extent to a VBD; caller must be privileged  */
   10.99 +	if(!IS_PRIV(p))
  10.100 +	    return -EPERM; 
  10.101 +	ret = vbd_add(&op.u.add_info); 
  10.102 +	break; 
  10.103 +
  10.104 +    case BLOCK_IO_OP_VBD_REMOVE:  
  10.105 +	/* remove an extnet from a VBD; caller must be privileged  */
  10.106 +	if(!IS_PRIV(p))
  10.107 +	    return -EPERM; 
  10.108 +	ret = vbd_remove(&op.u.remove_info); 
  10.109 +	break; 
  10.110 +
  10.111 +    case BLOCK_IO_OP_VBD_DELETE:  
  10.112 +	/* delete a VBD; caller must be privileged */
  10.113 +	if(!IS_PRIV(p))
  10.114 +	    return -EPERM; 
  10.115 +	ret = vbd_delete(&op.u.delete_info); 
  10.116 +	break; 
  10.117 +
  10.118      default: 
  10.119  	ret = -ENOSYS; 
  10.120      } 
  10.121 @@ -429,22 +411,6 @@ static int do_block_io_op_domain(struct 
  10.122  	    dispatch_debug_block_io(p, i);
  10.123  	    break;
  10.124  
  10.125 -	case XEN_BLOCK_VBD_CREATE:
  10.126 -	    dispatch_create_vbd(p, i);
  10.127 -	    break;
  10.128 -
  10.129 -	case XEN_BLOCK_VBD_DELETE:
  10.130 -	    dispatch_delete_vbd(p, i);
  10.131 -	    break;
  10.132 -
  10.133 -	case XEN_BLOCK_PHYSDEV_GRANT:
  10.134 -  	    dispatch_grant_physdev(p, i);
  10.135 -	    break;
  10.136 -
  10.137 -	case XEN_BLOCK_PHYSDEV_PROBE:
  10.138 - 	    dispatch_probe_physdev(p, i);
  10.139 -	    break;
  10.140 -
  10.141  	default:
  10.142              DPRINTK("error: unknown block io operation [%d]\n",
  10.143                      blk_ring->ring[i].req.operation);
  10.144 @@ -463,113 +429,6 @@ static void dispatch_debug_block_io(stru
  10.145      DPRINTK("dispatch_debug_block_io: unimplemented\n"); 
  10.146  }
  10.147  
  10.148 -static void dispatch_probe_physdev(struct task_struct *p, int index)
  10.149 -{
  10.150 -    blk_ring_t *blk_ring = p->blk_ring_base;
  10.151 -    unsigned long flags, buffer;
  10.152 -    physdisk_probebuf_t *buf;
  10.153 -    int result;
  10.154 -
  10.155 -    buffer = blk_ring->ring[index].req.buffer_and_sects[0] & ~0x1FF;
  10.156 -
  10.157 -    spin_lock_irqsave(&p->page_lock, flags);
  10.158 -    if ( !__buffer_is_valid(p, buffer, sizeof(*buf), 1) )
  10.159 -    {
  10.160 -        spin_unlock_irqrestore(&p->page_lock, flags);
  10.161 -        result = 1;
  10.162 -        goto out;
  10.163 -    }
  10.164 -    __lock_buffer(buffer, sizeof(*buf), 1);
  10.165 -    spin_unlock_irqrestore(&p->page_lock, flags);
  10.166 -
  10.167 -    buf = phys_to_virt(buffer);
  10.168 -    result = xen_physdisk_probe(p, buf);
  10.169 -
  10.170 -    unlock_buffer(p, buffer, sizeof(*buf), 1);
  10.171 -
  10.172 - out:
  10.173 -    make_response(p, blk_ring->ring[index].req.id, 
  10.174 -                  XEN_BLOCK_PHYSDEV_PROBE, result); 
  10.175 -}
  10.176 -
  10.177 -static void dispatch_grant_physdev(struct task_struct *p, int index)
  10.178 -{
  10.179 -    blk_ring_t *blk_ring = p->blk_ring_base;
  10.180 -    unsigned long flags, buffer;
  10.181 -    xp_disk_t *xpd;
  10.182 -    int result;
  10.183 -
  10.184 -    if ( p->domain != 0 )
  10.185 -    {
  10.186 -        DPRINTK("dispatch_grant_physdev called by dom%d\n", p->domain);
  10.187 -        result = 1;
  10.188 -        goto out;
  10.189 -    }
  10.190 -
  10.191 -    buffer = blk_ring->ring[index].req.buffer_and_sects[0] & ~0x1FF;
  10.192 -
  10.193 -    spin_lock_irqsave(&p->page_lock, flags);
  10.194 -    if ( !__buffer_is_valid(p, buffer, sizeof(xv_disk_t), 1) )
  10.195 -    {
  10.196 -        DPRINTK("Bad buffer in dispatch_grant_physdev\n");
  10.197 -        spin_unlock_irqrestore(&p->page_lock, flags);
  10.198 -        result = 1;
  10.199 -        goto out;
  10.200 -    }
  10.201 -    __lock_buffer(buffer, sizeof(xv_disk_t), 1);
  10.202 -    spin_unlock_irqrestore(&p->page_lock, flags);
  10.203 -
  10.204 -    xpd = phys_to_virt(buffer);
  10.205 -    result = xen_physdisk_grant(xpd);
  10.206 -
  10.207 -    unlock_buffer(p, buffer, sizeof(xp_disk_t), 1);
  10.208 -
  10.209 - out:
  10.210 -    make_response(p, blk_ring->ring[index].req.id, 
  10.211 -                  XEN_BLOCK_PHYSDEV_GRANT, result); 
  10.212 -}
  10.213 -  
  10.214 -static void dispatch_create_vbd(struct task_struct *p, int index)
  10.215 -{
  10.216 -    blk_ring_t *blk_ring = p->blk_ring_base;
  10.217 -    unsigned long flags, buffer;
  10.218 -    xv_disk_t *xvd;
  10.219 -    int result;
  10.220 -
  10.221 -    if ( p->domain != 0 )
  10.222 -    {
  10.223 -        DPRINTK("dispatch_create_vbd called by dom%d\n", p->domain);
  10.224 -        result = 1;
  10.225 -        goto out;
  10.226 -    }
  10.227 -
  10.228 -    buffer = blk_ring->ring[index].req.buffer_and_sects[0] & ~0x1FF;
  10.229 -
  10.230 -    spin_lock_irqsave(&p->page_lock, flags);
  10.231 -    if ( !__buffer_is_valid(p, buffer, sizeof(xv_disk_t), 1) )
  10.232 -    {
  10.233 -        DPRINTK("Bad buffer in dispatch_create_vbd\n");
  10.234 -        spin_unlock_irqrestore(&p->page_lock, flags);
  10.235 -        result = 1;
  10.236 -        goto out;
  10.237 -    }
  10.238 -    __lock_buffer(buffer, sizeof(xv_disk_t), 1);
  10.239 -    spin_unlock_irqrestore(&p->page_lock, flags);
  10.240 -
  10.241 -    xvd = phys_to_virt(buffer);
  10.242 -    result = xen_vbd_create(xvd);
  10.243 -
  10.244 -    unlock_buffer(p, buffer, sizeof(xv_disk_t), 1);    
  10.245 -
  10.246 - out:
  10.247 -    make_response(p, blk_ring->ring[index].req.id, 
  10.248 -                  XEN_BLOCK_VBD_CREATE, result); 
  10.249 -}
  10.250 -
  10.251 -static void dispatch_delete_vbd(struct task_struct *p, int index)
  10.252 -{
  10.253 -    DPRINTK("dispatch_delete_vbd: unimplemented\n"); 
  10.254 -}
  10.255  
  10.256  static void dispatch_probe(struct task_struct *p, int index)
  10.257  {
  10.258 @@ -604,15 +463,12 @@ static void dispatch_probe(struct task_s
  10.259      */
  10.260      xdi = map_domain_mem(buffer);
  10.261      xdi->count = 0; 
  10.262 -#if 0 // XXX SMH: fix below once done proper vbd/physd rewrit
  10.263 +
  10.264      if(IS_PRIV(p)) { 
  10.265 -#endif
  10.266 -	/* privilege domains always gets access to the 'real' devices */
  10.267 +	/* privileged domains always get access to the 'real' devices */
  10.268  	ide_probe_devices(xdi);
  10.269  	scsi_probe_devices(xdi);
  10.270 -#if 0
  10.271      } 
  10.272 -#endif
  10.273      vbd_probe_devices(xdi, p); 
  10.274      unmap_domain_mem(xdi);
  10.275  
  10.276 @@ -631,7 +487,7 @@ static void dispatch_rw_block_io(struct 
  10.277      int operation = (req->operation == XEN_BLOCK_WRITE) ? WRITE : READ;
  10.278      unsigned short nr_sects;
  10.279      unsigned long buffer, flags;
  10.280 -    int i, tot_sects;
  10.281 +    int i, rc, tot_sects;
  10.282      pending_req_t *pending_req;
  10.283  
  10.284      /* We map virtual scatter/gather segments to physical segments. */
  10.285 @@ -670,41 +526,25 @@ static void dispatch_rw_block_io(struct 
  10.286              goto bad_descriptor;
  10.287  	}
  10.288  
  10.289 -        /* Get the physical device and block index. */
  10.290 -        if ( (req->device & XENDEV_TYPE_MASK) == XENDEV_VIRTUAL )
  10.291 -        {
  10.292 -            new_segs = xen_vbd_map_request(
  10.293 -                &phys_seg[nr_psegs], p, operation,
  10.294 -                req->device, 
  10.295 -                req->sector_number + tot_sects,
  10.296 -                buffer, nr_sects);
  10.297 -            if ( new_segs <= 0 ) 
  10.298 -	    {
  10.299 -	        DPRINTK("bogus xen_vbd_map_request\n");
  10.300 -		goto bad_descriptor;
  10.301 -	    }
  10.302 -        }
  10.303 -        else
  10.304 -        {
  10.305 -	    phys_seg[nr_psegs].dev           = req->device;
  10.306 -            phys_seg[nr_psegs].sector_number = req->sector_number + tot_sects;
  10.307 -            phys_seg[nr_psegs].buffer        = buffer;
  10.308 -            phys_seg[nr_psegs].nr_sects      = nr_sects;
  10.309 -	    if (p->domain != 0 &&
  10.310 -		!xen_physdisk_access_okay(&phys_seg[nr_psegs], p, operation)) {
  10.311 -                DPRINTK("access denied: dev=%04x off=%ld nr=%ld\n",
  10.312 -                        req->device, req->sector_number + tot_sects, nr_sects);
  10.313 -                goto bad_descriptor;
  10.314 -	    }
  10.315 -	    phys_seg[nr_psegs].dev           = xendev_to_physdev(req->device);
  10.316 -            if ( phys_seg[nr_psegs].dev == 0 ) 
  10.317 -	    {
  10.318 -	        DPRINTK("bad device: %04x\n", req->device);
  10.319 -	        goto bad_descriptor;
  10.320 -	    }
  10.321 -            new_segs = 1;
  10.322 -        }
  10.323 -        
  10.324 +	phys_seg[nr_psegs].dev           = req->device;
  10.325 +	phys_seg[nr_psegs].sector_number = req->sector_number + tot_sects;
  10.326 +	phys_seg[nr_psegs].buffer        = buffer;
  10.327 +	phys_seg[nr_psegs].nr_sects      = nr_sects;
  10.328 +
  10.329 +        /* Translate the request into the relevant 'physical device' */
  10.330 +	new_segs = 1; 
  10.331 +	rc = vbd_translate(&phys_seg[nr_psegs], &new_segs, p, operation); 
  10.332 +
  10.333 +	/* If it fails we bail (unless the caller is priv => has raw access) */
  10.334 +	if(rc && !IS_PRIV(p)) { 
  10.335 +	    printk("access denied: attempted %s of [%ld,%ld] on dev=%04x\n", 
  10.336 +		   operation == READ ? "read" : "write", 
  10.337 +		   req->sector_number + tot_sects, 
  10.338 +		   req->sector_number + tot_sects + nr_sects, 
  10.339 +		   req->device); 
  10.340 +	    goto bad_descriptor;
  10.341 +	}
  10.342 +	    
  10.343          nr_psegs += new_segs;
  10.344          if ( nr_psegs >= (MAX_BLK_SEGS*2) ) BUG();
  10.345      }
  10.346 @@ -767,36 +607,6 @@ static void dispatch_rw_block_io(struct 
  10.347   * MISCELLANEOUS SETUP / TEARDOWN / DEBUGGING
  10.348   */
  10.349  
  10.350 -kdev_t xendev_to_physdev(unsigned short xendev)
  10.351 -{
  10.352 -    switch ( (xendev & XENDEV_TYPE_MASK) )
  10.353 -    {
  10.354 -    case XENDEV_IDE:
  10.355 -        xendev &= XENDEV_IDX_MASK;
  10.356 -        if ( xendev >= NR_IDE_DEVS )
  10.357 -        {
  10.358 -            DPRINTK("IDE device number out of range %d\n", xendev);
  10.359 -            goto fail;
  10.360 -        }
  10.361 -        return ide_devs[xendev];
  10.362 -        
  10.363 -    case XENDEV_SCSI:
  10.364 -        xendev &= XENDEV_IDX_MASK;
  10.365 -        if ( xendev >= NR_SCSI_DEVS )
  10.366 -        {
  10.367 -            DPRINTK("SCSI device number out of range %d\n", xendev);
  10.368 -            goto fail;
  10.369 -        }
  10.370 -        return scsi_devs[xendev];
  10.371 -        
  10.372 -    case XENDEV_VIRTUAL:
  10.373 -    default:
  10.374 -        DPRINTK("xendev_to_physdev: unknown device %d\n", xendev);
  10.375 -    }
  10.376 -
  10.377 - fail:
  10.378 -    return (kdev_t)0;
  10.379 -}
  10.380  
  10.381  static void make_response(struct task_struct *p, unsigned long id, 
  10.382  			  unsigned short op, unsigned long st)
  10.383 @@ -853,11 +663,6 @@ void init_blkdev_info(struct task_struct
  10.384      clear_page(p->blk_ring_base);
  10.385      SHARE_PFN_WITH_DOMAIN(virt_to_page(p->blk_ring_base), p->domain);
  10.386      p->blkdev_list.next = NULL;
  10.387 -
  10.388 -    memset(p->vbd_list, 0, sizeof(p->vbd_list));
  10.389 -
  10.390 -    /* Get any previously created segments. */
  10.391 -    xen_refresh_vbd_list(p);
  10.392  }
  10.393  
  10.394  /* End-of-day teardown for a domain. */
  10.395 @@ -898,7 +703,5 @@ void initialize_block_io ()
  10.396          "buffer_head_cache", sizeof(struct buffer_head),
  10.397          0, SLAB_HWCACHE_ALIGN, NULL, NULL);
  10.398  
  10.399 -    xen_vbd_initialize();
  10.400 -    
  10.401      add_key_handler('b', dump_blockq, "dump xen ide blkdev statistics");
  10.402  }
    11.1 --- a/xen/drivers/block/xen_vbd.c	Wed Nov 05 11:50:12 2003 +0000
    11.2 +++ b/xen/drivers/block/xen_vbd.c	Wed Nov 05 11:57:30 2003 +0000
    11.3 @@ -14,21 +14,6 @@
    11.4  #include <asm/current.h>
    11.5  #include <asm/domain_page.h>
    11.6  
    11.7 -/* Global list of all possible vbds.  This can be changed in
    11.8 -   the following way:
    11.9 -
   11.10 -   1) UNUSED vbd -> RO or RW vbd.  This requires the spinlock.
   11.11 -
   11.12 -   2) RO or RW -> UNUSED.  This requires the lock and can only happen
   11.13 -   during process teardown.
   11.14 -
   11.15 -   This means that processes can access entries in the list safely
   11.16 -   without having to hold any lock at all: they already have an entry
   11.17 -   allocated, and we know that entry can't become unused, as vbds
   11.18 -   are only torn down when the domain is dieing, by which point it
   11.19 -   can't be accessing them anymore. */
   11.20 -static vbd_t xvbds[XEN_MAX_VBDS];
   11.21 -static spinlock_t xvbd_lock = SPIN_LOCK_UNLOCKED;
   11.22  
   11.23  #if 0
   11.24  #define DPRINTK(_f, _a...) printk( _f , ## _a )
   11.25 @@ -36,136 +21,156 @@ static spinlock_t xvbd_lock = SPIN_LOCK_
   11.26  #define DPRINTK(_f, _a...) ((void)0)
   11.27  #endif
   11.28  
   11.29 -/*
   11.30 - * xen_vbd_map_request
   11.31 - *
   11.32 - * xen_device must be a valid device.
   11.33 - * 
   11.34 - * NB. All offsets and sizes here are in sector units.
   11.35 - * eg. 'size == 1' means an actual size of 512 bytes.
   11.36 - *
   11.37 - * Note that no locking is performed here whatsoever --
   11.38 - * we rely on the fact that once vbd information is
   11.39 - * established, it is only modified by domain shutdown,
   11.40 - * and so if this is being called, noone is trying
   11.41 - * to modify the vbd list.
   11.42 - */
   11.43 -int xen_vbd_map_request(
   11.44 -    phys_seg_t *pseg, struct task_struct *p, int operation,
   11.45 -    unsigned short vbd_number,
   11.46 -    unsigned long sect_nr, unsigned long buffer, unsigned short nr_sects)
   11.47 -{
   11.48 -    vbd_t *seg;
   11.49 -    extent_t  *ext;
   11.50 -    int sum, i;
   11.51  
   11.52 -    vbd_number &= XENDEV_IDX_MASK;
   11.53 -    if ( vbd_number >= XEN_MAX_VBDS )
   11.54 -    {
   11.55 -        DPRINTK("invalid vbd number. %d %d\n",
   11.56 -                vbd_number, XEN_MAX_VBDS);
   11.57 -        goto fail;
   11.58 -    }
   11.59 -
   11.60 -    seg = p->vbd_list[vbd_number];
   11.61 -    if ( seg == NULL ) 
   11.62 -    {
   11.63 -        DPRINTK("vbd is null. %d\n", vbd_number);
   11.64 -        goto fail;
   11.65 -    }
   11.66 +/* XXX SMH: crappy 'hash function' .. fix when care. */
   11.67 +#define HSH(_x) (((_x) >> 6) & (VBD_HTAB_SZ - 1))
   11.68  
   11.69 -    /* check domain permissions */
   11.70 -    if ( seg->domain != p->domain )
   11.71 -    {
   11.72 -        DPRINTK("seg is for another domain. %d %d\n", seg->domain, p->domain);
   11.73 -        goto fail;
   11.74 -    }
   11.75 +/* 
   11.76 +** Create a new VBD; all this involves is adding an entry to the domain's
   11.77 +** vbd hash table. 
   11.78 +*/
   11.79 +long vbd_create(vbd_create_t *create_info) 
   11.80 +{
   11.81 +    struct task_struct *p; 
   11.82 +    vbd_t *new_vbd, *v; 
   11.83 +    int h; 
   11.84  
   11.85 -    /* check rw access */
   11.86 -    if ( ((operation == WRITE) && (seg->mode != XEN_VBD_RW)) ||
   11.87 -         ((operation == READ)  && (seg->mode == XEN_VBD_UNUSED)) )
   11.88 -    {
   11.89 -        DPRINTK("illegal operation: %d %d\n", operation, seg->mode);
   11.90 -        goto fail;
   11.91 -    }
   11.92 +    p = find_domain_by_id(create_info->domain);
   11.93  
   11.94 -    if ( (nr_sects + sect_nr) <= sect_nr )
   11.95 -    {
   11.96 -        DPRINTK("sector + size wrap! %08lx %04x\n", sect_nr, nr_sects);
   11.97 -        goto fail;
   11.98 +    if (!p) { 
   11.99 +	printk("vbd_create attempted for non-existent domain %d\n", 
  11.100 +	       create_info->domain); 
  11.101 +	return -EINVAL; 
  11.102      }
  11.103  
  11.104 -    /* find extent, check size */
  11.105 -    sum = 0; 
  11.106 -    i = 0;
  11.107 -    ext = seg->extents;
  11.108 -    while ( (i < seg->num_extents) && ((sum + ext->nr_sectors) <= sect_nr) )
  11.109 -    {
  11.110 -        sum += ext->nr_sectors;
  11.111 -        ext++; i++;
  11.112 -    }
  11.113 +    new_vbd = kmalloc(sizeof(vbd_t), GFP_KERNEL); 
  11.114 +    new_vbd->vdevice = create_info->vdevice; 
  11.115 +    new_vbd->extents = (xen_extent_le_t *)NULL; 
  11.116 +    new_vbd->next    = (vbd_t *)NULL; 
  11.117  
  11.118 -    if ( (sum + ext->nr_sectors) <= sect_nr ) 
  11.119 -    {
  11.120 -        DPRINTK("extent size mismatch: %d %d : %d %ld %ld\n",
  11.121 -                i, seg->num_extents, sum, ext->nr_sectors, sect_nr);
  11.122 -        goto fail;
  11.123 -    }
  11.124 +    h = HSH(create_info->vdevice); 
  11.125 +    if(p->vbdtab[h]) { 
  11.126 +	for(v = p->vbdtab[h]; v->next; v = v->next) 
  11.127 +	    ; 
  11.128 +	v->next = new_vbd; 
  11.129 +    } else p->vbdtab[h] = new_vbd; 
  11.130  
  11.131 -    pseg->sector_number = (sect_nr - sum) + ext->start_sector;
  11.132 -    pseg->buffer        = buffer;
  11.133 -    pseg->nr_sects      = nr_sects;
  11.134 -    pseg->dev           = xendev_to_physdev(ext->raw_device);
  11.135 -    if ( pseg->dev == 0 ) 
  11.136 -    {
  11.137 -        DPRINTK ("invalid device 0x%x 0x%lx 0x%lx\n", 
  11.138 -                 ext->raw_device, ext->start_sector, ext->nr_sectors);
  11.139 -        goto fail;
  11.140 +    put_task_struct(p);
  11.141 +    
  11.142 +    return 0; 
  11.143 +}
  11.144 +
  11.145 +/*
  11.146 +** Add an extent to an existing VBD; fails if the VBD doesn't exist. 
  11.147 +** Doesn't worry about overlapping extents (e.g. merging etc) for now. 
  11.148 +*/
  11.149 +long vbd_add(vbd_add_t *add_info) 
  11.150 +{
  11.151 +    struct task_struct *p; 
  11.152 +    xen_extent_le_t *x, *xele; 
  11.153 +    vbd_t *v; 
  11.154 +    int h; 
  11.155 +
  11.156 +    p = find_domain_by_id(add_info->domain);
  11.157 +
  11.158 +    if (!p) { 
  11.159 +	printk("vbd_add attempted for non-existent domain %d\n", 
  11.160 +	       add_info->domain); 
  11.161 +	return -EINVAL; 
  11.162      }
  11.163  
  11.164 -    /* We're finished if the virtual extent didn't overrun the phys extent. */
  11.165 -    if ( (sum + ext->nr_sectors) >= (sect_nr + nr_sects) )
  11.166 -        return 1;                         /* entire read fits in this extent */
  11.167 +    h = HSH(add_info->vdevice); 
  11.168  
  11.169 -    /* Hmmm... make sure there's another extent to overrun onto! */
  11.170 -    if ( (i+1) == seg->num_extents ) 
  11.171 -    {
  11.172 -        DPRINTK ("not enough extents %d %d\n",
  11.173 -                 i, seg->num_extents);
  11.174 -        goto fail;
  11.175 +    for(v = p->vbdtab[h]; v; v = v->next) 
  11.176 +	if(v->vdevice == add_info->vdevice)
  11.177 +	    break; 
  11.178 +
  11.179 +    if(!v) {
  11.180 +	printk("vbd_add; attempted to add extent to non-existent VBD.\n"); 
  11.181 +	return -EINVAL; 
  11.182      }
  11.183  
  11.184 -    pseg[1].nr_sects = (sect_nr + nr_sects) - (sum + ext->nr_sectors);
  11.185 -    pseg[0].nr_sects = sum + ext->nr_sectors - sect_nr;
  11.186 -    pseg[1].buffer = buffer + (pseg->nr_sects << 9);
  11.187 -    pseg[1].sector_number = ext[1].start_sector;
  11.188 -    pseg[1].dev = xendev_to_physdev(ext[1].raw_device);
  11.189 -    if ( pseg[1].dev == 0 ) 
  11.190 -    {
  11.191 -        DPRINTK ("bogus device for pseg[1] \n");
  11.192 -        goto fail;
  11.193 +    xele = kmalloc(sizeof(xen_extent_le_t), GFP_KERNEL); 
  11.194 +    xele->extent.device       = add_info->extent.device; 
  11.195 +    xele->extent.start_sector = add_info->extent.start_sector; 
  11.196 +    xele->extent.nr_sectors   = add_info->extent.nr_sectors; 
  11.197 +    xele->extent.mode         = add_info->extent.mode; 
  11.198 +    xele->next                = (xen_extent_le_t *)NULL; 
  11.199 +
  11.200 +    if(!v->extents) {
  11.201 +	v->extents = xele; 
  11.202 +    } else { 
  11.203 +	for(x = v->extents; x->next; x = x->next) 
  11.204 +	    ; 
  11.205 +	x->next = xele; 
  11.206 +    } 
  11.207 +
  11.208 +    put_task_struct(p);
  11.209 +    return 0; 
  11.210 +}
  11.211 +
  11.212 +long vbd_remove(vbd_remove_t *remove_info) 
  11.213 +{
  11.214 +    return -ENOSYS; 
  11.215 +}
  11.216 +
  11.217 +long vbd_delete(vbd_delete_t *delete_info) 
  11.218 +{
  11.219 +    return -ENOSYS; 
  11.220 +}
  11.221 +
  11.222 +
  11.223 +int vbd_translate(phys_seg_t * pseg, int *nr_segs, 
  11.224 +		  struct task_struct *p, int operation)
  11.225 +{
  11.226 +    xen_extent_le_t *x; 
  11.227 +    vbd_t *v; 
  11.228 +    int h; 
  11.229 +    long sec; 
  11.230 +
  11.231 +    h = HSH(pseg->dev); 
  11.232 +
  11.233 +    for(v = p->vbdtab[h]; v; v = v->next) 
  11.234 +	if(v->vdevice == pseg->dev)
  11.235 +	    break; 
  11.236 +
  11.237 +    if(!v) {
  11.238 +	if(!IS_PRIV(p)) 
  11.239 +	    printk("vbd_translate; domain %d attempted to access "
  11.240 +		   "non-existent VBD.\n", p->domain); 
  11.241 +	return -ENODEV; 
  11.242      }
  11.243  
  11.244 -    /* We don't allow overrun onto a third physical extent. */
  11.245 -    if ( pseg[1].nr_sects > ext[1].nr_sectors )
  11.246 -    {
  11.247 -        DPRINTK ("third extent\n");
  11.248 -        DPRINTK (" sum:%d, e0:%ld, e1:%ld   p1.sect:%ld p1.nr:%d\n",
  11.249 -                 sum, ext[0].nr_sectors, ext[1].nr_sectors, 
  11.250 -                 pseg[1].sector_number, pseg[1].nr_sects);
  11.251 -        goto fail;    
  11.252 +    /* Now iterate through the list of xen_extents, working out which 
  11.253 +       should be used to perform the translation. */
  11.254 +    sec = pseg->sector_number; 
  11.255 +    for(x = v->extents; x; x = x->next) { 
  11.256 +
  11.257 +	if(sec < x->extent.nr_sectors) {
  11.258 +
  11.259 +	    /* we've got a match! XXX SMH: should deal with 
  11.260 +	       situation where we span multiple xe's */
  11.261 +
  11.262 +	    if(operation == READ && !(x->extent.mode & PHYSDISK_MODE_R))
  11.263 +		return -EACCES; 
  11.264 +
  11.265 +	    if(operation == WRITE && !(x->extent.mode & PHYSDISK_MODE_W))
  11.266 +		return -EACCES; 
  11.267 +
  11.268 +	    pseg->dev = x->extent.device; 
  11.269 +	    pseg->sector_number += x->extent.start_sector; 
  11.270 +
  11.271 +	    return 0; 
  11.272 +
  11.273 +	} 
  11.274 +
  11.275 +	sec -= x->extent.nr_sectors; 
  11.276      }
  11.277  
  11.278 -    return 2;                   /* We overran onto a second physical extent. */
  11.279 +    /* No luck -- return no access */
  11.280 +    return -EACCES; 
  11.281 +}
  11.282  
  11.283 - fail:
  11.284 -    DPRINTK ("xen_vbd_map_request failure\n");
  11.285 -    DPRINTK ("operation: %d\n", operation);
  11.286 -    DPRINTK ("vbd number: %d\n", vbd_number);
  11.287 -    DPRINTK ("sect_nr: %ld 0x%lx\n", sect_nr, sect_nr);
  11.288 -    DPRINTK ("nr_sects: %d 0x%x\n", nr_sects, nr_sects);
  11.289 -    return -1;
  11.290 -}
  11.291  
  11.292  /*
  11.293   * vbd_probe_devices: 
  11.294 @@ -175,492 +180,27 @@ int xen_vbd_map_request(
  11.295   */
  11.296  void vbd_probe_devices(xen_disk_info_t *xdi, struct task_struct *p)
  11.297  {
  11.298 -    int loop, i;
  11.299 -    unsigned long capacity = 0, device;
  11.300 -
  11.301 -    spin_lock(&xvbd_lock);
  11.302 -    for (loop = 0; loop < XEN_MAX_VBDS; loop++ )
  11.303 -    {
  11.304 -        if ( (xvbds[loop].mode == XEN_VBD_UNUSED) ||
  11.305 -             (xvbds[loop].domain != p->domain) )
  11.306 -            continue;
  11.307 -
  11.308 -        device = MK_VIRTUAL_XENDEV(xvbds[loop].vbd_number);
  11.309 -        for ( i = 0; i < xvbds[loop].num_extents; i++ )
  11.310 -            capacity += xvbds[loop].extents[i].nr_sectors;
  11.311 -
  11.312 -        xdi->disks[xdi->count].device   = device;
  11.313 -        xdi->disks[xdi->count].capacity = capacity;
  11.314 -        xdi->count++;
  11.315 -    }
  11.316 -    spin_unlock(&xvbd_lock);
  11.317 -    return;
  11.318 -}
  11.319 -
  11.320 -/*
  11.321 - * xen_refresh_vbd_list
  11.322 - *
  11.323 - * find all vbds associated with a domain and assign
  11.324 - * them to the domain
  11.325 - *
  11.326 - */
  11.327 -void xen_refresh_vbd_list (struct task_struct *p)
  11.328 -{
  11.329 -    int loop;
  11.330 -
  11.331 -    spin_lock(&xvbd_lock);
  11.332 -    for (loop = 0; loop < XEN_MAX_VBDS; loop++)
  11.333 -    {
  11.334 -        if ( (xvbds[loop].mode == XEN_VBD_UNUSED) ||
  11.335 -             (xvbds[loop].domain != p->domain) )
  11.336 -            continue;
  11.337 -
  11.338 -        p->vbd_list[xvbds[loop].vbd_number] = &xvbds[loop];
  11.339 -    }
  11.340 -    spin_unlock(&xvbd_lock);
  11.341 -}
  11.342 -
  11.343 -/*
  11.344 - * create a new vbd for a domain
  11.345 - *
  11.346 - * return 0 on success, 1 on failure
  11.347 - *
  11.348 - * if we see the same DOM#/SEG# combination, we reuse the slot in
  11.349 - * the vbd table (overwriting what was there before).
  11.350 - * an alternative would be to raise an error if the slot is reused.
  11.351 - */
  11.352 -int xen_vbd_create(xv_disk_t *xvd_in)
  11.353 -{
  11.354 -    int idx;
  11.355 -    int loop;
  11.356 -    xv_disk_t *xvd = map_domain_mem(virt_to_phys(xvd_in));
  11.357 -    struct task_struct *p;
  11.358 -
  11.359 -    spin_lock(&xvbd_lock);
  11.360 -    for (idx = 0; idx < XEN_MAX_VBDS; idx++)
  11.361 -    {
  11.362 -        if (xvbds[idx].mode == XEN_VBD_UNUSED ||
  11.363 -            (xvbds[idx].domain == xvd->domain &&
  11.364 -             xvbds[idx].vbd_number == xvd->vbd)) break;
  11.365 -    }
  11.366 -    if (idx == XEN_MAX_VBDS)
  11.367 -    {
  11.368 -        printk (KERN_ALERT "xen_vbd_create: unable to find free slot\n");
  11.369 -        unmap_domain_mem(xvd);
  11.370 -        return 1;
  11.371 -    }
  11.372 -
  11.373 -    xvbds[idx].mode = xvd->mode;
  11.374 -    xvbds[idx].domain = xvd->domain;
  11.375 -    xvbds[idx].vbd_number = xvd->vbd;
  11.376 -    memcpy(xvbds[idx].key, xvd->key, XEN_VBD_KEYSIZE);
  11.377 -    xvbds[idx].num_extents = xvd->ext_count;
  11.378 -
  11.379 -
  11.380 -    if (xvbds[idx].extents)
  11.381 -	kfree(xvbds[idx].extents);    
  11.382 -    xvbds[idx].extents = (extent_t *)kmalloc(
  11.383 -        sizeof(extent_t)*xvd->ext_count,
  11.384 -        GFP_KERNEL);
  11.385 - 
  11.386 -    /* could memcpy, but this is safer */
  11.387 -    for (loop = 0; loop < xvd->ext_count; loop++)
  11.388 -    {
  11.389 -        xvbds[idx].extents[loop].raw_device = xvd->extents[loop].disk; 
  11.390 -        xvbds[idx].extents[loop].start_sector = 
  11.391 -	    xvd->extents[loop].offset;
  11.392 -        xvbds[idx].extents[loop].nr_sectors = xvd->extents[loop].size;
  11.393 -        if (xvbds[idx].extents[loop].nr_sectors == 0) 
  11.394 -        {
  11.395 -            printk("xen_vbd_create: extent %d is zero length\n", loop);
  11.396 -            unmap_domain_mem(xvd);
  11.397 -            return 1;
  11.398 -        }
  11.399 -    }
  11.400 -
  11.401 -    /* if the domain exists, assign the vbd to the domain */
  11.402 -    p = find_domain_by_id(xvd->domain);
  11.403 -    if (p != NULL)
  11.404 -    {
  11.405 -        p->vbd_list[xvd->vbd] = &xvbds[idx];
  11.406 -        put_task_struct(p);
  11.407 -    }
  11.408 +    xen_extent_le_t *x; 
  11.409 +    vbd_t *v; 
  11.410 +    int i; 
  11.411  
  11.412 -    spin_unlock(&xvbd_lock);
  11.413 -
  11.414 -    unmap_domain_mem(xvd);
  11.415 -    return 0;
  11.416 -}
  11.417 -
  11.418 -/*
  11.419 - * delete a vbd from a domain
  11.420 - *
  11.421 - * return 0 on success, 1 on failure
  11.422 - *
  11.423 - * This should *only* be called from domain shutdown, or else we
  11.424 - * race with access checking.
  11.425 - */
  11.426 -int xen_vbd_delete(struct task_struct *p, int segnr)
  11.427 -{
  11.428 -    vbd_t *seg;
  11.429 -
  11.430 -    if (!p) {
  11.431 -	printk("xen_vbd delete called with NULL domain?\n");
  11.432 -	BUG();
  11.433 -	return 1;
  11.434 -    }
  11.435 -
  11.436 -    if (segnr < 0 || segnr > XEN_MAX_VBDS) {
  11.437 -	printk("xen_vbd_delete called with bad segnr?\n");
  11.438 -	BUG();
  11.439 -	return 1;
  11.440 -    }
  11.441 -
  11.442 -    if (!p->vbd_list[segnr])
  11.443 -	return 1;
  11.444 -
  11.445 -    seg = p->vbd_list[segnr];
  11.446 -
  11.447 -    /* sanity checking */
  11.448 -    if (seg->domain != p->domain || seg->vbd_number != segnr ||
  11.449 -	(seg->mode != XEN_VBD_RO && seg->mode != XEN_VBD_RW) ||
  11.450 -	seg->num_extents <= 0 || seg->extents == NULL) {
  11.451 -	printk("vbd is insane!\n");
  11.452 -	BUG();
  11.453 -	return 1;
  11.454 -    }
  11.455 -
  11.456 -    spin_lock(&xvbd_lock);
  11.457 -
  11.458 -    p->vbd_list[segnr] = NULL;
  11.459 -    seg->domain = -1;
  11.460 -    seg->vbd_number = -1;
  11.461 -    kfree(seg->extents);
  11.462 -    seg->mode = XEN_VBD_UNUSED;
  11.463 -
  11.464 -    spin_unlock(&xvbd_lock);
  11.465 +    /* XXX SMH: should allow priv domains to probe vbds for other doms XXX */
  11.466  
  11.467 -    return 0;
  11.468 -}
  11.469 -
  11.470 -static void dump_vbds(u_char key, void *dev_id, struct pt_regs *regs) 
  11.471 -{
  11.472 -    int loop, i;
  11.473 -    struct task_struct *p;
  11.474 -
  11.475 -    printk("vbd list\n");
  11.476 -    for (loop = 0; loop < XEN_MAX_VBDS; loop++)
  11.477 -    {
  11.478 -        if (xvbds[loop].mode != XEN_VBD_UNUSED)
  11.479 -        {
  11.480 -            printk(" %2d: %s dom%d, seg# %d, num_exts: %d\n",
  11.481 -                   loop, 
  11.482 -                   xvbds[loop].mode == XEN_VBD_RO ? "RO" : "RW",
  11.483 -                   xvbds[loop].domain, xvbds[loop].vbd_number,
  11.484 -                   xvbds[loop].num_extents);
  11.485 -            for (i = 0; i < xvbds[loop].num_extents; i++)
  11.486 -            {
  11.487 -                printk("     extent %d: raw device 0x%x, start_sector 0x%lx"
  11.488 -		       " nr_sectors 0x%lx\n",
  11.489 -                       i, xvbds[loop].extents[i].raw_device,
  11.490 -                       xvbds[loop].extents[i].start_sector,
  11.491 -                       xvbds[loop].extents[i].nr_sectors);
  11.492 -            } 
  11.493 -        }
  11.494 -    }
  11.495 +    for(i = 0; i < VBD_HTAB_SZ; i++) { 
  11.496 +	for(v = p->vbdtab[i]; v; v = v->next) { 
  11.497 +	    xdi->disks[xdi->count].device   = v->vdevice; 
  11.498 +	    xdi->disks[xdi->count].type     = XD_TYPE_DISK; // always :-) 
  11.499 +	    xdi->disks[xdi->count].capacity = 0; 
  11.500 +	    for(x = v->extents; x; x = x->next) 
  11.501 +		xdi->disks[xdi->count].capacity += x->extent.nr_sectors; 
  11.502 +	    xdi->count++; 
  11.503 +	}
  11.504 +    } 
  11.505  
  11.506 -    printk("vbds by domain (index into vbds list)\n");
  11.507 -    p = current;
  11.508 -    do
  11.509 -    {
  11.510 -	if(is_idle_task(p))
  11.511 -	    continue; 
  11.512 -
  11.513 -        printk("  domain %d: ", p->domain);
  11.514 -        for (loop = 0; loop < XEN_MAX_VBDS; loop++)
  11.515 -        {
  11.516 -            if (p->vbd_list[loop])
  11.517 -            {
  11.518 -                printk (" %d", p->vbd_list[loop] - xvbds);
  11.519 -            }
  11.520 -        }
  11.521 -        printk("\n");
  11.522 -        p = p->next_task;
  11.523 -    } while (p != current);
  11.524 -}
  11.525 -
  11.526 -/*
  11.527 - * initialize vbds
  11.528 - */
  11.529 -
  11.530 -void xen_vbd_initialize(void)
  11.531 -{
  11.532 -    memset (xvbds, 0, sizeof(xvbds));
  11.533 -
  11.534 -    add_key_handler('S', dump_vbds, "dump vbds");
  11.535 +    return; 
  11.536  }
  11.537  
  11.538  
  11.539 -/* The idea is that, for each sector of each disk, each domain has two
  11.540 -   bits, saying whether they can read the sector or write it.  That
  11.541 -   would take too much memory, so instead each process has a list of
  11.542 -   (device, start, end, mode) quads which say what it has access to,
  11.543 -   and we fake the logical view on top of that. */
  11.544 -struct physdisk_ace {
  11.545 -    struct list_head list;
  11.546 -    unsigned short device;
  11.547 -    unsigned short partition;
  11.548 -    unsigned long start_sect;
  11.549 -    unsigned long n_sectors;
  11.550 -    int mode;
  11.551 -};
  11.552  
  11.553  
  11.554 -/* Operation is a blkdev constant i.e. READ, WRITE, ... */
  11.555 -/* Must be called with p->physdev_lock held. */
  11.556 -static struct physdisk_ace *find_ace(const struct task_struct *p,
  11.557 -                     unsigned short dev,
  11.558 -                     unsigned long sect, int operation)
  11.559 -{
  11.560 -    struct list_head *cur_ace_head;
  11.561 -    struct physdisk_ace *cur_ace;
  11.562 -
  11.563 -    list_for_each(cur_ace_head, &p->physdisk_aces)
  11.564 -    {
  11.565 -    cur_ace = list_entry(cur_ace_head, struct physdisk_ace, list);
  11.566 -    DPRINTK("Is [%lx, %lx) good for %lx?\n",
  11.567 -        cur_ace->start_sect,
  11.568 -        cur_ace->start_sect + cur_ace->n_sectors, sect);
  11.569 -    if ( (sect >= cur_ace->start_sect) &&
  11.570 -         (sect < (cur_ace->start_sect + cur_ace->n_sectors)) &&
  11.571 -             (dev == cur_ace->device) &&
  11.572 -             (((operation == READ) && (cur_ace->mode & PHYSDISK_MODE_R)) ||
  11.573 -              ((operation == WRITE) && (cur_ace->mode & PHYSDISK_MODE_W))) )
  11.574 -        return cur_ace;
  11.575 -    }
  11.576 -    return NULL;
  11.577 -}
  11.578 -
  11.579 -/* Hold the lock on entry, it remains held on exit. */
  11.580 -static void xen_physdisk_revoke_access(unsigned short dev,
  11.581 -                       unsigned long start_sect,
  11.582 -                       unsigned long n_sectors,
  11.583 -                       struct task_struct *p)
  11.584 -{
  11.585 -    /* Find every ace which intersects [start_sect, start_sect +
  11.586 -       n_sectors] and either remove it completely or truncate it
  11.587 -       down. */
  11.588 -    struct list_head *cur_ace_head;
  11.589 -    struct physdisk_ace *cur_ace, *new_ace;
  11.590 -    unsigned long kill_zone_end, ace_end;
  11.591 -
  11.592 -    kill_zone_end = start_sect + n_sectors;
  11.593 -    list_for_each(cur_ace_head, &p->physdisk_aces) 
  11.594 -    {
  11.595 -	cur_ace = list_entry(cur_ace_head, struct physdisk_ace, list);
  11.596 -	ace_end = cur_ace->start_sect + cur_ace->n_sectors;
  11.597 -	if ( (cur_ace->start_sect >= kill_zone_end) ||
  11.598 -             (ace_end <= start_sect) || 
  11.599 -             (cur_ace->device != dev) )
  11.600 -	    continue;
  11.601 -
  11.602 -	DPRINTK("Killing ace [%lx, %lx) against kill zone [%lx, %lx)\n",
  11.603 -		cur_ace->start_sect, ace_end, start_sect, kill_zone_end);
  11.604 -
  11.605 -	if ( (cur_ace->start_sect >= start_sect) && 
  11.606 -             (ace_end <= kill_zone_end) )
  11.607 -        {
  11.608 -	    /* ace entirely within kill zone -> kill it */
  11.609 -	    list_del(cur_ace_head);
  11.610 -	    cur_ace_head = cur_ace_head->prev;
  11.611 -	    kfree(cur_ace);
  11.612 -	} 
  11.613 -        else if ( ace_end <= kill_zone_end )
  11.614 -        {
  11.615 -	    /* ace start before kill start, ace end in kill zone, 
  11.616 -	       move ace end. */
  11.617 -	    cur_ace->n_sectors = start_sect - cur_ace->start_sect;
  11.618 -	} 
  11.619 -        else if ( cur_ace->start_sect >= start_sect )
  11.620 -        {
  11.621 -	    /* ace start after kill start, ace end outside kill zone,
  11.622 -	       move ace start. */
  11.623 -	    cur_ace->start_sect = kill_zone_end;
  11.624 -	    cur_ace->n_sectors = ace_end - cur_ace->start_sect;
  11.625 -	} 
  11.626 -        else 
  11.627 -        {
  11.628 -	    /* The fun one: the ace entirely includes the kill zone. */
  11.629 -	    /* Cut the current ace down to just the bit before the kzone,
  11.630 -	       create a new ace for the bit just after it. */
  11.631 -	    new_ace = kmalloc(sizeof(*cur_ace), GFP_KERNEL);
  11.632 -	    new_ace->device = dev;
  11.633 -	    new_ace->start_sect = kill_zone_end;
  11.634 -	    new_ace->n_sectors = ace_end - kill_zone_end;
  11.635 -	    new_ace->mode = cur_ace->mode;
  11.636 -
  11.637 -	    cur_ace->n_sectors = start_sect - cur_ace->start_sect;
  11.638 -
  11.639 -	    list_add(&new_ace->list, cur_ace_head);
  11.640 -	}
  11.641 -    }
  11.642 -}
  11.643 -
  11.644 -/* Hold the lock on entry, it remains held on exit. */
  11.645 -static int xen_physdisk_grant_access(unsigned short dev,
  11.646 -				     unsigned short partition,
  11.647 -				     unsigned long start_sect,
  11.648 -				     unsigned long n_sectors,
  11.649 -				     int mode, struct task_struct *p)
  11.650 -{
  11.651 -    struct physdisk_ace *cur_ace;
  11.652 -
  11.653 -    /* Make sure it won't overlap with any existing ACEs. */
  11.654 -    /* XXX this isn't quite right if the domain already has read access
  11.655 -       and we try to grant write access, or vice versa. */
  11.656 -    xen_physdisk_revoke_access(dev, start_sect, n_sectors, p);
  11.657 -
  11.658 -    if ( mode ) 
  11.659 -    {
  11.660 -	cur_ace = kmalloc(sizeof(*cur_ace), GFP_KERNEL);
  11.661 -	cur_ace->device = dev;
  11.662 -	cur_ace->start_sect = start_sect;
  11.663 -	cur_ace->n_sectors = n_sectors;
  11.664 -	cur_ace->mode = mode;
  11.665 -	cur_ace->partition = partition;
  11.666 -
  11.667 -	list_add_tail(&cur_ace->list, &p->physdisk_aces);
  11.668 -    }
  11.669 -
  11.670 -    return 0;
  11.671 -}
  11.672  
  11.673 -static void xen_physdisk_probe_access(physdisk_probebuf_t * buf,
  11.674 -				      struct task_struct *p)
  11.675 -{
  11.676 -    int n_aces;
  11.677 -    struct list_head *cur_ace_head;
  11.678 -    struct physdisk_ace *cur_ace;
  11.679 -    int x = 0;
  11.680 -
  11.681 -    n_aces = 0;
  11.682 -    list_for_each(cur_ace_head, &p->physdisk_aces) 
  11.683 -    {
  11.684 -	x++;
  11.685 -	if ( x >= buf->start_ind ) 
  11.686 -        {
  11.687 -	    cur_ace = list_entry(cur_ace_head, struct physdisk_ace, list);
  11.688 -	    buf->entries[n_aces].device = cur_ace->device;
  11.689 -	    buf->entries[n_aces].partition = cur_ace->partition;
  11.690 -	    buf->entries[n_aces].start_sect = cur_ace->start_sect;
  11.691 -	    buf->entries[n_aces].n_sectors = cur_ace->n_sectors;
  11.692 -	    buf->entries[n_aces].mode = cur_ace->mode;
  11.693 -	    n_aces++;
  11.694 -	}
  11.695 -    }
  11.696 -    buf->n_aces = n_aces;
  11.697 -}
  11.698 -
  11.699 -int xen_physdisk_grant(xp_disk_t * xpd_in)
  11.700 -{
  11.701 -    struct task_struct *p = current;
  11.702 -    xp_disk_t *xpd = map_domain_mem(virt_to_phys(xpd_in));
  11.703 -    int res;
  11.704 -
  11.705 -    p = find_domain_by_id(xpd->domain);
  11.706 -    if ( p == NULL )
  11.707 -    {
  11.708 -	DPRINTK("Bad domain!\n");
  11.709 -	res = 1;
  11.710 -	goto out;
  11.711 -    }
  11.712 -
  11.713 -    spin_lock(&p->physdev_lock);
  11.714 -    res = xen_physdisk_grant_access(xpd->device,
  11.715 -				    xpd->partition,
  11.716 -				    xpd->start_sect,
  11.717 -				    xpd->n_sectors, xpd->mode, p);
  11.718 -    spin_unlock(&p->physdev_lock);
  11.719 -    put_task_struct(p);
  11.720 -
  11.721 -  out:
  11.722 -    unmap_domain_mem(xpd);
  11.723 -    return res;
  11.724 -}
  11.725 -
  11.726 -int xen_physdisk_probe(struct task_struct *requesting_domain,
  11.727 -		       physdisk_probebuf_t * buf_in)
  11.728 -{
  11.729 -    struct task_struct *p;
  11.730 -    physdisk_probebuf_t *buf = map_domain_mem(virt_to_phys(buf_in));
  11.731 -    int res;
  11.732 -
  11.733 -    if ( (requesting_domain->domain != 0) &&
  11.734 -	 (requesting_domain->domain != buf->domain) )
  11.735 -    {
  11.736 -	res = 1;
  11.737 -	goto out;
  11.738 -    }
  11.739 -
  11.740 -    p = find_domain_by_id(buf->domain);
  11.741 -    if ( p == NULL )
  11.742 -    {
  11.743 -	res = 1;
  11.744 -	goto out;
  11.745 -    }
  11.746 -
  11.747 -    spin_lock(&p->physdev_lock);
  11.748 -    xen_physdisk_probe_access(buf, p);
  11.749 -    spin_unlock(&p->physdev_lock);
  11.750 -    put_task_struct(p);
  11.751 -
  11.752 -    res = 0;
  11.753 -  out:
  11.754 -    unmap_domain_mem(buf);
  11.755 -    return res;
  11.756 -}
  11.757 -
  11.758 -#define MAX(a,b) ((a) > (b) ? (a) : (b))
  11.759 -
  11.760 -int xen_physdisk_access_okay(phys_seg_t * pseg, struct task_struct *p,
  11.761 -			     int operation)
  11.762 -{
  11.763 -    struct physdisk_ace *cur_ace;
  11.764 -    unsigned long sect;
  11.765 -
  11.766 -    DPRINTK
  11.767 -	("Checking access for domain %d, start sect 0x%lx, length 0x%x.\n",
  11.768 -	 p->domain, pseg->sector_number, pseg->nr_sects);
  11.769 -
  11.770 -    for ( sect = pseg->sector_number;
  11.771 -	  sect < pseg->sector_number + pseg->nr_sects; ) 
  11.772 -    {
  11.773 -	/* XXX this would be a lot faster if the aces were sorted on start
  11.774 -	   address.  Also in revoke_access. */
  11.775 -	spin_lock(&p->physdev_lock);
  11.776 -	cur_ace = find_ace(p, pseg->dev, sect, operation);
  11.777 -	spin_unlock(&p->physdev_lock);
  11.778 -	if ( cur_ace == NULL )
  11.779 -	    return 0;
  11.780 -	sect +=
  11.781 -	    MAX(cur_ace->n_sectors,
  11.782 -		pseg->nr_sects + pseg->sector_number - sect);
  11.783 -    }
  11.784 -    return 1;
  11.785 -}
  11.786 -
  11.787 -void destroy_physdisk_aces(struct task_struct *p)
  11.788 -{
  11.789 -    struct list_head *cur_ace_head, *next_head;
  11.790 -    struct physdisk_ace *cur_ace;
  11.791 -
  11.792 -    for ( cur_ace_head = p->physdisk_aces.next;
  11.793 -          cur_ace_head != &p->physdisk_aces; 
  11.794 -          cur_ace_head = next_head )
  11.795 -    {
  11.796 -	cur_ace = list_entry(cur_ace_head, struct physdisk_ace, list);
  11.797 -	next_head = cur_ace_head->next;
  11.798 -	kfree(cur_ace);
  11.799 -    }
  11.800 -}
  11.801 -
    12.1 --- a/xen/drivers/ide/ide-xeno.c	Wed Nov 05 11:50:12 2003 +0000
    12.2 +++ b/xen/drivers/ide/ide-xeno.c	Wed Nov 05 11:57:30 2003 +0000
    12.3 @@ -6,6 +6,24 @@
    12.4  #include <asm/domain_page.h>
    12.5  #include <asm/io.h>
    12.6  
    12.7 +#define NR_IDE_DEVS  20
    12.8 +
    12.9 +static kdev_t ide_devs[NR_IDE_DEVS] = { 
   12.10 +    MKDEV(IDE0_MAJOR, 0), MKDEV(IDE0_MAJOR, 64),                /* hda, hdb */
   12.11 +    MKDEV(IDE1_MAJOR, 0), MKDEV(IDE1_MAJOR, 64),                /* hdc, hdd */
   12.12 +    MKDEV(IDE2_MAJOR, 0), MKDEV(IDE2_MAJOR, 64),                /* hde, hdf */
   12.13 +    MKDEV(IDE3_MAJOR, 0), MKDEV(IDE3_MAJOR, 64),                /* hdg, hdh */
   12.14 +    MKDEV(IDE4_MAJOR, 0), MKDEV(IDE4_MAJOR, 64),                /* hdi, hdj */
   12.15 +    MKDEV(IDE5_MAJOR, 0), MKDEV(IDE5_MAJOR, 64),                /* hdk, hdl */
   12.16 +    MKDEV(IDE6_MAJOR, 0), MKDEV(IDE6_MAJOR, 64),                /* hdm, hdn */
   12.17 +    MKDEV(IDE7_MAJOR, 0), MKDEV(IDE7_MAJOR, 64),                /* hdo, hdp */
   12.18 +    MKDEV(IDE8_MAJOR, 0), MKDEV(IDE8_MAJOR, 64),                /* hdq, hdr */
   12.19 +    MKDEV(IDE9_MAJOR, 0), MKDEV(IDE9_MAJOR, 64)                 /* hds, hdt */
   12.20 +};
   12.21 +
   12.22 +
   12.23 +
   12.24 +
   12.25  void ide_probe_devices(xen_disk_info_t* xdi)
   12.26  {
   12.27      int loop;
   12.28 @@ -30,8 +48,10 @@ void ide_probe_devices(xen_disk_info_t* 
   12.29  	    ** as our 'type' field (XD_TYPE_DISK, XD_TYPE_CDROM, etc). 
   12.30  	    ** Hence must ensure these are kept in sync. 
   12.31  	    */
   12.32 +
   12.33 +	    /* SMH: we export 'raw' linux device numbers to domain 0 */
   12.34 +            device   = ide_devs[(loop * MAX_DRIVES) + unit]; 
   12.35  	    type     = drive->media; 
   12.36 -            device   = MK_IDE_XENDEV((loop * MAX_DRIVES) + unit);
   12.37              capacity = current_capacity(drive);
   12.38  
   12.39              xdi->disks[xdi->count].device   = device; 
    13.1 --- a/xen/drivers/scsi/sd.c	Wed Nov 05 11:50:12 2003 +0000
    13.2 +++ b/xen/drivers/scsi/sd.c	Wed Nov 05 11:57:30 2003 +0000
    13.3 @@ -1321,17 +1321,34 @@ static void sd_finish()
    13.4  ** easiest place to hook it in :-( 
    13.5  **
    13.6  */
    13.7 +
    13.8 +#define NR_SCSI_DEVS 16
    13.9 +
   13.10 +static kdev_t scsi_devs[NR_SCSI_DEVS] = { 
   13.11 +    MKDEV(SCSI_DISK0_MAJOR,   0), MKDEV(SCSI_DISK0_MAJOR,  16), /* sda, sdb */
   13.12 +    MKDEV(SCSI_DISK0_MAJOR,  32), MKDEV(SCSI_DISK0_MAJOR,  48), /* sdc, sdd */
   13.13 +    MKDEV(SCSI_DISK0_MAJOR,  64), MKDEV(SCSI_DISK0_MAJOR,  80), /* sde, sdf */
   13.14 +    MKDEV(SCSI_DISK0_MAJOR,  96), MKDEV(SCSI_DISK0_MAJOR, 112), /* sdg, sdh */
   13.15 +    MKDEV(SCSI_DISK0_MAJOR, 128), MKDEV(SCSI_DISK0_MAJOR, 144), /* sdi, sdj */
   13.16 +    MKDEV(SCSI_DISK0_MAJOR, 160), MKDEV(SCSI_DISK0_MAJOR, 176), /* sdk, sdl */
   13.17 +    MKDEV(SCSI_DISK0_MAJOR, 192), MKDEV(SCSI_DISK0_MAJOR, 208), /* sdm, sdn */
   13.18 +    MKDEV(SCSI_DISK0_MAJOR, 224), MKDEV(SCSI_DISK0_MAJOR, 240), /* sdo, sdp */
   13.19 +};
   13.20 +
   13.21 +
   13.22  void scsi_probe_devices(xen_disk_info_t *xdi)
   13.23  {
   13.24      Scsi_Disk *sd; 
   13.25      int i;
   13.26 -    unsigned long capacity, device;
   13.27 +    unsigned short device;
   13.28 +    unsigned long capacity;
   13.29  
   13.30      for ( sd = rscsi_disks, i = 0; i < sd_template.dev_max; i++, sd++ )
   13.31      {
   13.32          if ( sd->device == NULL ) continue;
   13.33  
   13.34 -        device   = MK_SCSI_XENDEV(i);
   13.35 +	/* SMH: we export 'raw' linux device numbers to domain 0 */
   13.36 +	device   = scsi_devs[i]; 
   13.37          capacity = sd->capacity;
   13.38  
   13.39  	/* XXX SMH: if make generic, need to properly determine 'type' */
    14.1 --- a/xen/include/hypervisor-ifs/block.h	Wed Nov 05 11:50:12 2003 +0000
    14.2 +++ b/xen/include/hypervisor-ifs/block.h	Wed Nov 05 11:57:30 2003 +0000
    14.3 @@ -9,28 +9,6 @@
    14.4  #define __BLOCK_H__
    14.5  
    14.6  /*
    14.7 - * Device numbers
    14.8 - */
    14.9 -
   14.10 -#define XENDEV_TYPE_MASK      0xf000
   14.11 -#define XENDEV_IDX_MASK       0x0fff
   14.12 -#define XENDEV_TYPE_SHIFT     12
   14.13 -#define XENDEV_IDX_SHIFT      0
   14.14 -
   14.15 -#define XENDEV_IDE            (1 << XENDEV_TYPE_SHIFT)
   14.16 -#define XENDEV_SCSI           (2 << XENDEV_TYPE_SHIFT)
   14.17 -#define XENDEV_VIRTUAL        (3 << XENDEV_TYPE_SHIFT)
   14.18 -
   14.19 -#define IS_IDE_XENDEV(_d)     (((_d) & XENDEV_TYPE_MASK) == XENDEV_IDE)
   14.20 -#define IS_SCSI_XENDEV(_d)    (((_d) & XENDEV_TYPE_MASK) == XENDEV_SCSI)
   14.21 -#define IS_VIRTUAL_XENDEV(_d) (((_d) & XENDEV_TYPE_MASK) == XENDEV_VIRTUAL)
   14.22 -
   14.23 -#define MK_IDE_XENDEV(_i)     ((_i) | XENDEV_IDE)
   14.24 -#define MK_SCSI_XENDEV(_i)    ((_i) | XENDEV_SCSI)
   14.25 -#define MK_VIRTUAL_XENDEV(_i) ((_i) | XENDEV_VIRTUAL)
   14.26 -
   14.27 -
   14.28 -/*
   14.29   *
   14.30   * These are the ring data structures for buffering messages between 
   14.31   * the hypervisor and guestos's.  
    15.1 --- a/xen/include/hypervisor-ifs/vbd.h	Wed Nov 05 11:50:12 2003 +0000
    15.2 +++ b/xen/include/hypervisor-ifs/vbd.h	Wed Nov 05 11:57:30 2003 +0000
    15.3 @@ -1,41 +1,11 @@
    15.4  #ifndef __HYP_IFS_VBD_H__
    15.5  #define __HYP_IFS_VBD_H__
    15.6  
    15.7 -#define XEN_MAX_VBDS 100     /* total number of vbds across all doms */
    15.8 -
    15.9 -#define XEN_VBD_UNUSED 0          /* bzero default */
   15.10 -#define XEN_DISK_READ_WRITE  1
   15.11 -#define XEN_DISK_READ_ONLY   2
   15.12 -#define XEN_VBD_RO XEN_DISK_READ_ONLY
   15.13 -#define XEN_VBD_RW XEN_DISK_READ_WRITE
   15.14 -
   15.15 -/*
   15.16 - *
   15.17 - * virtual disk (vhd) structures, used by XEN_BLOCK_VBD_{CREATE, DELETE}
   15.18 - *
   15.19 - */
   15.20 -
   15.21 -typedef struct xv_extent
   15.22 -{
   15.23 -  int disk;                                          /* physical disk number */
   15.24 -  unsigned long offset;               /* offset in blocks into physical disk */
   15.25 -  unsigned long size;                                      /* size in blocks */
   15.26 -} xv_extent_t;
   15.27 -
   15.28 -#define XEN_VBD_KEYSIZE 10
   15.29 -
   15.30 -typedef struct xv_disk
   15.31 -{
   15.32 -  int mode;                     /* XEN_DISK_READ_WRITE or XEN_DISK_READ_ONLY */
   15.33 -  int domain;                   /* domain */
   15.34 -  int vbd;                      /* segment number */
   15.35 -  char key[XEN_VBD_KEYSIZE];    /* key for benefit of dom0 userspace */
   15.36 -  int ext_count;                /* number of xv_extent_t to follow */
   15.37 -  xv_extent_t extents[XEN_MAX_DISK_COUNT];    /* arbitrary reuse of constant */
   15.38 -} xv_disk_t;
   15.39  
   15.40  #define PHYSDISK_MODE_R 1
   15.41  #define PHYSDISK_MODE_W 2
   15.42 +
   15.43 +#if 0
   15.44  typedef struct xp_disk
   15.45  {
   15.46    int mode; /* 0 -> revoke existing access, otherwise bitmask of
   15.47 @@ -60,43 +30,53 @@ typedef struct {
   15.48      unsigned mode;
   15.49    } entries[PHYSDISK_MAX_ACES_PER_REQUEST];
   15.50  } physdisk_probebuf_t;
   15.51 -
   15.52 -
   15.53 -typedef struct xen_vbd_info
   15.54 -{
   15.55 -    int count;
   15.56 -    struct {
   15.57 -        unsigned domain;
   15.58 -        unsigned seg_nr;
   15.59 -        char key[XEN_VBD_KEYSIZE];
   15.60 -        unsigned short mode;             /* UNUSED, RO, or RW. */
   15.61 -    } vbds[XEN_MAX_VBDS];
   15.62 -} xen_vbd_info_t;
   15.63 -
   15.64 +#endif
   15.65  
   15.66  
   15.67  /* Block I/O trap operations and associated structures.
   15.68   */
   15.69  
   15.70 -#define BLOCK_IO_OP_SIGNAL       0 /* let xen know we have work to do     */ 
   15.71 -#define BLOCK_IO_OP_ATTACH_VBD   1 /* attach a VBD to a given domain      */
   15.72 -#define BLOCK_IO_OP_RESET        2 /* reset ring indexes on quiescent i/f */
   15.73 -#define BLOCK_IO_OP_RING_ADDRESS 3 /* returns machine address of I/O ring */
   15.74 +#define BLOCK_IO_OP_SIGNAL       0    /* let xen know we have work to do */ 
   15.75 +#define BLOCK_IO_OP_RESET        1    /* reset ring indexes on quiescent i/f */
   15.76 +#define BLOCK_IO_OP_RING_ADDRESS 2 /* returns machine address of I/O ring */
   15.77 +#define BLOCK_IO_OP_VBD_CREATE   3    /* create a new VBD for a given domain */
   15.78 +#define BLOCK_IO_OP_VBD_ADD      4    /* add an extent to a given VBD */
   15.79 +#define BLOCK_IO_OP_VBD_REMOVE   5    /* remove an extent from a given VBD */
   15.80 +#define BLOCK_IO_OP_VBD_DELETE   6    /* delete a VBD */
   15.81  
   15.82 -typedef struct _extent { 
   15.83 -    u16       raw_device; 
   15.84 +
   15.85 +typedef struct _xen_extent { 
   15.86 +    u16       device; 
   15.87      ulong     start_sector; 
   15.88      ulong     nr_sectors;
   15.89 -} extent_t; 
   15.90 +    u16       mode; 
   15.91 +} xen_extent_t; 
   15.92  
   15.93 -    
   15.94 -typedef struct _vbd_attach { 
   15.95 -    int       domain; 
   15.96 -    u16       mode;                  /* read-only or read-write */ 
   15.97 -    u16       device;                /* how this domain refers to this VBD */
   15.98 -    int       nr_extents;            /* number of extents in the VBD */
   15.99 -    extent_t *extents;               /* pointer to /array/ of extents */
  15.100 -} vbd_attach_t; 
  15.101 +  
  15.102 +typedef struct _vbd_create { 
  15.103 +    unsigned  domain; 
  15.104 +    u16       vdevice; 
  15.105 +} vbd_create_t; 
  15.106 +
  15.107 +
  15.108 +typedef struct _vbd_add { 
  15.109 +    unsigned     domain; 
  15.110 +    u16          vdevice; 
  15.111 +    xen_extent_t extent; 
  15.112 +} vbd_add_t; 
  15.113 +
  15.114 +typedef struct _vbd_remove { 
  15.115 +    unsigned     domain; 
  15.116 +    u16          vdevice; 
  15.117 +    xen_extent_t extent; 
  15.118 +} vbd_remove_t; 
  15.119 +
  15.120 +
  15.121 +typedef struct _vbd_delete { 
  15.122 +    unsigned  domain; 
  15.123 +    u16       vdevice; 
  15.124 +} vbd_delete_t; 
  15.125 +
  15.126  
  15.127  
  15.128  typedef struct block_io_op_st
  15.129 @@ -104,10 +84,13 @@ typedef struct block_io_op_st
  15.130      unsigned long cmd;
  15.131      union
  15.132      {
  15.133 -        /* no entry for BLOCK_IO_OP_SIGNAL       */
  15.134 -	vbd_attach_t attach_info; 
  15.135 -        /* no entry for BLOCK_IO_OP_RESET        */
  15.136 -        unsigned long ring_mfn;
  15.137 +        /* no entry for BLOCK_IO_OP_SIGNAL */
  15.138 +        /* no entry for BLOCK_IO_OP_RESET  */
  15.139 +	unsigned long ring_mfn; 
  15.140 +	vbd_create_t  create_info; 
  15.141 +	vbd_add_t     add_info; 
  15.142 +	vbd_remove_t  remove_info; 
  15.143 +	vbd_delete_t  delete_info; 
  15.144      }
  15.145      u;
  15.146  } block_io_op_t;
    16.1 --- a/xen/include/xeno/sched.h	Wed Nov 05 11:50:12 2003 +0000
    16.2 +++ b/xen/include/xeno/sched.h	Wed Nov 05 11:57:30 2003 +0000
    16.3 @@ -119,7 +119,7 @@ struct task_struct
    16.4  				       the process can do raw access
    16.5  				       to. */
    16.6      spinlock_t physdev_lock;
    16.7 -    vbd_t *vbd_list[XEN_MAX_VBDS];
    16.8 +    vbd_t *vbdtab[VBD_HTAB_SZ];     // mapping from 16bit vdevices to vbds
    16.9  
   16.10      /* VM */
   16.11      struct mm_struct mm;
    17.1 --- a/xen/include/xeno/vbd.h	Wed Nov 05 11:50:12 2003 +0000
    17.2 +++ b/xen/include/xeno/vbd.h	Wed Nov 05 11:57:30 2003 +0000
    17.3 @@ -9,7 +9,34 @@
    17.4  #include <hypervisor-ifs/block.h>
    17.5  #include <hypervisor-ifs/vbd.h>
    17.6  
    17.7 -/* Describes a physical disk extent. */
    17.8 +/* an entry in a list of xen_extent's */
    17.9 +typedef struct _xen_extent_le { 
   17.10 +    xen_extent_t           extent;     // an individual extent  
   17.11 +    struct _xen_extent_le *next;       // and a pointer to the next 
   17.12 +} xen_extent_le_t; 
   17.13 +
   17.14 +
   17.15 +/*
   17.16 +** This is what a vbd looks like from the pov of xen: essentially a list 
   17.17 +** of xen_extents which a given domain refers to by a particular 16bit id. 
   17.18 +** Each domain has a hash table to map from these to the relevant VBD. 
   17.19 +*/
   17.20 +typedef struct _vbd { 
   17.21 +    unsigned short    vdevice;   // what the domain refers to this vbd as 
   17.22 +    xen_extent_le_t  *extents;   // list of xen_extents making up this vbd
   17.23 +    struct _vbd      *next;      // for chaining in the hash table
   17.24 +} vbd_t; 
   17.25 +
   17.26 +#define VBD_HTAB_SZ  16       // no. of entries in the vbd hash table. 
   17.27 +
   17.28 +void xen_vbd_initialize(void);
   17.29 +void xen_refresh_vbd_list (struct task_struct *p);
   17.30 +long vbd_create(vbd_create_t *create_info); 
   17.31 +long vbd_add(vbd_add_t *add_info); 
   17.32 +long vbd_remove(vbd_remove_t *remove_info);
   17.33 +long vbd_delete(vbd_delete_t *delete_info); 
   17.34 +
   17.35 +/* Describes a physical disk extent (part of a block io request) */
   17.36  typedef struct {
   17.37      unsigned short dev;
   17.38      unsigned short nr_sects;
   17.39 @@ -17,34 +44,12 @@ typedef struct {
   17.40      unsigned long  buffer;
   17.41  } phys_seg_t;
   17.42  
   17.43 -struct task_struct;
   17.44 -
   17.45 -void xen_vbd_initialize(void);
   17.46 -void xen_refresh_vbd_list (struct task_struct *p);
   17.47 -int xen_vbd_create(xv_disk_t *xvd);
   17.48 -int xen_vbd_delete(struct task_struct *p, int segnr);
   17.49 -int xen_vbd_map_request(
   17.50 -    phys_seg_t *pseg, struct task_struct *p, int operation,
   17.51 -    unsigned short vbd_number,
   17.52 -    unsigned long sect_nr, unsigned long buffer, unsigned short nr_sects);
   17.53  
   17.54 -typedef struct vbd
   17.55 -{
   17.56 -    int mode;                         /* UNUSED, RO, or RW */
   17.57 -    int domain;
   17.58 -    int vbd_number;               /* vbd number for domain */
   17.59 -    char key[XEN_VBD_KEYSIZE];    /* for the userspace tools in dom0 */
   17.60 -    int num_extents;                  /* number of extents */
   17.61 -    extent_t *extents;
   17.62 -} vbd_t;
   17.63 +int vbd_translate(phys_seg_t * pseg, int *nr_segs, 
   17.64 +		  struct task_struct *p, int operation); 
   17.65  
   17.66 -#endif
   17.67  
   17.68 -#ifndef PHYSDISK_ACES__
   17.69 -#define PHYSDISK_ACES__
   17.70 -
   17.71 -struct task_struct;
   17.72 -
   17.73 +#if 0
   17.74  void destroy_physdisk_aces(struct task_struct *p);
   17.75  
   17.76  int xen_physdisk_grant(xp_disk_t *);
   17.77 @@ -52,5 +57,7 @@ int xen_physdisk_probe(struct task_struc
   17.78  		       physdisk_probebuf_t *);
   17.79  int xen_physdisk_access_okay(phys_seg_t *pseg, struct task_struct *p,
   17.80  			     int operation);
   17.81 +#endif
   17.82 +
   17.83  
   17.84  #endif /* PHYSDISK_ACES__ */
    18.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/Makefile	Wed Nov 05 11:50:12 2003 +0000
    18.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/Makefile	Wed Nov 05 11:57:30 2003 +0000
    18.3 @@ -1,3 +1,3 @@
    18.4  O_TARGET := blk.o
    18.5 -obj-y := xl_block.o xl_ide.o xl_scsi.o xl_vbd.o info.o
    18.6 +obj-y := xl_block.o xl_vbd.o info.o
    18.7  include $(TOPDIR)/Rules.make
    19.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c	Wed Nov 05 11:50:12 2003 +0000
    19.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c	Wed Nov 05 11:57:30 2003 +0000
    19.3 @@ -55,95 +55,11 @@ static inline void signal_requests_to_xe
    19.4      return;
    19.5  }
    19.6  
    19.7 -
    19.8 -inline kdev_t physdev_to_xldev(unsigned short physdev)
    19.9 -{
   19.10 -    switch (physdev & XENDEV_TYPE_MASK) {
   19.11 -    case XENDEV_IDE:
   19.12 -        if ( (physdev & XENDEV_IDX_MASK) < XLIDE_DEVS_PER_MAJOR) {
   19.13 -	    return MKDEV(XLIDE_MAJOR_0,
   19.14 -			 (physdev & XENDEV_IDX_MASK) << XLIDE_PARTN_SHIFT);
   19.15 -	} else if ( (physdev & XENDEV_IDX_MASK) < (XLIDE_DEVS_PER_MAJOR * 2)) {
   19.16 -	    return MKDEV(XLIDE_MAJOR_1,
   19.17 -			 (physdev & XENDEV_IDX_MASK) << XLIDE_PARTN_SHIFT);
   19.18 -	}
   19.19 -	break;
   19.20 -    case XENDEV_SCSI:
   19.21 -	return MKDEV(XLSCSI_MAJOR,
   19.22 -		     (physdev & XENDEV_IDX_MASK) << XLSCSI_PARTN_SHIFT);
   19.23 -    case XENDEV_VIRTUAL:
   19.24 -	return MKDEV(XLVIRT_MAJOR,
   19.25 -		     (physdev & XENDEV_IDX_MASK) << XLVIRT_PARTN_SHIFT);
   19.26 -    }
   19.27 -
   19.28 -    return 0;
   19.29 -}
   19.30 -
   19.31 -
   19.32 -/* Convert from a XenoLinux major device to the Xen-level 'physical' device */
   19.33 -inline unsigned short xldev_to_physdev(kdev_t xldev) 
   19.34 -{
   19.35 -    unsigned short physdev = 0;
   19.36 -
   19.37 -    switch ( MAJOR(xldev) ) 
   19.38 -    { 
   19.39 -    case XLIDE_MAJOR_0: 
   19.40 -        physdev = XENDEV_IDE + (0*XLIDE_DEVS_PER_MAJOR) +
   19.41 -            (MINOR(xldev) >> XLIDE_PARTN_SHIFT);
   19.42 -	break; 
   19.43 -
   19.44 -    case XLIDE_MAJOR_1:
   19.45 -	physdev = XENDEV_IDE + (1*XLIDE_DEVS_PER_MAJOR) +
   19.46 -            (MINOR(xldev) >> XLIDE_PARTN_SHIFT);
   19.47 -        break;
   19.48 -
   19.49 -    case XLSCSI_MAJOR: 
   19.50 -        physdev = XENDEV_SCSI + (MINOR(xldev) >> XLSCSI_PARTN_SHIFT);
   19.51 -	break; 
   19.52 -
   19.53 -    case XLVIRT_MAJOR:
   19.54 -        physdev = XENDEV_VIRTUAL + (MINOR(xldev) >> XLVIRT_PARTN_SHIFT);
   19.55 -        break;
   19.56 -    } 
   19.57 -
   19.58 -    return physdev;
   19.59 -}
   19.60 -
   19.61 -
   19.62 -static inline struct gendisk *xldev_to_gendisk(kdev_t xldev) 
   19.63 -{
   19.64 -    struct gendisk *gd = NULL;
   19.65 -
   19.66 -    switch ( MAJOR(xldev) ) 
   19.67 -    { 
   19.68 -    case XLIDE_MAJOR_0: 
   19.69 -        gd = xlide_gendisk[0];
   19.70 -	break; 
   19.71 -	
   19.72 -    case XLIDE_MAJOR_1: 
   19.73 -        gd = xlide_gendisk[1];
   19.74 -	break; 
   19.75 -	
   19.76 -    case XLSCSI_MAJOR: 
   19.77 -        gd = xlscsi_gendisk;
   19.78 -	break; 
   19.79 -
   19.80 -    case XLVIRT_MAJOR:
   19.81 -        gd = xlvbd_gendisk;
   19.82 -        break;
   19.83 -    }
   19.84 -
   19.85 -    if ( gd == NULL ) BUG();
   19.86 -
   19.87 -    return gd;
   19.88 -}
   19.89 -
   19.90 -
   19.91  static inline xl_disk_t *xldev_to_xldisk(kdev_t xldev)
   19.92  {
   19.93      struct gendisk *gd = xldev_to_gendisk(xldev);
   19.94      return (xl_disk_t *)gd->real_devices + 
   19.95 -        (MINOR(xldev) >> PARTN_SHIFT(xldev));
   19.96 +        (MINOR(xldev) >> gd->minor_shift);
   19.97  }
   19.98  
   19.99  
  19.100 @@ -192,27 +108,7 @@ int xenolinux_block_ioctl(struct inode *
  19.101          return xenolinux_block_revalidate(dev);
  19.102  
  19.103      case BLKSSZGET:
  19.104 -	switch ( MAJOR(dev) )
  19.105 -        {
  19.106 -	case XLIDE_MAJOR_0: 
  19.107 -	    DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET, 
  19.108 -			  xlide_hwsect(MINOR(dev)));
  19.109 -	    return xlide_hwsect(MINOR(dev)); 
  19.110 -
  19.111 -	case XLSCSI_MAJOR: 
  19.112 -	    DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET,
  19.113 -			  xlscsi_hwsect(MINOR(dev)));
  19.114 -	    return xlscsi_hwsect(MINOR(dev)); 
  19.115 -
  19.116 -        case XLVIRT_MAJOR:
  19.117 -	    DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET, 
  19.118 -			  xlsbd_hwsect(MINOR(dev)));
  19.119 -	    return xlvbd_hwsect(MINOR(dev)); 
  19.120 -
  19.121 -	default: 
  19.122 -	    printk(KERN_ALERT "BLKSSZGET ioctl() on bogus disk!\n"); 
  19.123 -            return 0;
  19.124 -	}
  19.125 +	return hardsect_size[MAJOR(dev)][MINOR(dev)]; 
  19.126  
  19.127      case BLKBSZGET:                                        /* get block size */
  19.128          DPRINTK_IOCTL("   BLKBSZGET: %x\n", BLKBSZGET);
  19.129 @@ -275,7 +171,7 @@ int xenolinux_block_revalidate(kdev_t de
  19.130      struct gendisk *gd = xldev_to_gendisk(dev);
  19.131      xl_disk_t *disk = xldev_to_xldisk(dev);
  19.132      unsigned long flags;
  19.133 -    int i, partn_shift = PARTN_SHIFT(dev), disk_nr = MINOR(dev) >> partn_shift;
  19.134 +    int i, disk_nr = MINOR(dev) >> gd->minor_shift; 
  19.135      
  19.136      DPRINTK("xenolinux_block_revalidate: %d\n", dev);
  19.137  
  19.138 @@ -287,13 +183,14 @@ int xenolinux_block_revalidate(kdev_t de
  19.139      }
  19.140      spin_unlock_irqrestore(&io_request_lock, flags);
  19.141  
  19.142 -    for ( i = (1 << partn_shift) - 1; i >= 0; i-- )
  19.143 +    for ( i = gd->nr_real - 1; i >= 0; i-- )
  19.144      {
  19.145          invalidate_device(dev+i, 1);
  19.146          gd->part[MINOR(dev+i)].start_sect = 0;
  19.147          gd->part[MINOR(dev+i)].nr_sects = 0;
  19.148      }
  19.149  
  19.150 +#if 0
  19.151      /* VBDs can change under our feet. Check if that has happened. */
  19.152      if ( MAJOR(dev) == XLVIRT_MAJOR )
  19.153      {
  19.154 @@ -311,9 +208,9 @@ int xenolinux_block_revalidate(kdev_t de
  19.155              kfree(xdi);
  19.156          }
  19.157      }
  19.158 +#endif
  19.159  
  19.160 -    grok_partitions(gd, disk_nr,
  19.161 -                    1 << partn_shift, disk->capacity);
  19.162 +    grok_partitions(gd, disk_nr, gd->nr_real, disk->capacity);
  19.163  
  19.164      return 0;
  19.165  }
  19.166 @@ -337,7 +234,6 @@ static int hypervisor_request(unsigned l
  19.167                                kdev_t          device)
  19.168  {
  19.169      unsigned long buffer_ma = phys_to_machine(virt_to_phys(buffer)); 
  19.170 -    kdev_t phys_device = (kdev_t) 0;
  19.171      struct gendisk *gd;
  19.172      blk_ring_req_entry_t *req;
  19.173      struct buffer_head *bh;
  19.174 @@ -350,25 +246,20 @@ static int hypervisor_request(unsigned l
  19.175  
  19.176      switch ( operation )
  19.177      {
  19.178 -    case XEN_BLOCK_VBD_CREATE:
  19.179 -    case XEN_BLOCK_VBD_DELETE:
  19.180 -    case XEN_BLOCK_PHYSDEV_GRANT:
  19.181 -    case XEN_BLOCK_PHYSDEV_PROBE:
  19.182 +//    case XEN_BLOCK_PHYSDEV_GRANT:
  19.183 +//    case XEN_BLOCK_PHYSDEV_PROBE:
  19.184      case XEN_BLOCK_PROBE:
  19.185          if ( RING_PLUGGED ) return 1;
  19.186 -	phys_device = (kdev_t) 0;
  19.187  	sector_number = 0;
  19.188          DISABLE_SCATTERGATHER();
  19.189          break;
  19.190  
  19.191      case XEN_BLOCK_READ:
  19.192      case XEN_BLOCK_WRITE:
  19.193 -        phys_device = xldev_to_physdev(device);
  19.194  	gd = xldev_to_gendisk(device); 
  19.195 -
  19.196  	sector_number += gd->part[MINOR(device)].start_sect;
  19.197          if ( (sg_operation == operation) &&
  19.198 -             (sg_dev == phys_device) &&
  19.199 +             (sg_dev == device) &&
  19.200               (sg_next_sect == sector_number) )
  19.201          {
  19.202              req = &blk_ring->ring[(req_prod-1)&(BLK_RING_SIZE-1)].req;
  19.203 @@ -389,7 +280,7 @@ static int hypervisor_request(unsigned l
  19.204          else
  19.205          {
  19.206              sg_operation = operation;
  19.207 -            sg_dev       = phys_device;
  19.208 +            sg_dev       = device;
  19.209              sg_next_sect = sector_number + nr_sectors;
  19.210          }
  19.211          break;
  19.212 @@ -403,7 +294,7 @@ static int hypervisor_request(unsigned l
  19.213      req->id            = id;
  19.214      req->operation     = operation;
  19.215      req->sector_number = sector_number;
  19.216 -    req->device        = phys_device;
  19.217 +    req->device        = device; 
  19.218      req->nr_segments   = 1;
  19.219      req->buffer_and_sects[0] = buffer_ma | nr_sectors;
  19.220      req_prod = BLK_RING_INC(req_prod);
  19.221 @@ -542,9 +433,11 @@ static void xlblk_response_int(int irq, 
  19.222  	    
  19.223          case XEN_BLOCK_VBD_CREATE:
  19.224          case XEN_BLOCK_VBD_DELETE:
  19.225 -        case XEN_BLOCK_PROBE:
  19.226  	case XEN_BLOCK_PHYSDEV_GRANT:
  19.227  	case XEN_BLOCK_PHYSDEV_PROBE:
  19.228 +	    printk(KERN_ALERT "response for bogus operation %d\n", 
  19.229 +		   bret->operation); 
  19.230 +        case XEN_BLOCK_PROBE:
  19.231              xlblk_control_msg_pending = bret->status;
  19.232              break;
  19.233  	  
  19.234 @@ -637,24 +530,7 @@ int __init xlblk_init(void)
  19.235          goto fail;
  19.236      }
  19.237  
  19.238 -    { 
  19.239 -	int i; 
  19.240 -	printk(KERN_ALERT "xlblk_init: xen returned info for %d disks\n", 
  19.241 -	       xlblk_disk_info.count); 
  19.242 -	for(i=0; i < xlblk_disk_info.count; i++) { 
  19.243 -            printk("%d -- device no=%x, type=%d, capacity=%ldMB\n",
  19.244 -                   i, xlblk_disk_info.disks[i].device, 
  19.245 -		   xlblk_disk_info.disks[i].type, 
  19.246 -		   xlblk_disk_info.disks[i].capacity >> 11); 
  19.247 -
  19.248 -	}
  19.249 -	
  19.250 -    }	
  19.251 -    /* Pass the information to our fake IDE and SCSI susbystems. */
  19.252 -    xlide_init(&xlblk_disk_info);
  19.253 -    xlscsi_init(&xlblk_disk_info);
  19.254 -
  19.255 -    /* And do the same for the 'virtual block device' world */
  19.256 +    /* Pass the information to our virtual block device susbystem. */
  19.257      xlvbd_init(&xlblk_disk_info);
  19.258  
  19.259      return 0;
  19.260 @@ -666,8 +542,6 @@ int __init xlblk_init(void)
  19.261  static void __exit xlblk_cleanup(void)
  19.262  {
  19.263      xlvbd_cleanup();
  19.264 -    xlscsi_cleanup();
  19.265 -    xlide_cleanup();
  19.266      free_irq(XLBLK_RESPONSE_IRQ, NULL);
  19.267  }
  19.268  
    20.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.h	Wed Nov 05 11:50:12 2003 +0000
    20.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.h	Wed Nov 05 11:57:30 2003 +0000
    20.3 @@ -39,37 +39,9 @@
    20.4  #define DPRINTK_IOCTL(_f, _a...) ((void)0)
    20.5  #endif
    20.6  
    20.7 -/* XL IDE and SCSI use same major/minor numbers as normal Linux devices. */
    20.8 -#define XLIDE_MAJOR_0 IDE0_MAJOR
    20.9 -#define XLIDE_MAJOR_1 IDE1_MAJOR
   20.10 -#define XLSCSI_MAJOR SCSI_DISK0_MAJOR
   20.11 -
   20.12 -#define XLIDE_PARTN_SHIFT  6
   20.13 -#define XLSCSI_PARTN_SHIFT 4
   20.14 -#define XLVIRT_PARTN_SHIFT 4
   20.15 -
   20.16 -static inline int PARTN_SHIFT(kdev_t dev)
   20.17 -{
   20.18 -    switch ( MAJOR(dev) )
   20.19 -    {
   20.20 -    case XLIDE_MAJOR_0:
   20.21 -    case XLIDE_MAJOR_1:
   20.22 -        return XLIDE_PARTN_SHIFT;
   20.23 -    case XLSCSI_MAJOR:
   20.24 -        return XLSCSI_PARTN_SHIFT;
   20.25 -    case XLVIRT_MAJOR:
   20.26 -        return XLVIRT_PARTN_SHIFT;
   20.27 -    default:
   20.28 -        BUG();
   20.29 -    }
   20.30 -}
   20.31 -
   20.32 -#define XLIDE_DEVS_PER_MAJOR   2
   20.33 -#define XLSCSI_DEVS_PER_MAJOR 16
   20.34 -#define XLVIRT_DEVS_PER_MAJOR 16
   20.35  
   20.36  /*
   20.37 - * We have one of these per XL-IDE, XL-SCSI, and XL-VIRT device.
   20.38 + * We have one of these per vbd, whether ide, scsi or 'other'.
   20.39   * They hang in an array off the gendisk structure. We may end up putting
   20.40   * all kinds of interesting stuff here :-)
   20.41   */
   20.42 @@ -88,25 +60,10 @@ extern int xenolinux_block_check(kdev_t 
   20.43  extern int xenolinux_block_revalidate(kdev_t dev);
   20.44  extern void do_xlblk_request (request_queue_t *rq); 
   20.45  
   20.46 -/* Fake IDE subsystem. */
   20.47 -extern int  xlide_init(xen_disk_info_t *xdi);
   20.48 -extern int  xlide_hwsect(int minor); 
   20.49 -extern void xlide_cleanup(void); 
   20.50 -extern struct gendisk *xlide_gendisk[];
   20.51 -
   20.52 -/* Fake SCSI subsystem. */
   20.53 -extern int  xlscsi_init(xen_disk_info_t *xdi);
   20.54 -extern int  xlscsi_hwsect(int minor); 
   20.55 -extern void xlscsi_cleanup(void); 
   20.56 -extern struct gendisk *xlscsi_gendisk;
   20.57  
   20.58  /* Virtual block-device subsystem. */
   20.59  extern int  xlvbd_init(xen_disk_info_t *xdi);
   20.60 -extern int  xlvbd_hwsect(int minor); 
   20.61  extern void xlvbd_cleanup(void); 
   20.62 -extern struct gendisk *xlvbd_gendisk;
   20.63 -
   20.64 -extern unsigned short xldev_to_physdev(kdev_t xldev);
   20.65 -extern kdev_t physdev_to_xldev(unsigned short physdev);
   20.66 +extern struct gendisk *xldev_to_gendisk(kdev_t xldev);
   20.67  
   20.68  #endif /* __XL_BLOCK_H__ */
    21.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_ide.c	Wed Nov 05 11:50:12 2003 +0000
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,204 +0,0 @@
    21.4 -/******************************************************************************
    21.5 - * xl_ide.c
    21.6 - * 
    21.7 - * Xenolinux virtual IDE block-device driver.
    21.8 - */
    21.9 -
   21.10 -#include "xl_block.h"
   21.11 -#include <linux/blk.h>
   21.12 -
   21.13 -#define XLIDE_MAX         256
   21.14 -#define XLIDE_MAJOR_NAME "hd"
   21.15 -static int xlide_blksize_size[XLIDE_MAX];
   21.16 -static int xlide_hardsect_size[XLIDE_MAX];
   21.17 -static int xlide_max_sectors[XLIDE_MAX];
   21.18 -
   21.19 -#define XLIDE_NR_MAJORS     2
   21.20 -
   21.21 -struct gendisk *xlide_gendisk[XLIDE_NR_MAJORS] = { NULL };
   21.22 -
   21.23 -static struct block_device_operations xlide_block_fops = 
   21.24 -{
   21.25 -    open:               xenolinux_block_open,
   21.26 -    release:            xenolinux_block_release,
   21.27 -    ioctl:              xenolinux_block_ioctl,
   21.28 -    check_media_change: xenolinux_block_check,
   21.29 -    revalidate:         xenolinux_block_revalidate,
   21.30 -};
   21.31 -
   21.32 -int xlide_hwsect(int minor) 
   21.33 -{
   21.34 -    return xlide_hardsect_size[minor]; 
   21.35 -} 
   21.36 -
   21.37 -static int get_major(int major)
   21.38 -{
   21.39 -    int r = register_blkdev(major, XLIDE_MAJOR_NAME, &xlide_block_fops);
   21.40 -    if ( r < 0 )
   21.41 -        printk (KERN_ALERT "XL IDE: can't get major %d\n", XLIDE_MAJOR_0);
   21.42 -    return r;
   21.43 -}
   21.44 -
   21.45 -static void setup_major(struct gendisk **pgd, 
   21.46 -                        xen_disk_info_t *xdi, int base, int major)
   21.47 -{
   21.48 -    int i, minors, disk, units = XLIDE_DEVS_PER_MAJOR;
   21.49 -    unsigned short minor; 
   21.50 -    unsigned char buf[64];
   21.51 -    struct gendisk *gd;
   21.52 -
   21.53 -    blk_size[major]      = NULL;
   21.54 -    blksize_size[major]  = xlide_blksize_size + base*(1<<XLIDE_PARTN_SHIFT);
   21.55 -    hardsect_size[major] = xlide_hardsect_size + base*(1<<XLIDE_PARTN_SHIFT);
   21.56 -    max_sectors[major]   = xlide_max_sectors + base*(1<<XLIDE_PARTN_SHIFT);
   21.57 -    read_ahead[major]    = 8;
   21.58 -
   21.59 -    blk_init_queue(BLK_DEFAULT_QUEUE(major), do_xlblk_request);
   21.60 -
   21.61 -    /*
   21.62 -     * Turn off barking 'headactive' mode. We dequeue buffer heads as soon as 
   21.63 -     * we pass them down to Xen.
   21.64 -     */
   21.65 -    blk_queue_headactive(BLK_DEFAULT_QUEUE(major), 0);
   21.66 -
   21.67 -    /* Construct an appropriate gendisk structure. */
   21.68 -    minors    = units * (1<<XLIDE_PARTN_SHIFT);
   21.69 -    gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
   21.70 -    gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
   21.71 -    gd->part  = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
   21.72 -    gd->major        = major;
   21.73 -    gd->major_name   = XLIDE_MAJOR_NAME;
   21.74 -    gd->minor_shift  = XLIDE_PARTN_SHIFT; 
   21.75 -    gd->max_p	     = 1<<XLIDE_PARTN_SHIFT;
   21.76 -    gd->nr_real	     = units;           
   21.77 -    gd->real_devices = kmalloc(units * sizeof(xl_disk_t), GFP_KERNEL);
   21.78 -    gd->next	     = NULL;            
   21.79 -    gd->fops         = &xlide_block_fops;
   21.80 -    gd->de_arr       = kmalloc(sizeof(*gd->de_arr) * units, GFP_KERNEL);
   21.81 -    gd->flags	     = kmalloc(sizeof(*gd->flags) * units, GFP_KERNEL);
   21.82 -    memset(gd->sizes, 0, minors * sizeof(int));
   21.83 -    memset(gd->part,  0, minors * sizeof(struct hd_struct));
   21.84 -    memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
   21.85 -    memset(gd->flags, 0, sizeof(*gd->flags) * units);
   21.86 -    memset(gd->real_devices, 0, sizeof(xl_disk_t) * units);
   21.87 -    *pgd = gd;
   21.88 -    add_gendisk(gd);
   21.89 -    
   21.90 -    /* Now register each disk in turn. */
   21.91 -    for ( i = 0; i < xdi->count; i++ )
   21.92 -    {
   21.93 -        disk  = xdi->disks[i].device & XENDEV_IDX_MASK;
   21.94 -        minor = (disk-base) << XLIDE_PARTN_SHIFT; 
   21.95 -
   21.96 -        if ( !IS_IDE_XENDEV(xdi->disks[i].device) ||
   21.97 -             (disk < base) || (disk >= (base + XLIDE_DEVS_PER_MAJOR)) ) 
   21.98 -            continue;
   21.99 -
  21.100 -        ((xl_disk_t *)gd->real_devices)[disk-base].capacity =
  21.101 -            xdi->disks[i].capacity;
  21.102 -
  21.103 -        switch (xdi->disks[i].type) 
  21.104 -        { 
  21.105 -        case XD_TYPE_CDROM:
  21.106 -            set_device_ro(MKDEV(major, minor), 1); 
  21.107 -
  21.108 -        case XD_TYPE_FLOPPY: 
  21.109 -        case XD_TYPE_TAPE:
  21.110 -            gd->flags[disk] = GENHD_FL_REMOVABLE; 
  21.111 -            printk(KERN_ALERT "Skipping partition check on %s /dev/%s\n", 
  21.112 -                   xdi->disks[i].type==XD_TYPE_CDROM ? "cdrom" : 
  21.113 -                   (xdi->disks[i].type==XD_TYPE_TAPE ? "tape" : "floppy"), 
  21.114 -                   disk_name(gd, minor, buf)); 
  21.115 -            break; 
  21.116 -
  21.117 -        case XD_TYPE_DISK: 
  21.118 -            register_disk(gd, 
  21.119 -                          MKDEV(major, minor), 
  21.120 -                          1<<XLIDE_PARTN_SHIFT, 
  21.121 -                          &xlide_block_fops, xdi->disks[i].capacity);
  21.122 -            break; 
  21.123 -
  21.124 -        default: 
  21.125 -            printk(KERN_ALERT "XenoLinux: unknown ide device type %d\n", 
  21.126 -                   xdi->disks[i].type); 
  21.127 -            break; 
  21.128 -        }
  21.129 -    }
  21.130 -
  21.131 -    return;
  21.132 -}
  21.133 -
  21.134 -
  21.135 -int xlide_init(xen_disk_info_t *xdi) 
  21.136 -{
  21.137 -    int i, units;
  21.138 -
  21.139 -    /* If we don't have any usable IDE devices we may as well bail now. */
  21.140 -    units = 0;
  21.141 -    for ( i = 0; i < xdi->count; i++ )
  21.142 -        if ( IS_IDE_XENDEV(xdi->disks[i].device) &&
  21.143 -             ((xdi->disks[i].device & XENDEV_IDX_MASK) <
  21.144 -              (XLIDE_NR_MAJORS*XLIDE_DEVS_PER_MAJOR)) ) 
  21.145 -            units++;
  21.146 -    if ( units == 0 ) return 0;
  21.147 -
  21.148 -    SET_MODULE_OWNER(&xlide_block_fops);
  21.149 -    
  21.150 -    if ( get_major(XLIDE_MAJOR_0) < 0 )
  21.151 -        return 0;
  21.152 -    if ( get_major(XLIDE_MAJOR_1) < 0 )
  21.153 -    {
  21.154 -        (void)unregister_blkdev(XLIDE_MAJOR_0, XLIDE_MAJOR_NAME);
  21.155 -        return 0;
  21.156 -    }
  21.157 -
  21.158 -    /* Initialize global arrays. */
  21.159 -    for ( i = 0; i < XLIDE_MAX; i++ )
  21.160 -    {
  21.161 -        xlide_blksize_size[i]  = 512;
  21.162 -        xlide_hardsect_size[i] = 512;
  21.163 -        xlide_max_sectors[i]   = 128;
  21.164 -    }
  21.165 -
  21.166 -    setup_major(&xlide_gendisk[0], xdi, 0*XLIDE_DEVS_PER_MAJOR, XLIDE_MAJOR_0);
  21.167 -    setup_major(&xlide_gendisk[1], xdi, 1*XLIDE_DEVS_PER_MAJOR, XLIDE_MAJOR_1);
  21.168 -
  21.169 -    return 0;
  21.170 -}
  21.171 -
  21.172 -
  21.173 -static void cleanup_major(int major)
  21.174 -{
  21.175 -    blk_cleanup_queue(BLK_DEFAULT_QUEUE(major));
  21.176 -
  21.177 -    read_ahead[major] = 0;
  21.178 -
  21.179 -    if ( blksize_size[major] != NULL )
  21.180 -    { 
  21.181 -	kfree(blksize_size[major]);
  21.182 -        blksize_size[major] = NULL;
  21.183 -    }
  21.184 -
  21.185 -    if ( hardsect_size[major] != NULL )
  21.186 -    { 
  21.187 -	kfree(hardsect_size[major]);
  21.188 -        hardsect_size[major] = NULL;
  21.189 -    }
  21.190 -    
  21.191 -    if ( max_sectors[major] != NULL )
  21.192 -    { 
  21.193 -	kfree(max_sectors[major]);
  21.194 -        max_sectors[major] = NULL;
  21.195 -    }
  21.196 -    
  21.197 -    (void)unregister_blkdev(major, XLIDE_MAJOR_NAME);
  21.198 -}
  21.199 -
  21.200 -void xlide_cleanup(void)
  21.201 -{
  21.202 -    if ( xlide_gendisk[0] == NULL ) return;
  21.203 -    xlide_gendisk[0] = NULL;
  21.204 -    cleanup_major(XLIDE_MAJOR_0);
  21.205 -    cleanup_major(XLIDE_MAJOR_1);
  21.206 -}
  21.207 -
    22.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_scsi.c	Wed Nov 05 11:50:12 2003 +0000
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,168 +0,0 @@
    22.4 -/******************************************************************************
    22.5 - * xl_scsi.c
    22.6 - * 
    22.7 - * Xenolinux virtual SCSI block-device driver.
    22.8 - */
    22.9 -
   22.10 -#include "xl_block.h"
   22.11 -
   22.12 -#define MAJOR_NR XLSCSI_MAJOR
   22.13 -#include <linux/blk.h>
   22.14 -
   22.15 -#define XLSCSI_MAX        256
   22.16 -#define XLSCSI_MAJOR_NAME "sd"
   22.17 -static int xlscsi_blksize_size[XLSCSI_MAX];
   22.18 -static int xlscsi_hardsect_size[XLSCSI_MAX];
   22.19 -static int xlscsi_max_sectors[XLSCSI_MAX];
   22.20 -
   22.21 -struct gendisk *xlscsi_gendisk = NULL;
   22.22 -
   22.23 -static struct block_device_operations xlscsi_block_fops = 
   22.24 -{
   22.25 -    open:               xenolinux_block_open,
   22.26 -    release:            xenolinux_block_release,
   22.27 -    ioctl:              xenolinux_block_ioctl,
   22.28 -    check_media_change: xenolinux_block_check,
   22.29 -    revalidate:         xenolinux_block_revalidate,
   22.30 -};
   22.31 -
   22.32 -
   22.33 -/* tiny inteface fn */
   22.34 -int xlscsi_hwsect(int minor) 
   22.35 -{
   22.36 -    return xlscsi_hardsect_size[minor]; 
   22.37 -} 
   22.38 -
   22.39 -
   22.40 -int xlscsi_init(xen_disk_info_t *xdi) 
   22.41 -{
   22.42 -    int i, result, units, minors, disk;
   22.43 -    struct gendisk *gd;
   22.44 -
   22.45 -    /* If we don't have any usable SCSI devices we may as well bail now. */
   22.46 -    units = 0;
   22.47 -    for ( i = 0; i < xdi->count; i++ )
   22.48 -        if ( IS_SCSI_XENDEV(xdi->disks[i].device) &&
   22.49 -             ((xdi->disks[i].device & XENDEV_IDX_MASK) <
   22.50 -              XLSCSI_DEVS_PER_MAJOR) ) 
   22.51 -            units++;
   22.52 -    if ( units == 0 ) return 0;
   22.53 -
   22.54 -    SET_MODULE_OWNER(&xlscsi_block_fops);
   22.55 -
   22.56 -    result = register_blkdev(XLSCSI_MAJOR, XLSCSI_MAJOR_NAME, 
   22.57 -                             &xlscsi_block_fops);
   22.58 -    if ( result < 0 )
   22.59 -    {
   22.60 -	printk (KERN_ALERT "XL SCSI: can't get major %d\n", XLSCSI_MAJOR);
   22.61 -	return result;
   22.62 -    }
   22.63 -
   22.64 -    /* Initialize global arrays. */
   22.65 -    for ( i = 0; i < XLSCSI_MAX; i++ )
   22.66 -    {
   22.67 -	xlscsi_blksize_size[i]  = 1024; //XXX 512;
   22.68 -	xlscsi_hardsect_size[i] = 512;
   22.69 -	xlscsi_max_sectors[i]   = 128*8; //XXX 128
   22.70 -    }
   22.71 -
   22.72 -    blk_size[XLSCSI_MAJOR]      = NULL;
   22.73 -    blksize_size[XLSCSI_MAJOR]  = xlscsi_blksize_size;
   22.74 -    hardsect_size[XLSCSI_MAJOR] = xlscsi_hardsect_size;
   22.75 -    max_sectors[XLSCSI_MAJOR]   = xlscsi_max_sectors;
   22.76 -    read_ahead[XLSCSI_MAJOR]    = 0; //XXX8;
   22.77 -
   22.78 -    blk_init_queue(BLK_DEFAULT_QUEUE(XLSCSI_MAJOR), do_xlblk_request);
   22.79 -
   22.80 -    /*
   22.81 -     * Turn off barking 'headactive' mode. We dequeue buffer heads as
   22.82 -     * soon as we pass them down to Xen.
   22.83 -     */
   22.84 -    blk_queue_headactive(BLK_DEFAULT_QUEUE(XLSCSI_MAJOR), 0);
   22.85 -
   22.86 -    units = XLSCSI_MAX >> XLSCSI_PARTN_SHIFT;
   22.87 -
   22.88 -    /* Construct an appropriate gendisk structure. */
   22.89 -    minors    = units * (1<<XLSCSI_PARTN_SHIFT);
   22.90 -    gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
   22.91 -    gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
   22.92 -    gd->part  = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
   22.93 -    gd->major        = XLSCSI_MAJOR;
   22.94 -    gd->major_name   = XLSCSI_MAJOR_NAME;
   22.95 -    gd->minor_shift  = XLSCSI_PARTN_SHIFT; 
   22.96 -    gd->max_p	     = 1<<XLSCSI_PARTN_SHIFT;
   22.97 -    gd->nr_real	     = units;           
   22.98 -    gd->real_devices = kmalloc(units * sizeof(xl_disk_t), GFP_KERNEL);
   22.99 -    gd->next	     = NULL;            
  22.100 -    gd->fops         = &xlscsi_block_fops;
  22.101 -    gd->de_arr       = kmalloc(sizeof(*gd->de_arr) * units, GFP_KERNEL);
  22.102 -    gd->flags	     = kmalloc(sizeof(*gd->flags) * units, GFP_KERNEL);
  22.103 -    memset(gd->sizes, 0, minors * sizeof(int));
  22.104 -    memset(gd->part,  0, minors * sizeof(struct hd_struct));
  22.105 -    memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
  22.106 -    memset(gd->flags, 0, sizeof(*gd->flags) * units);
  22.107 -    memset(gd->real_devices, 0, sizeof(xl_disk_t) * units);
  22.108 -    xlscsi_gendisk = gd;
  22.109 -    add_gendisk(gd);
  22.110 -
  22.111 -    /* Now register each disk in turn. */
  22.112 -    for ( i = 0; i < xdi->count; i++ )
  22.113 -    {
  22.114 -        disk = xdi->disks[i].device & XENDEV_IDX_MASK;
  22.115 -
  22.116 -        if ( !IS_SCSI_XENDEV(xdi->disks[i].device) || 
  22.117 -             (disk >= XLSCSI_DEVS_PER_MAJOR) )
  22.118 -            continue;
  22.119 -
  22.120 -        ((xl_disk_t *)gd->real_devices)[disk].capacity =
  22.121 -            xdi->disks[i].capacity;
  22.122 -        register_disk(gd,
  22.123 -                      MKDEV(XLSCSI_MAJOR, disk<<XLSCSI_PARTN_SHIFT), 
  22.124 -                      1<<XLSCSI_PARTN_SHIFT, 
  22.125 -                      &xlscsi_block_fops, 
  22.126 -                      xdi->disks[i].capacity);
  22.127 -    }
  22.128 -   
  22.129 -    printk(KERN_ALERT 
  22.130 -	   "XenoLinux Virtual SCSI Device Driver installed [device: %d]\n",
  22.131 -	   XLSCSI_MAJOR);
  22.132 -
  22.133 -    return 0;
  22.134 -}
  22.135 -
  22.136 -
  22.137 -void xlscsi_cleanup(void)
  22.138 -{
  22.139 -    if ( xlscsi_gendisk == NULL ) return;
  22.140 -
  22.141 -    blk_cleanup_queue(BLK_DEFAULT_QUEUE(XLSCSI_MAJOR));
  22.142 -
  22.143 -    xlscsi_gendisk = NULL;
  22.144 -
  22.145 -    read_ahead[XLSCSI_MAJOR] = 0;
  22.146 -
  22.147 -    if ( blksize_size[XLSCSI_MAJOR] != NULL )
  22.148 -    { 
  22.149 -	kfree(blksize_size[XLSCSI_MAJOR]);
  22.150 -        blksize_size[XLSCSI_MAJOR] = NULL;
  22.151 -    }
  22.152 -
  22.153 -    if ( hardsect_size[XLSCSI_MAJOR] != NULL )
  22.154 -    { 
  22.155 -	kfree(hardsect_size[XLSCSI_MAJOR]);
  22.156 -        hardsect_size[XLSCSI_MAJOR] = NULL;
  22.157 -    }
  22.158 -    
  22.159 -    if ( max_sectors[XLSCSI_MAJOR] != NULL )
  22.160 -    { 
  22.161 -	kfree(max_sectors[XLSCSI_MAJOR]);
  22.162 -        max_sectors[XLSCSI_MAJOR] = NULL;
  22.163 -    }
  22.164 -    
  22.165 -    if ( unregister_blkdev(XLSCSI_MAJOR, XLSCSI_MAJOR_NAME) != 0 )
  22.166 -    {
  22.167 -	printk(KERN_ALERT
  22.168 -	       "XenoLinux Virtual SCSI Device Driver uninstalled w/ errs\n");
  22.169 -    }
  22.170 -}
  22.171 -
    23.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c	Wed Nov 05 11:50:12 2003 +0000
    23.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c	Wed Nov 05 11:57:30 2003 +0000
    23.3 @@ -7,19 +7,52 @@
    23.4  
    23.5  #include "xl_block.h"
    23.6  
    23.7 -#define MAJOR_NR XLVIRT_MAJOR
    23.8 +// #define MAJOR_NR XLVIRT_MAJOR
    23.9  #include <linux/blk.h>
   23.10  
   23.11  /* Copied from linux/ide.h */
   23.12  typedef unsigned char byte; 
   23.13  
   23.14 -#define XLVIRT_MAX        256
   23.15 -#define XLVIRT_MAJOR_NAME "xvd"
   23.16 -static int xlvbd_blksize_size[XLVIRT_MAX];
   23.17 -static int xlvbd_hardsect_size[XLVIRT_MAX];
   23.18 -static int xlvbd_max_sectors[XLVIRT_MAX];
   23.19 +#define XLVBD_MAX_MAJORS  64  /* total number of vbds we support */
   23.20  
   23.21 -struct gendisk *xlvbd_gendisk = NULL;
   23.22 +struct gendisk *xlvbd_gendisk[XLVBD_MAX_MAJORS] = { NULL };
   23.23 +
   23.24 +/* For convenience we distinguish between ide, scsi and 'other' (i.e. 
   23.25 +** potentially combinations of the two) in the naming scheme and in a 
   23.26 +** few other places (like default readahead, etc). 
   23.27 +*/
   23.28 +#define XLIDE_MAJOR_NAME  "hd"
   23.29 +#define XLSCSI_MAJOR_NAME "sd"
   23.30 +#define XLVBD_MAJOR_NAME "xvd"
   23.31 +
   23.32 +#define XLIDE_DEVS_PER_MAJOR   2
   23.33 +#define XLSCSI_DEVS_PER_MAJOR 16
   23.34 +#define XLVBD_DEVS_PER_MAJOR  16
   23.35 +
   23.36 +
   23.37 +#define XLIDE_PARTN_SHIFT  6    /* amount to shift minor to get 'real' minor */
   23.38 +#define XLIDE_MAX_MINORS  (1 << XLIDE_PARTN_SHIFT)     /* minors per ide vbd */
   23.39 +
   23.40 +#define XLSCSI_PARTN_SHIFT 6    /* amount to shift minor to get 'real' minor */
   23.41 +#define XLSCSI_MAX_MINORS (1 << XLSCSI_PARTN_SHIFT)   /* minors per scsi vbd */
   23.42 +
   23.43 +#define XLVBD_PARTN_SHIFT  6    /* amount to shift minor to get 'real' minor */
   23.44 +#define XLVBD_MAX_MINORS  (1 << XLVBD_PARTN_SHIFT) /* minors per 'other' vbd */
   23.45 +
   23.46 +
   23.47 +/* the below are for the use of the generic drivers/block/ll_rw_block.c code */
   23.48 +static int xlide_blksize_size[XLIDE_MAX_MINORS];
   23.49 +static int xlide_hardsect_size[XLIDE_MAX_MINORS];
   23.50 +static int xlide_max_sectors[XLIDE_MAX_MINORS];
   23.51 +
   23.52 +static int xlscsi_blksize_size[XLSCSI_MAX_MINORS];
   23.53 +static int xlscsi_hardsect_size[XLSCSI_MAX_MINORS];
   23.54 +static int xlscsi_max_sectors[XLSCSI_MAX_MINORS];
   23.55 +
   23.56 +static int xlvbd_blksize_size[XLVBD_MAX_MINORS];
   23.57 +static int xlvbd_hardsect_size[XLVBD_MAX_MINORS];
   23.58 +static int xlvbd_max_sectors[XLVBD_MAX_MINORS];
   23.59 +
   23.60  
   23.61  static struct block_device_operations xlvbd_block_fops = 
   23.62  {
   23.63 @@ -31,104 +64,249 @@ static struct block_device_operations xl
   23.64  };
   23.65  
   23.66  
   23.67 -int xlvbd_hwsect(int minor) 
   23.68 -{
   23.69 -    return xlvbd_hardsect_size[minor]; 
   23.70 -} 
   23.71 +typedef unsigned char bool; 
   23.72  
   23.73 -
   23.74 +/* 
   23.75 +** Set up all the linux device goop for the virtual block devices (vbd's)
   23.76 +** that xen tells us about. Note that although from xen's pov VBDs are 
   23.77 +** addressed simply an opaque 16-bit device number, the domain creation 
   23.78 +** tools conventionally allocate these numbers to correspond to those 
   23.79 +** used by 'real' linux -- this is just for convenience as it means e.g. 
   23.80 +** that the same /etc/fstab can be used when booting with or without xen.
   23.81 +*/
   23.82  int __init xlvbd_init(xen_disk_info_t *xdi)
   23.83  {
   23.84 -    int i, result, units, minors, disk;
   23.85 +    int i, result, nminors; 
   23.86      struct gendisk *gd;
   23.87 +    kdev_t device; 
   23.88 +    unsigned short major, minor, real_minor; 
   23.89 +    bool is_ide, is_scsi; 
   23.90 +    char *major_name; 
   23.91 +    unsigned char buf[64]; 
   23.92 +    int majors[256]; 
   23.93  
   23.94      SET_MODULE_OWNER(&xlvbd_block_fops);
   23.95  
   23.96 -    result = register_blkdev(XLVIRT_MAJOR, XLVIRT_MAJOR_NAME,
   23.97 -                             &xlvbd_block_fops);
   23.98 -    if ( result < 0 )
   23.99 +    /* Initialize the global arrays. */
  23.100 +    for (i = 0; i < XLIDE_MAX_MINORS; i++) 
  23.101      {
  23.102 -	printk(KERN_ALERT "XL VBD: can't get major %d\n", XLVIRT_MAJOR);
  23.103 -	return result;
  23.104 +	/* from the generic ide code (drivers/ide/ide-probe.c, etc) */
  23.105 +	xlide_blksize_size[i]  = 1024;
  23.106 +	xlide_hardsect_size[i] = 512;
  23.107 +	xlide_max_sectors[i]   = 128;  /* 'hwif->rqsize' if we knew it */
  23.108      }
  23.109 -
  23.110 -    /* Initialize global arrays. */
  23.111 -    for (i = 0; i < XLVIRT_MAX; i++) 
  23.112 +    
  23.113 +    for (i = 0; i < XLSCSI_MAX_MINORS; i++) 
  23.114      {
  23.115 -        xlvbd_blksize_size[i]  = 512;
  23.116 -        xlvbd_hardsect_size[i] = 512;
  23.117 -        xlvbd_max_sectors[i]   = 128;
  23.118 +	/* from the generic scsi disk code (drivers/scsi/sd.c) */
  23.119 +	xlscsi_blksize_size[i]  = 1024; //XXX 512;
  23.120 +	xlscsi_hardsect_size[i] = 512;
  23.121 +	xlscsi_max_sectors[i]   = 128*8; //XXX 128;
  23.122 +    }
  23.123 +    
  23.124 +    for (i = 0; i < XLVBD_MAX_MINORS; i++) 
  23.125 +    {
  23.126 +	/* we don't really know what to set these too since it depends */
  23.127 +	xlvbd_blksize_size[i]  = 512;
  23.128 +	xlvbd_hardsect_size[i] = 512;
  23.129 +	xlvbd_max_sectors[i]   = 128;
  23.130      }
  23.131  
  23.132 -    blk_size[XLVIRT_MAJOR]      = NULL;
  23.133 -    blksize_size[XLVIRT_MAJOR]  = xlvbd_blksize_size;
  23.134 -    hardsect_size[XLVIRT_MAJOR] = xlvbd_hardsect_size;
  23.135 -    max_sectors[XLVIRT_MAJOR]   = xlvbd_max_sectors;
  23.136 -    read_ahead[XLVIRT_MAJOR]    = 8;
  23.137 -
  23.138 -    blk_init_queue(BLK_DEFAULT_QUEUE(XLVIRT_MAJOR), do_xlblk_request);
  23.139 -
  23.140 -    /*
  23.141 -     * Turn off barking 'headactive' mode. We dequeue buffer heads as
  23.142 -     * soon as we pass them down to Xen.
  23.143 -     */
  23.144 -    blk_queue_headactive(BLK_DEFAULT_QUEUE(XLVIRT_MAJOR), 0);
  23.145 -
  23.146 -    units = XLVIRT_MAX >> XLVIRT_PARTN_SHIFT;
  23.147 +    /* keep track of which majors we've seen so far */
  23.148 +    for (i = 0; i < 256; i++) 
  23.149 +	majors[i] = 0; 
  23.150  
  23.151 -    /* Construct an appropriate gendisk structure. */
  23.152 -    minors    = units * (1<<XLVIRT_PARTN_SHIFT);
  23.153 -    gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
  23.154 -    gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
  23.155 -    gd->part  = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
  23.156 -    gd->major        = XLVIRT_MAJOR;
  23.157 -    gd->major_name   = XLVIRT_MAJOR_NAME;
  23.158 -    gd->minor_shift  = XLVIRT_PARTN_SHIFT; 
  23.159 -    gd->max_p	     = 1<<XLVIRT_PARTN_SHIFT;
  23.160 -    gd->nr_real	     = units;           
  23.161 -    gd->real_devices = kmalloc(units * sizeof(xl_disk_t), GFP_KERNEL);
  23.162 -    gd->next	     = NULL;            
  23.163 -    gd->fops         = &xlvbd_block_fops;
  23.164 -    gd->de_arr       = kmalloc(sizeof(*gd->de_arr) * units, GFP_KERNEL);
  23.165 -    gd->flags	     = kmalloc(sizeof(*gd->flags) * units, GFP_KERNEL);
  23.166 -    memset(gd->sizes, 0, minors * sizeof(int));
  23.167 -    memset(gd->part,  0, minors * sizeof(struct hd_struct));
  23.168 -    memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
  23.169 -    memset(gd->flags, 0, sizeof(*gd->flags) * units);
  23.170 -    memset(gd->real_devices, 0, sizeof(xl_disk_t) * units);
  23.171 -    xlvbd_gendisk = gd;
  23.172 -    add_gendisk(gd);
  23.173 +    /* 
  23.174 +    ** We need to loop through each major device we've been told about and: 
  23.175 +    ** a) register the appropriate blkdev 
  23.176 +    ** b) setup the indexed-by-major global arrays (blk_size[], 
  23.177 +    **    blksize_size[], hardsect_size[], max_sectors[], read_ahead[]) 
  23.178 +    ** c) setup the block queue + make it sensible
  23.179 +    ** d) create an appropriate gendisk structure, and 
  23.180 +    ** e) register the gendisk 
  23.181 +    */
  23.182 +    for (i = 0; i < xdi->count; i++)
  23.183 +    {
  23.184 +	device = xdi->disks[i].device;
  23.185 +	major  = MAJOR(device); 
  23.186 +	minor  = MINOR(device);
  23.187 +	is_ide = IDE_DISK_MAJOR(major);  /* is this an ide device? */
  23.188 +	is_scsi= SCSI_BLK_MAJOR(major);  /* is this a scsi device? */
  23.189 +	
  23.190 +	if(is_ide) { 
  23.191 +	    major_name = XLIDE_MAJOR_NAME; 
  23.192 +	    nminors    = XLIDE_MAX_MINORS; 
  23.193 +	} else if(is_scsi) { 
  23.194 +	    major_name = XLSCSI_MAJOR_NAME;
  23.195 +	    nminors    = XLSCSI_MAX_MINORS; 
  23.196 +	} else { 
  23.197 +	    major_name = XLVBD_MAJOR_NAME;
  23.198 +	    nminors    = XLVBD_MAX_MINORS; 
  23.199 +	}
  23.200  
  23.201 -    /* Now register each disk in turn. */
  23.202 -    for ( i = 0; i < xdi->count; i++ )
  23.203 -    {
  23.204 -        disk = xdi->disks[i].device & XENDEV_IDX_MASK;
  23.205 -
  23.206 -        if ( !IS_VIRTUAL_XENDEV(xdi->disks[i].device) || 
  23.207 -             (disk >= XLVIRT_DEVS_PER_MAJOR) )
  23.208 -            continue;
  23.209 +	/* 
  23.210 +	** XXX SMH: conventionally we assume a minor device if the 
  23.211 +	** corresponding linux device number would be a minor device; 
  23.212 +	** minor devices require slightly different handling than 
  23.213 +	** 'full' devices (e.g. in terms of partition table handling). 
  23.214 +	*/
  23.215 +	real_minor = minor & (nminors - 1); 
  23.216  
  23.217 -        ((xl_disk_t *)gd->real_devices)[disk].capacity =
  23.218 -            xdi->disks[i].capacity;
  23.219 -        register_disk(gd, 
  23.220 -                      MKDEV(XLVIRT_MAJOR, disk<<XLVIRT_PARTN_SHIFT), 
  23.221 -                      1<<XLVIRT_PARTN_SHIFT, 
  23.222 -                      &xlvbd_block_fops, 
  23.223 -                      xdi->disks[i].capacity);
  23.224 +	if(!majors[major]) {
  23.225 +
  23.226 +	    result = register_blkdev(major, major_name, &xlvbd_block_fops);
  23.227 +	    if (result < 0) {
  23.228 +		printk(KERN_ALERT "XL VBD: can't get major %d\n", major);
  23.229 +		continue; 
  23.230 +	    }
  23.231 +
  23.232 +	    blk_size[major]      = NULL;
  23.233 +	    if(is_ide) { 
  23.234 +		blksize_size[major]  = xlide_blksize_size;
  23.235 +		hardsect_size[major] = xlide_hardsect_size;
  23.236 +		max_sectors[major]   = xlide_max_sectors;
  23.237 +		read_ahead[major]    = 8; // from drivers/ide/ide-probe.c
  23.238 +	    } else if(is_scsi) { 
  23.239 +		blksize_size[major]  = xlscsi_blksize_size;
  23.240 +		hardsect_size[major] = xlscsi_hardsect_size;
  23.241 +		max_sectors[major]   = xlscsi_max_sectors;
  23.242 +		read_ahead[major]    = 0; // XXX 8; -- guessing 
  23.243 +	    } else { 
  23.244 +		blksize_size[major]  = xlvbd_blksize_size;
  23.245 +		hardsect_size[major] = xlvbd_hardsect_size;
  23.246 +		max_sectors[major]   = xlvbd_max_sectors;
  23.247 +		read_ahead[major]    = 8;
  23.248 +	    }
  23.249 +	
  23.250 +	    blk_init_queue(BLK_DEFAULT_QUEUE(major), do_xlblk_request);
  23.251 +	
  23.252 +	    /*
  23.253 +	     * Turn off barking 'headactive' mode. We dequeue buffer heads as
  23.254 +	     * soon as we pass them down to Xen.
  23.255 +	     */
  23.256 +	    blk_queue_headactive(BLK_DEFAULT_QUEUE(major), 0);
  23.257 +
  23.258 +	    /* Construct an appropriate gendisk structure. */
  23.259 +	    gd             = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
  23.260 +	    gd->sizes      = kmalloc(nminors*sizeof(int), GFP_KERNEL);
  23.261 +	    gd->part       = kmalloc(nminors*sizeof(struct hd_struct), 
  23.262 +				     GFP_KERNEL);
  23.263 +	    gd->major      = major;
  23.264 +	    gd->major_name = major_name; 
  23.265 +	    
  23.266 +	    gd->max_p      = nminors; 
  23.267 +	    if(is_ide) { 
  23.268 +		gd->minor_shift  = XLIDE_PARTN_SHIFT; 
  23.269 +		gd->nr_real      = XLIDE_DEVS_PER_MAJOR; 
  23.270 +	    } else if(is_scsi) { 
  23.271 +		gd->minor_shift  = XLSCSI_PARTN_SHIFT; 
  23.272 +		gd->nr_real      = XLSCSI_DEVS_PER_MAJOR; 
  23.273 +	    } else { 
  23.274 +		gd->minor_shift  = XLVBD_PARTN_SHIFT; 
  23.275 +		gd->nr_real      = XLVBD_DEVS_PER_MAJOR; 
  23.276 +	    }
  23.277 +	    gd->real_devices = kmalloc(gd->nr_real * sizeof(xl_disk_t), 
  23.278 +				       GFP_KERNEL);
  23.279 +	    gd->next   = NULL;            
  23.280 +	    gd->fops   = &xlvbd_block_fops;
  23.281 +	    gd->de_arr = kmalloc(gd->nr_real * sizeof(*gd->de_arr), 
  23.282 +				 GFP_KERNEL);
  23.283 +	    gd->flags  = kmalloc(gd->nr_real * sizeof(*gd->flags), GFP_KERNEL);
  23.284 +	    
  23.285 +	    memset(gd->sizes, 0, nminors * sizeof(int));
  23.286 +	    memset(gd->part,  0, nminors * sizeof(struct hd_struct));
  23.287 +	    memset(gd->de_arr, 0, gd->nr_real * sizeof(*gd->de_arr));
  23.288 +	    memset(gd->flags, 0, gd->nr_real *  sizeof(*gd->flags));
  23.289 +	    memset(gd->real_devices, 0, gd->nr_real * sizeof(xl_disk_t));
  23.290 +
  23.291 +	    /* 
  23.292 +	    ** Keep track of gendisk both locally and in the global array. 
  23.293 +	    ** XXX SMH: can probably do without local copy -- FIXME later 
  23.294 +	    */
  23.295 +	    xlvbd_gendisk[i] = gd;
  23.296 +	    add_gendisk(gd);
  23.297 +
  23.298 +	    /* XXX SMH: not clear on what 'real_devices' is indexed by; 
  23.299 +	       hence using unit number for now but in old code was 'disk' aka 
  23.300 +	       sequence number assigned by xen during probe = barfle? */
  23.301 +	    ((xl_disk_t *)gd->real_devices)[minor>>gd->minor_shift].capacity =
  23.302 +	    xdi->disks[i].capacity;
  23.303 +
  23.304 +	    
  23.305 +	    /* remember that we've done this major */
  23.306 +	    majors[major] = 1; 
  23.307 +	}
  23.308 +
  23.309 +	if(real_minor) { 
  23.310 +
  23.311 +	    /* Need to skankily setup 'partition' information */
  23.312 +	    gd->part[real_minor].start_sect = 0; 
  23.313 +	    gd->part[real_minor].nr_sects   = xdi->disks[i].capacity; 
  23.314 +	    gd->sizes[real_minor]           = xdi->disks[i].capacity; 
  23.315 +
  23.316 +	} else { 
  23.317 +	
  23.318 +	    /* Some final fix-ups depending on the device type */
  23.319 +	    switch (xdi->disks[i].type) 
  23.320 +	    { 
  23.321 +	    case XD_TYPE_CDROM:
  23.322 +		set_device_ro(device, 1); 
  23.323 +		
  23.324 +	    case XD_TYPE_FLOPPY: 
  23.325 +	    case XD_TYPE_TAPE:
  23.326 +		gd->flags[0] = GENHD_FL_REMOVABLE; 
  23.327 +		printk(KERN_ALERT 
  23.328 +		       "Skipping partition check on %s /dev/%s\n", 
  23.329 +		       xdi->disks[i].type==XD_TYPE_CDROM ? "cdrom" : 
  23.330 +		       (xdi->disks[i].type==XD_TYPE_TAPE ? "tape" : 
  23.331 +			"floppy"), disk_name(gd, MINOR(device), buf)); 
  23.332 +		break; 
  23.333 +	    
  23.334 +	    case XD_TYPE_DISK: 
  23.335 +		register_disk(gd, device, gd->nr_real, &xlvbd_block_fops, 
  23.336 +			      xdi->disks[i].capacity);
  23.337 +		break; 
  23.338 +		
  23.339 +	    default: 
  23.340 +		printk(KERN_ALERT "XenoLinux: unknown ide device type %d\n", 
  23.341 +		       xdi->disks[i].type); 
  23.342 +		break; 
  23.343 +	    }
  23.344 +
  23.345 +	}
  23.346 +	    
  23.347 +	printk(KERN_ALERT "XenoLinux Virtual Block Device Driver "
  23.348 +	       "installed [device: %04x]\n", device);
  23.349      }
  23.350  
  23.351 -    printk(KERN_ALERT 
  23.352 -	   "XenoLinux Virtual Block Device Driver installed [device: %d]\n",
  23.353 -	   XLVIRT_MAJOR);
  23.354 -
  23.355      return 0;
  23.356  }
  23.357  
  23.358 +/* 
  23.359 +** XXX SMH: crappy linear scan routine to map from a device number bac k
  23.360 +** to the relevant gendisk; could be made better if and when it becomes 
  23.361 +** an issue but for now we expect success within a few loop iterations. 
  23.362 +*/
  23.363 +struct gendisk *xldev_to_gendisk(kdev_t xldev)
  23.364 +{
  23.365 +    int i; 
  23.366 +    short major = MAJOR(xldev); 
  23.367 +    
  23.368 +    for(i = 0; i < XLVBD_MAX_MAJORS; i++) { 
  23.369 +	if(xlvbd_gendisk[i]->major == major)
  23.370 +	    return xlvbd_gendisk[i]; 
  23.371 +    }
  23.372 +    
  23.373 +    /* didn't find it -- death */
  23.374 +    BUG();
  23.375 +    return NULL; 
  23.376 +}
  23.377  
  23.378  void xlvbd_cleanup(void)
  23.379  {
  23.380 +#if 0
  23.381      if ( xlvbd_gendisk == NULL ) return;
  23.382 -
  23.383 +    
  23.384      blk_cleanup_queue(BLK_DEFAULT_QUEUE(XLVIRT_MAJOR));
  23.385  
  23.386      xlvbd_gendisk = NULL;
  23.387 @@ -159,6 +337,8 @@ void xlvbd_cleanup(void)
  23.388  	       "XenoLinux Virtual Block Device Driver"
  23.389                 " uninstalled w/ errs\n");
  23.390      }
  23.391 +#endif
  23.392 +    printk(KERN_ALERT "xlvbd_cleanup: not implemented XXX FIXME SMH\n"); 
  23.393  }
  23.394  
  23.395  
    24.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/dom0/dom0_core.c	Wed Nov 05 11:50:12 2003 +0000
    24.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/dom0/dom0_core.c	Wed Nov 05 11:57:30 2003 +0000
    24.3 @@ -61,6 +61,7 @@ static int privcmd_ioctl(struct inode *i
    24.4              TRAP_INSTR "; "
    24.5              "popl %%edi; popl %%esi; popl %%edx; popl %%ecx; popl %%ebx"
    24.6              : "=a" (ret) : "0" (&hypercall) : "memory" );
    24.7 +
    24.8      }
    24.9      break;
   24.10  
   24.11 @@ -99,25 +100,10 @@ static int privcmd_ioctl(struct inode *i
   24.12      }
   24.13      break;
   24.14      
   24.15 -    case IOCTL_PRIVCMD_LINDEV_TO_XENDEV:
   24.16 -    {
   24.17 -        ret = (int)xldev_to_physdev((kdev_t)data);
   24.18 -    }
   24.19 -    break;
   24.20 -
   24.21 -    case IOCTL_PRIVCMD_XENDEV_TO_LINDEV:
   24.22 -    {
   24.23 -        ret = (int)physdev_to_xldev((unsigned short)data);
   24.24 -    }
   24.25 -    break;
   24.26 -
   24.27      default:
   24.28 -    {
   24.29          ret = -EINVAL;
   24.30 -    }
   24.31 -    break;
   24.32 -    }
   24.33 -
   24.34 +    	break;
   24.35 +	}
   24.36      return ret;
   24.37  }
   24.38  
    25.1 --- a/xenolinux-2.4.22-sparse/fs/partitions/Config.in	Wed Nov 05 11:50:12 2003 +0000
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,72 +0,0 @@
    25.4 -#
    25.5 -# Partition configuration
    25.6 -#
    25.7 -bool 'Advanced partition selection' CONFIG_PARTITION_ADVANCED
    25.8 -if [ "$CONFIG_PARTITION_ADVANCED" = "y" ]; then
    25.9 -   bool '  Acorn partition support' CONFIG_ACORN_PARTITION
   25.10 -   if [ "$CONFIG_ACORN_PARTITION" != "n" ]; then
   25.11 -#      bool '    Cumana partition support' CONFIG_ACORN_PARTITION_CUMANA
   25.12 -      bool '    ICS partition support' CONFIG_ACORN_PARTITION_ICS
   25.13 -      bool '    Native filecore partition support' CONFIG_ACORN_PARTITION_ADFS
   25.14 -      bool '    PowerTec partition support' CONFIG_ACORN_PARTITION_POWERTEC
   25.15 -      bool '    RISCiX partition support' CONFIG_ACORN_PARTITION_RISCIX
   25.16 -   fi
   25.17 -   bool '  Alpha OSF partition support' CONFIG_OSF_PARTITION
   25.18 -   bool '  Amiga partition table support' CONFIG_AMIGA_PARTITION
   25.19 -   bool '  Atari partition table support' CONFIG_ATARI_PARTITION
   25.20 -   if [ "$CONFIG_ARCH_S390" = "y" ]; then
   25.21 -      bool '  IBM disk label and partition support' CONFIG_IBM_PARTITION
   25.22 -   fi
   25.23 -   bool '  Macintosh partition map support' CONFIG_MAC_PARTITION
   25.24 -   bool '  Xeno partition support' CONFIG_XENO_PARTITION
   25.25 -   bool '  PC BIOS (MSDOS partition tables) support' CONFIG_MSDOS_PARTITION
   25.26 -   if [ "$CONFIG_MSDOS_PARTITION" = "y" ]; then
   25.27 -      bool '    BSD disklabel (FreeBSD partition tables) support' CONFIG_BSD_DISKLABEL
   25.28 -      bool '    Minix subpartition support' CONFIG_MINIX_SUBPARTITION
   25.29 -      bool '    Solaris (x86) partition table support' CONFIG_SOLARIS_X86_PARTITION
   25.30 -      bool '    Unixware slices support' CONFIG_UNIXWARE_DISKLABEL
   25.31 -   fi
   25.32 -   dep_bool '  Windows Logical Disk Manager (Dynamic Disk) support (EXPERIMENTAL)' CONFIG_LDM_PARTITION $CONFIG_EXPERIMENTAL
   25.33 -   if [ "$CONFIG_LDM_PARTITION" = "y" ]; then
   25.34 -      bool '    Windows LDM extra logging' CONFIG_LDM_DEBUG
   25.35 -   fi
   25.36 -   bool '  SGI partition support' CONFIG_SGI_PARTITION
   25.37 -   bool '  Ultrix partition table support' CONFIG_ULTRIX_PARTITION
   25.38 -   bool '  Sun partition tables support' CONFIG_SUN_PARTITION
   25.39 -   bool '  EFI GUID Partition support' CONFIG_EFI_PARTITION
   25.40 -else
   25.41 -   if [ "$CONFIG_ALPHA" = "y" ]; then
   25.42 -      define_bool CONFIG_OSF_PARTITION y
   25.43 -   fi
   25.44 -   if [ "$CONFIG_AMIGA" != "y" -a "$CONFIG_ATARI" != "y" -a \
   25.45 -        "$CONFIG_MAC" != "y" -a "$CONFIG_SGI_IP22" != "y" -a \
   25.46 -	"$CONFIG_SGI_IP27" != "y" ]; then
   25.47 -      define_bool CONFIG_MSDOS_PARTITION y
   25.48 -   fi
   25.49 -   if [ "$CONFIG_AMIGA" = "y" -o "$CONFIG_AFFS_FS" = "y" ]; then
   25.50 -      define_bool CONFIG_AMIGA_PARTITION y
   25.51 -   fi
   25.52 -   if [ "$CONFIG_MAC" = "y" ]; then
   25.53 -      define_bool CONFIG_MAC_PARTITION y
   25.54 -   fi
   25.55 -   if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
   25.56 -      define_bool CONFIG_ACORN_PARTITION y
   25.57 -      define_bool CONFIG_ACORN_PARTITION_ADFS y
   25.58 -#      define_bool CONFIG_ACORN_PARTITION_CUMANA y
   25.59 -      define_bool CONFIG_ACORN_PARTITION_ICS y
   25.60 -      define_bool CONFIG_ACORN_PARTITION_POWERTEC y
   25.61 -      define_bool CONFIG_ACORN_PARTITION_RISCIX y
   25.62 -   fi
   25.63 -   if [ "$CONFIG_ATARI" = "y" ]; then
   25.64 -      define_bool CONFIG_ATARI_PARTITION y
   25.65 -   fi
   25.66 -   if [ "$CONFIG_SGI_IP22" = "y" -o "$CONFIG_SGI_IP27" = "y" ]; then
   25.67 -      define_bool CONFIG_SGI_PARTITION y
   25.68 -   fi
   25.69 -   if [ "$CONFIG_DECSTATION" = "y" ]; then
   25.70 -      define_bool CONFIG_ULTRIX_PARTITION y
   25.71 -   fi
   25.72 -   if [ "$CONFIG_SPARC32" = "y" -o "$CONFIG_SPARC64" = "y" ]; then
   25.73 -      define_bool CONFIG_SUN_PARTITION y
   25.74 -   fi
   25.75 -fi
    26.1 --- a/xenolinux-2.4.22-sparse/fs/partitions/Makefile	Wed Nov 05 11:50:12 2003 +0000
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,30 +0,0 @@
    26.4 -#
    26.5 -# Makefile for the linux kernel.
    26.6 -#
    26.7 -# Note! Dependencies are done automagically by 'make dep', which also
    26.8 -# removes any old dependencies. DON'T put your own dependencies here
    26.9 -# unless it's something special (ie not a .c file).
   26.10 -#
   26.11 -# Note 2! The CFLAGS definitions are now in the main makefile...
   26.12 -
   26.13 -O_TARGET := partitions.o
   26.14 -
   26.15 -export-objs := check.o msdos.o
   26.16 -
   26.17 -obj-y := check.o
   26.18 -
   26.19 -obj-$(CONFIG_ACORN_PARTITION) += acorn.o
   26.20 -obj-$(CONFIG_XENO_PARTITION) += xeno.o
   26.21 -obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
   26.22 -obj-$(CONFIG_ATARI_PARTITION) += atari.o
   26.23 -obj-$(CONFIG_MAC_PARTITION) += mac.o
   26.24 -obj-$(CONFIG_LDM_PARTITION) += ldm.o
   26.25 -obj-$(CONFIG_MSDOS_PARTITION) += msdos.o
   26.26 -obj-$(CONFIG_OSF_PARTITION) += osf.o
   26.27 -obj-$(CONFIG_SGI_PARTITION) += sgi.o
   26.28 -obj-$(CONFIG_SUN_PARTITION) += sun.o
   26.29 -obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o
   26.30 -obj-$(CONFIG_IBM_PARTITION) += ibm.o
   26.31 -obj-$(CONFIG_EFI_PARTITION) += efi.o
   26.32 -
   26.33 -include $(TOPDIR)/Rules.make
    27.1 --- a/xenolinux-2.4.22-sparse/fs/partitions/check.c	Wed Nov 05 11:50:12 2003 +0000
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,443 +0,0 @@
    27.4 -/*
    27.5 - *  Code extracted from drivers/block/genhd.c
    27.6 - *  Copyright (C) 1991-1998  Linus Torvalds
    27.7 - *  Re-organised Feb 1998 Russell King
    27.8 - *
    27.9 - *  We now have independent partition support from the
   27.10 - *  block drivers, which allows all the partition code to
   27.11 - *  be grouped in one location, and it to be mostly self
   27.12 - *  contained.
   27.13 - *
   27.14 - *  Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl}
   27.15 - */
   27.16 -
   27.17 -#include <linux/config.h>
   27.18 -#include <linux/fs.h>
   27.19 -#include <linux/genhd.h>
   27.20 -#include <linux/kernel.h>
   27.21 -#include <linux/major.h>
   27.22 -#include <linux/blk.h>
   27.23 -#include <linux/init.h>
   27.24 -#include <linux/raid/md.h>
   27.25 -
   27.26 -#include "check.h"
   27.27 -
   27.28 -#include "acorn.h"
   27.29 -#include "amiga.h"
   27.30 -#include "atari.h"
   27.31 -#include "ldm.h"
   27.32 -#include "mac.h"
   27.33 -#include "msdos.h"
   27.34 -#include "osf.h"
   27.35 -#include "sgi.h"
   27.36 -#include "sun.h"
   27.37 -#include "ibm.h"
   27.38 -#include "ultrix.h"
   27.39 -#include "efi.h"
   27.40 -#include "xeno.h"
   27.41 -
   27.42 -extern int *blk_size[];
   27.43 -
   27.44 -int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
   27.45 -
   27.46 -static int (*check_part[])(struct gendisk *hd, struct block_device *bdev, unsigned long first_sect, int first_minor) = {
   27.47 -#ifdef CONFIG_XENO_PARTITION
   27.48 -        xeno_partition,         /* this must come first */
   27.49 -#endif
   27.50 -#ifdef CONFIG_ACORN_PARTITION
   27.51 -	acorn_partition,
   27.52 -#endif
   27.53 -#ifdef CONFIG_EFI_PARTITION
   27.54 -	efi_partition,		/* this must come before msdos */
   27.55 -#endif
   27.56 -#ifdef CONFIG_LDM_PARTITION
   27.57 -	ldm_partition,		/* this must come before msdos */
   27.58 -#endif
   27.59 -#ifdef CONFIG_MSDOS_PARTITION
   27.60 -	msdos_partition,
   27.61 -#endif
   27.62 -#ifdef CONFIG_OSF_PARTITION
   27.63 -	osf_partition,
   27.64 -#endif
   27.65 -#ifdef CONFIG_SUN_PARTITION
   27.66 -	sun_partition,
   27.67 -#endif
   27.68 -#ifdef CONFIG_AMIGA_PARTITION
   27.69 -	amiga_partition,
   27.70 -#endif
   27.71 -#ifdef CONFIG_ATARI_PARTITION
   27.72 -	atari_partition,
   27.73 -#endif
   27.74 -#ifdef CONFIG_MAC_PARTITION
   27.75 -	mac_partition,
   27.76 -#endif
   27.77 -#ifdef CONFIG_SGI_PARTITION
   27.78 -	sgi_partition,
   27.79 -#endif
   27.80 -#ifdef CONFIG_ULTRIX_PARTITION
   27.81 -	ultrix_partition,
   27.82 -#endif
   27.83 -#ifdef CONFIG_IBM_PARTITION
   27.84 -	ibm_partition,
   27.85 -#endif
   27.86 -	NULL
   27.87 -};
   27.88 -
   27.89 -/*
   27.90 - *	This is ucking fugly but its probably the best thing for 2.4.x
   27.91 - *	Take it as a clear reminder that: 1) we should put the device name
   27.92 - *	generation in the object kdev_t points to in 2.5.
   27.93 - *	and 2) ioctls better work on half-opened devices.
   27.94 - */
   27.95 - 
   27.96 -#ifdef CONFIG_ARCH_S390
   27.97 -int (*genhd_dasd_name)(char*,int,int,struct gendisk*) = NULL;
   27.98 -int (*genhd_dasd_ioctl)(struct inode *inp, struct file *filp,
   27.99 -			    unsigned int no, unsigned long data);
  27.100 -EXPORT_SYMBOL(genhd_dasd_name);
  27.101 -EXPORT_SYMBOL(genhd_dasd_ioctl);
  27.102 -#endif
  27.103 -
  27.104 -/*
  27.105 - * disk_name() is used by partition check code and the md driver.
  27.106 - * It formats the devicename of the indicated disk into
  27.107 - * the supplied buffer (of size at least 32), and returns
  27.108 - * a pointer to that same buffer (for convenience).
  27.109 - */
  27.110 -
  27.111 -char *disk_name (struct gendisk *hd, int minor, char *buf)
  27.112 -{
  27.113 -	const char *maj = hd->major_name;
  27.114 -	unsigned int unit = (minor >> hd->minor_shift);
  27.115 -	unsigned int part = (minor & ((1 << hd->minor_shift) -1 ));
  27.116 -
  27.117 -	if ((unit < hd->nr_real) && hd->part[minor].de) {
  27.118 -		int pos;
  27.119 -
  27.120 -		pos = devfs_generate_path (hd->part[minor].de, buf, 64);
  27.121 -		if (pos >= 0)
  27.122 -			return buf + pos;
  27.123 -	}
  27.124 -
  27.125 -#ifdef CONFIG_ARCH_S390
  27.126 -	if (genhd_dasd_name
  27.127 -	    && genhd_dasd_name (buf, unit, part, hd) == 0)
  27.128 -		return buf;
  27.129 -#endif
  27.130 -	/*
  27.131 -	 * IDE devices use multiple major numbers, but the drives
  27.132 -	 * are named as:  {hda,hdb}, {hdc,hdd}, {hde,hdf}, {hdg,hdh}..
  27.133 -	 * This requires special handling here.
  27.134 -	 */
  27.135 -	switch (hd->major) {
  27.136 -		case IDE9_MAJOR:
  27.137 -			unit += 2;
  27.138 -		case IDE8_MAJOR:
  27.139 -			unit += 2;
  27.140 -		case IDE7_MAJOR:
  27.141 -			unit += 2;
  27.142 -		case IDE6_MAJOR:
  27.143 -			unit += 2;
  27.144 -		case IDE5_MAJOR:
  27.145 -			unit += 2;
  27.146 -		case IDE4_MAJOR:
  27.147 -			unit += 2;
  27.148 -		case IDE3_MAJOR:
  27.149 -			unit += 2;
  27.150 -		case IDE2_MAJOR:
  27.151 -			unit += 2;
  27.152 -		case IDE1_MAJOR:
  27.153 -			unit += 2;
  27.154 -		case IDE0_MAJOR:
  27.155 -			maj = "hd";
  27.156 -			break;
  27.157 -		case MD_MAJOR:
  27.158 -			sprintf(buf, "%s%d", maj, unit);
  27.159 -			return buf;
  27.160 -	}
  27.161 -	if (hd->major >= SCSI_DISK1_MAJOR && hd->major <= SCSI_DISK7_MAJOR) {
  27.162 -		unit = unit + (hd->major - SCSI_DISK1_MAJOR + 1) * 16;
  27.163 -		if (unit+'a' > 'z') {
  27.164 -			unit -= 26;
  27.165 -			sprintf(buf, "sd%c%c", 'a' + unit / 26, 'a' + unit % 26);
  27.166 -			if (part)
  27.167 -				sprintf(buf + 4, "%d", part);
  27.168 -			return buf;
  27.169 -		}
  27.170 -	}
  27.171 -	if (hd->major >= COMPAQ_SMART2_MAJOR && hd->major <= COMPAQ_SMART2_MAJOR+7) {
  27.172 -		int ctlr = hd->major - COMPAQ_SMART2_MAJOR;
  27.173 - 		if (part == 0)
  27.174 - 			sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
  27.175 - 		else
  27.176 - 			sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
  27.177 - 		return buf;
  27.178 - 	}
  27.179 -	if (hd->major >= COMPAQ_CISS_MAJOR && hd->major <= COMPAQ_CISS_MAJOR+7) {
  27.180 -                int ctlr = hd->major - COMPAQ_CISS_MAJOR;
  27.181 -                if (part == 0)
  27.182 -                        sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
  27.183 -                else
  27.184 -                        sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
  27.185 -                return buf;
  27.186 -	}
  27.187 -	if (hd->major >= DAC960_MAJOR && hd->major <= DAC960_MAJOR+7) {
  27.188 -		int ctlr = hd->major - DAC960_MAJOR;
  27.189 - 		if (part == 0)
  27.190 - 			sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
  27.191 - 		else
  27.192 - 			sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
  27.193 - 		return buf;
  27.194 - 	}
  27.195 -	if (hd->major == ATARAID_MAJOR) {
  27.196 -		int disk = minor >> hd->minor_shift;
  27.197 -		int part = minor & (( 1 << hd->minor_shift) - 1);
  27.198 -		if (part == 0)
  27.199 -			sprintf(buf, "%s/d%d", maj, disk);
  27.200 -		else
  27.201 -			sprintf(buf, "%s/d%dp%d", maj, disk, part);
  27.202 -		return buf;
  27.203 -	}
  27.204 -	if (part)
  27.205 -		sprintf(buf, "%s%c%d", maj, unit+'a', part);
  27.206 -	else
  27.207 -		sprintf(buf, "%s%c", maj, unit+'a');
  27.208 -	return buf;
  27.209 -}
  27.210 -
  27.211 -/*
  27.212 - * Add a partitions details to the devices partition description.
  27.213 - */
  27.214 -void add_gd_partition(struct gendisk *hd, int minor, int start, int size)
  27.215 -{
  27.216 -#ifndef CONFIG_DEVFS_FS
  27.217 -	char buf[40];
  27.218 -#endif
  27.219 -
  27.220 -	hd->part[minor].start_sect = start;
  27.221 -	hd->part[minor].nr_sects   = size;
  27.222 -#ifdef CONFIG_DEVFS_FS
  27.223 -	printk(" p%d", (minor & ((1 << hd->minor_shift) - 1)));
  27.224 -#else
  27.225 -	if ((hd->major >= COMPAQ_SMART2_MAJOR+0 && hd->major <= COMPAQ_SMART2_MAJOR+7) ||
  27.226 -	    (hd->major >= COMPAQ_CISS_MAJOR+0 && hd->major <= COMPAQ_CISS_MAJOR+7))
  27.227 -		printk(" p%d", (minor & ((1 << hd->minor_shift) - 1)));
  27.228 -	else
  27.229 -		printk(" %s", disk_name(hd, minor, buf));
  27.230 -#endif
  27.231 -}
  27.232 -
  27.233 -static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor)
  27.234 -{
  27.235 -	devfs_handle_t de = NULL;
  27.236 -	static int first_time = 1;
  27.237 -	unsigned long first_sector;
  27.238 -	struct block_device *bdev;
  27.239 -	char buf[64];
  27.240 -	int i;
  27.241 -
  27.242 -	if (first_time)
  27.243 -		printk(KERN_INFO "Partition check:\n");
  27.244 -	first_time = 0;
  27.245 -	first_sector = hd->part[MINOR(dev)].start_sect;
  27.246 -
  27.247 -	/*
  27.248 -	 * This is a kludge to allow the partition check to be
  27.249 -	 * skipped for specific drives (e.g. IDE CD-ROM drives)
  27.250 -	 */
  27.251 -	if ((int)first_sector == -1) {
  27.252 -		hd->part[MINOR(dev)].start_sect = 0;
  27.253 -		return;
  27.254 -	}
  27.255 -
  27.256 -	if (hd->de_arr)
  27.257 -		de = hd->de_arr[MINOR(dev) >> hd->minor_shift];
  27.258 -	i = devfs_generate_path (de, buf, sizeof buf);
  27.259 -	if (i >= 0)
  27.260 -		printk(KERN_INFO " /dev/%s:", buf + i);
  27.261 -	else
  27.262 -		printk(KERN_INFO " %s:", disk_name(hd, MINOR(dev), buf));
  27.263 -	bdev = bdget(kdev_t_to_nr(dev));
  27.264 -	bdev->bd_inode->i_size = (loff_t)hd->part[MINOR(dev)].nr_sects << 9;
  27.265 -	bdev->bd_inode->i_blkbits = blksize_bits(block_size(dev));
  27.266 -	for (i = 0; check_part[i]; i++) {
  27.267 -		int res;
  27.268 -		res = check_part[i](hd, bdev, first_sector, first_part_minor);
  27.269 -		if (res) {
  27.270 -			if (res < 0 &&  warn_no_part)
  27.271 -				printk(" unable to read partition table\n");
  27.272 -			goto setup_devfs;
  27.273 -		}
  27.274 -	}
  27.275 -
  27.276 -	printk(" unknown partition table\n");
  27.277 -setup_devfs:
  27.278 -	invalidate_bdev(bdev, 1);
  27.279 -	truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
  27.280 -	bdput(bdev);
  27.281 -	i = first_part_minor - 1;
  27.282 -	devfs_register_partitions (hd, i, hd->sizes ? 0 : 1);
  27.283 -}
  27.284 -
  27.285 -#ifdef CONFIG_DEVFS_FS
  27.286 -static void devfs_register_partition (struct gendisk *dev, int minor, int part)
  27.287 -{
  27.288 -	int devnum = minor >> dev->minor_shift;
  27.289 -	devfs_handle_t dir;
  27.290 -	unsigned int devfs_flags = DEVFS_FL_DEFAULT;
  27.291 -	char devname[16];
  27.292 -
  27.293 -	if (dev->part[minor + part].de) return;
  27.294 -	dir = devfs_get_parent (dev->part[minor].de);
  27.295 -	if (!dir) return;
  27.296 -	if ( dev->flags && (dev->flags[devnum] & GENHD_FL_REMOVABLE) )
  27.297 -		devfs_flags |= DEVFS_FL_REMOVABLE;
  27.298 -	sprintf (devname, "part%d", part);
  27.299 -	dev->part[minor + part].de =
  27.300 -	    devfs_register (dir, devname, devfs_flags,
  27.301 -			    dev->major, minor + part,
  27.302 -			    S_IFBLK | S_IRUSR | S_IWUSR,
  27.303 -			    dev->fops, NULL);
  27.304 -}
  27.305 -
  27.306 -static struct unique_numspace disc_numspace = UNIQUE_NUMBERSPACE_INITIALISER;
  27.307 -
  27.308 -static void devfs_register_disc (struct gendisk *dev, int minor)
  27.309 -{
  27.310 -	int pos = 0;
  27.311 -	int devnum = minor >> dev->minor_shift;
  27.312 -	devfs_handle_t dir, slave;
  27.313 -	unsigned int devfs_flags = DEVFS_FL_DEFAULT;
  27.314 -	char dirname[64], symlink[16];
  27.315 -	static devfs_handle_t devfs_handle;
  27.316 -
  27.317 -	if (dev->part[minor].de) return;
  27.318 -	if ( dev->flags && (dev->flags[devnum] & GENHD_FL_REMOVABLE) )
  27.319 -		devfs_flags |= DEVFS_FL_REMOVABLE;
  27.320 -	if (dev->de_arr) {
  27.321 -		dir = dev->de_arr[devnum];
  27.322 -		if (!dir)  /*  Aware driver wants to block disc management  */
  27.323 -			return;
  27.324 -		pos = devfs_generate_path (dir, dirname + 3, sizeof dirname-3);
  27.325 -		if (pos < 0) return;
  27.326 -		strncpy (dirname + pos, "../", 3);
  27.327 -	}
  27.328 -	else {
  27.329 -		/*  Unaware driver: construct "real" directory  */
  27.330 -		sprintf (dirname, "../%s/disc%d", dev->major_name, devnum);
  27.331 -		dir = devfs_mk_dir (NULL, dirname + 3, NULL);
  27.332 -	}
  27.333 -	if (!devfs_handle)
  27.334 -		devfs_handle = devfs_mk_dir (NULL, "discs", NULL);
  27.335 -	dev->part[minor].number = devfs_alloc_unique_number (&disc_numspace);
  27.336 -	sprintf (symlink, "disc%d", dev->part[minor].number);
  27.337 -	devfs_mk_symlink (devfs_handle, symlink, DEVFS_FL_DEFAULT,
  27.338 -			  dirname + pos, &slave, NULL);
  27.339 -	dev->part[minor].de =
  27.340 -	    devfs_register (dir, "disc", devfs_flags, dev->major, minor,
  27.341 -			    S_IFBLK | S_IRUSR | S_IWUSR, dev->fops, NULL);
  27.342 -	devfs_auto_unregister (dev->part[minor].de, slave);
  27.343 -	if (!dev->de_arr)
  27.344 -		devfs_auto_unregister (slave, dir);
  27.345 -}
  27.346 -#endif  /*  CONFIG_DEVFS_FS  */
  27.347 -
  27.348 -void devfs_register_partitions (struct gendisk *dev, int minor, int unregister)
  27.349 -{
  27.350 -#ifdef CONFIG_DEVFS_FS
  27.351 -	int part;
  27.352 -
  27.353 -	if (!unregister)
  27.354 -		devfs_register_disc (dev, minor);
  27.355 -	for (part = 1; part < dev->max_p; part++) {
  27.356 -		if ( unregister || (dev->part[minor].nr_sects < 1) ||
  27.357 -		     (dev->part[part + minor].nr_sects < 1) ) {
  27.358 -			devfs_unregister (dev->part[part + minor].de);
  27.359 -			dev->part[part + minor].de = NULL;
  27.360 -			continue;
  27.361 -		}
  27.362 -		devfs_register_partition (dev, minor, part);
  27.363 -	}
  27.364 -	if (unregister) {
  27.365 -		devfs_unregister (dev->part[minor].de);
  27.366 -		dev->part[minor].de = NULL;
  27.367 -		devfs_dealloc_unique_number (&disc_numspace,
  27.368 -					     dev->part[minor].number);
  27.369 -	}
  27.370 -#endif  /*  CONFIG_DEVFS_FS  */
  27.371 -}
  27.372 -
  27.373 -/*
  27.374 - * This function will re-read the partition tables for a given device,
  27.375 - * and set things back up again.  There are some important caveats,
  27.376 - * however.  You must ensure that no one is using the device, and no one
  27.377 - * can start using the device while this function is being executed.
  27.378 - *
  27.379 - * Much of the cleanup from the old partition tables should have already been
  27.380 - * done
  27.381 - */
  27.382 -
  27.383 -void register_disk(struct gendisk *gdev, kdev_t dev, unsigned minors,
  27.384 -	struct block_device_operations *ops, long size)
  27.385 -{
  27.386 -	if (!gdev)
  27.387 -		return;
  27.388 -	grok_partitions(gdev, MINOR(dev)>>gdev->minor_shift, minors, size);
  27.389 -}
  27.390 -
  27.391 -void grok_partitions(struct gendisk *dev, int drive, unsigned minors, long size)
  27.392 -{
  27.393 -	int i;
  27.394 -	int first_minor	= drive << dev->minor_shift;
  27.395 -	int end_minor	= first_minor + dev->max_p;
  27.396 -
  27.397 -	if(!dev->sizes)
  27.398 -		blk_size[dev->major] = NULL;
  27.399 -
  27.400 -	dev->part[first_minor].nr_sects = size;
  27.401 -	/* No such device or no minors to use for partitions */
  27.402 -	if ( !size && dev->flags && (dev->flags[drive] & GENHD_FL_REMOVABLE) )
  27.403 -		devfs_register_partitions (dev, first_minor, 0);
  27.404 -	if (!size || minors == 1)
  27.405 -		return;
  27.406 -
  27.407 -	if (dev->sizes) {
  27.408 -		dev->sizes[first_minor] = size >> (BLOCK_SIZE_BITS - 9);
  27.409 -		for (i = first_minor + 1; i < end_minor; i++)
  27.410 -			dev->sizes[i] = 0;
  27.411 -	}
  27.412 -	blk_size[dev->major] = dev->sizes;
  27.413 -	check_partition(dev, MKDEV(dev->major, first_minor), 1 + first_minor);
  27.414 -
  27.415 - 	/*
  27.416 - 	 * We need to set the sizes array before we will be able to access
  27.417 - 	 * any of the partitions on this device.
  27.418 - 	 */
  27.419 -	if (dev->sizes != NULL) {	/* optional safeguard in ll_rw_blk.c */
  27.420 -		for (i = first_minor; i < end_minor; i++)
  27.421 -			dev->sizes[i] = dev->part[i].nr_sects >> (BLOCK_SIZE_BITS - 9);
  27.422 -	}
  27.423 -}
  27.424 -
  27.425 -unsigned char *read_dev_sector(struct block_device *bdev, unsigned long n, Sector *p)
  27.426 -{
  27.427 -	struct address_space *mapping = bdev->bd_inode->i_mapping;
  27.428 -	int sect = PAGE_CACHE_SIZE / 512;
  27.429 -	struct page *page;
  27.430 -
  27.431 -	page = read_cache_page(mapping, n/sect,
  27.432 -			(filler_t *)mapping->a_ops->readpage, NULL);
  27.433 -	if (!IS_ERR(page)) {
  27.434 -		wait_on_page(page);
  27.435 -		if (!Page_Uptodate(page))
  27.436 -			goto fail;
  27.437 -		if (PageError(page))
  27.438 -			goto fail;
  27.439 -		p->v = page;
  27.440 -		return (unsigned char *)page_address(page) + 512 * (n % sect);
  27.441 -fail:
  27.442 -		page_cache_release(page);
  27.443 -	}
  27.444 -	p->v = NULL;
  27.445 -	return NULL;
  27.446 -}
    28.1 --- a/xenolinux-2.4.22-sparse/fs/partitions/xeno.c	Wed Nov 05 11:50:12 2003 +0000
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,94 +0,0 @@
    28.4 -
    28.5 -#include <linux/kernel.h>
    28.6 -#include <asm/hypervisor.h>
    28.7 -#include <linux/fs.h>
    28.8 -#include <linux/blk.h>
    28.9 -#include <linux/slab.h>
   28.10 -#include <linux/genhd.h>
   28.11 -#include <asm/hypervisor-ifs/vbd.h>
   28.12 -#include <linux/pagemap.h>
   28.13 -
   28.14 -#include "check.h"
   28.15 -#include "xeno.h"
   28.16 -
   28.17 -extern int xenolinux_control_msg(int operration, char *buffer, int size);
   28.18 -extern unsigned short xldev_to_physdev(kdev_t xldev);
   28.19 -
   28.20 -/* Grab the physdisk partitions list from the hypervisor. */
   28.21 -int xeno_partition(struct gendisk *hd,
   28.22 -                   struct block_device *bdev,
   28.23 -                   unsigned long first_sec,
   28.24 -                   int first_part_minor)
   28.25 -{
   28.26 -    physdisk_probebuf_t *buf;
   28.27 -    int i, minor;
   28.28 -    
   28.29 -    /* Privileged domains can read partition info themselves. */
   28.30 -    if ( start_info.flags & SIF_PRIVILEGED )
   28.31 -        return 0;
   28.32 -
   28.33 -    /* This only deals with raw/direct devices (IDE & SCSI). */
   28.34 -    switch ( xldev_to_physdev(bdev->bd_dev) & XENDEV_TYPE_MASK )
   28.35 -    {
   28.36 -    case XENDEV_IDE:
   28.37 -    case XENDEV_SCSI:
   28.38 -        break;
   28.39 -    default:
   28.40 -        return 0;
   28.41 -    }
   28.42 -
   28.43 -    if ( (buf = kmalloc(sizeof(*buf), GFP_KERNEL)) == NULL )
   28.44 -        return -ENOMEM;
   28.45 -
   28.46 -    buf->domain = start_info.dom_id;
   28.47 -    buf->start_ind = 0;
   28.48 -    buf->n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
   28.49 -
   28.50 -    xenolinux_control_msg(XEN_BLOCK_PHYSDEV_PROBE, (char *)buf,
   28.51 -                          sizeof(*buf));
   28.52 -
   28.53 -    if ( buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST )
   28.54 -        printk(KERN_ALERT "Too many returns for xeno partition parser\n");
   28.55 -
   28.56 -    /* Check for access to whole disk, allowing direct p.t. access. */
   28.57 -    for ( i = 0; i < buf->n_aces; i++ )
   28.58 -    {
   28.59 -        if ( (buf->entries[i].device == xldev_to_physdev(bdev->bd_dev)) &&
   28.60 -             (buf->entries[i].partition == 0) )
   28.61 -        {
   28.62 -            if ( !(buf->entries[i].mode & PHYSDISK_MODE_W) )
   28.63 -            {
   28.64 -                if ( !(buf->entries[i].mode & PHYSDISK_MODE_R) )
   28.65 -                    continue;
   28.66 -                for ( i = 0; i < hd->max_p; i++ ) 
   28.67 -                    set_device_ro(bdev->bd_dev + i, 1);
   28.68 -            }
   28.69 -            kfree(buf);
   28.70 -            return 0;
   28.71 -        }
   28.72 -    }
   28.73 -
   28.74 -    /* No direct access so trawl through the access lists instead. */
   28.75 -    for ( i = 0; i < buf->n_aces; i++ )
   28.76 -    {
   28.77 -        if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev))
   28.78 -            continue;
   28.79 -        if ( !(buf->entries[i].mode & PHYSDISK_MODE_W) )
   28.80 -        {
   28.81 -            if ( !(buf->entries[i].mode & PHYSDISK_MODE_R) )
   28.82 -                continue;
   28.83 -            set_device_ro(bdev->bd_dev + buf->entries[i].partition, 1);
   28.84 -        }
   28.85 -        minor = buf->entries[i].partition + first_part_minor - 1;
   28.86 -        add_gd_partition(hd,
   28.87 -                         minor,
   28.88 -                         buf->entries[i].start_sect,
   28.89 -                         buf->entries[i].n_sectors);
   28.90 -    }
   28.91 -
   28.92 -    kfree(buf);
   28.93 -
   28.94 -    printk("\n");
   28.95 -
   28.96 -    return 1;
   28.97 -}
    29.1 --- a/xenolinux-2.4.22-sparse/fs/partitions/xeno.h	Wed Nov 05 11:50:12 2003 +0000
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,2 +0,0 @@
    29.4 -int xeno_partition(struct gendisk *hd, struct block_device *bdev,
    29.5 -		   unsigned long fsec, int first_part_minor);
    30.1 --- a/xenolinux-2.4.22-sparse/include/asm-xeno/proc_cmd.h	Wed Nov 05 11:50:12 2003 +0000
    30.2 +++ b/xenolinux-2.4.22-sparse/include/asm-xeno/proc_cmd.h	Wed Nov 05 11:57:30 2003 +0000
    30.3 @@ -24,9 +24,5 @@ typedef struct privcmd_blkmsg
    30.4      _IOC(_IOC_NONE, 'P', 0, sizeof(privcmd_hypercall_t))
    30.5  #define IOCTL_PRIVCMD_BLKMSG           \
    30.6      _IOC(_IOC_NONE, 'P', 1, sizeof(privcmd_blkmsg_t))
    30.7 -#define IOCTL_PRIVCMD_LINDEV_TO_XENDEV \
    30.8 -    _IOC(_IOC_NONE, 'P', 2, sizeof(unsigned short))
    30.9 -#define IOCTL_PRIVCMD_XENDEV_TO_LINDEV \
   30.10 -    _IOC(_IOC_NONE, 'P', 3, sizeof(unsigned short))
   30.11  
   30.12  #endif /* __PROC_CMD_H__ */