ia64/xen-unstable

changeset 2061:20a45872cb42

bitkeeper revision 1.1135 (410fc9b5AR4G7sAORAI1W-pb1J1aAA)

More 2.4/2.6 merges.
author kaf24@scramble.cl.cam.ac.uk
date Tue Aug 03 17:21:57 2004 +0000 (2004-08-03)
parents 539c0e6f0384
children a4c9a5d96b3c
files .rootkeys linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/control.c linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/interface.c linux-2.4.26-xen-sparse/mkbuildtree
line diff
     1.1 --- a/.rootkeys	Tue Aug 03 16:46:07 2004 +0000
     1.2 +++ b/.rootkeys	Tue Aug 03 17:21:57 2004 +0000
     1.3 @@ -52,8 +52,6 @@ 3e6377f8Me8IqtvEhb70XFgOvqQH7A linux-2.4
     1.4  4083dc16z0jvZEH4PiVDbDRreaNp6w linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/Makefile
     1.5  4083dc16KQus88a4U3uCV6qVCA6_8Q linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/Makefile
     1.6  4087cf0dPeHOvzmZAazvwLslKEF93A linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/common.h
     1.7 -4087cf0da2cROOiybf9A-j4R_yHnjg linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/control.c
     1.8 -4087cf0dvXL1PKX23t_LvO1wVPb7OA linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/interface.c
     1.9  4087cf0dkVF3I19gpT1cNubeJgQr7g linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c
    1.10  4087cf0dlv1Dw4MAbeRStPPG8IvPPg linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c
    1.11  4075806dI5kfeMD5RV-DA0PYoThx_w linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/frontend/Makefile
     2.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/control.c	Tue Aug 03 16:46:07 2004 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,87 +0,0 @@
     2.4 -/******************************************************************************
     2.5 - * arch/xen/drivers/blkif/backend/control.c
     2.6 - * 
     2.7 - * Routines for interfacing with the control plane.
     2.8 - * 
     2.9 - * Copyright (c) 2004, Keir Fraser
    2.10 - */
    2.11 -
    2.12 -#include "common.h"
    2.13 -
    2.14 -static void blkif_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
    2.15 -{
    2.16 -    DPRINTK("Received blkif backend message, subtype=%d\n", msg->subtype);
    2.17 -    
    2.18 -    switch ( msg->subtype )
    2.19 -    {
    2.20 -    case CMSG_BLKIF_BE_CREATE:
    2.21 -        if ( msg->length != sizeof(blkif_be_create_t) )
    2.22 -            goto parse_error;
    2.23 -        blkif_create((blkif_be_create_t *)&msg->msg[0]);
    2.24 -        break;        
    2.25 -    case CMSG_BLKIF_BE_DESTROY:
    2.26 -        if ( msg->length != sizeof(blkif_be_destroy_t) )
    2.27 -            goto parse_error;
    2.28 -        blkif_destroy((blkif_be_destroy_t *)&msg->msg[0]);
    2.29 -        break;        
    2.30 -    case CMSG_BLKIF_BE_CONNECT:
    2.31 -        if ( msg->length != sizeof(blkif_be_connect_t) )
    2.32 -            goto parse_error;
    2.33 -        blkif_connect((blkif_be_connect_t *)&msg->msg[0]);
    2.34 -        break;        
    2.35 -    case CMSG_BLKIF_BE_DISCONNECT:
    2.36 -        if ( msg->length != sizeof(blkif_be_disconnect_t) )
    2.37 -            goto parse_error;
    2.38 -        if ( !blkif_disconnect((blkif_be_disconnect_t *)&msg->msg[0],msg->id) )
    2.39 -            return; /* Sending the response is deferred until later. */
    2.40 -        break;        
    2.41 -    case CMSG_BLKIF_BE_VBD_CREATE:
    2.42 -        if ( msg->length != sizeof(blkif_be_vbd_create_t) )
    2.43 -            goto parse_error;
    2.44 -        vbd_create((blkif_be_vbd_create_t *)&msg->msg[0]);
    2.45 -        break;
    2.46 -    case CMSG_BLKIF_BE_VBD_DESTROY:
    2.47 -        if ( msg->length != sizeof(blkif_be_vbd_destroy_t) )
    2.48 -            goto parse_error;
    2.49 -        vbd_destroy((blkif_be_vbd_destroy_t *)&msg->msg[0]);
    2.50 -        break;
    2.51 -    case CMSG_BLKIF_BE_VBD_GROW:
    2.52 -        if ( msg->length != sizeof(blkif_be_vbd_grow_t) )
    2.53 -            goto parse_error;
    2.54 -        vbd_grow((blkif_be_vbd_grow_t *)&msg->msg[0]);
    2.55 -        break;
    2.56 -    case CMSG_BLKIF_BE_VBD_SHRINK:
    2.57 -        if ( msg->length != sizeof(blkif_be_vbd_shrink_t) )
    2.58 -            goto parse_error;
    2.59 -        vbd_shrink((blkif_be_vbd_shrink_t *)&msg->msg[0]);
    2.60 -        break;
    2.61 -    default:
    2.62 -        goto parse_error;
    2.63 -    }
    2.64 -
    2.65 -    ctrl_if_send_response(msg);
    2.66 -    return;
    2.67 -
    2.68 - parse_error:
    2.69 -    DPRINTK("Parse error while reading message subtype %d, len %d\n",
    2.70 -            msg->subtype, msg->length);
    2.71 -    msg->length = 0;
    2.72 -    ctrl_if_send_response(msg);
    2.73 -}
    2.74 -
    2.75 -void blkif_ctrlif_init(void)
    2.76 -{
    2.77 -    ctrl_msg_t                       cmsg;
    2.78 -    blkif_be_driver_status_changed_t st;
    2.79 -
    2.80 -    (void)ctrl_if_register_receiver(CMSG_BLKIF_BE, blkif_ctrlif_rx, 
    2.81 -                                    CALLBACK_IN_BLOCKING_CONTEXT);
    2.82 -
    2.83 -    /* Send a driver-UP notification to the domain controller. */
    2.84 -    cmsg.type      = CMSG_BLKIF_BE;
    2.85 -    cmsg.subtype   = CMSG_BLKIF_BE_DRIVER_STATUS_CHANGED;
    2.86 -    cmsg.length    = sizeof(blkif_be_driver_status_changed_t);
    2.87 -    st.status      = BLKIF_DRIVER_STATUS_UP;
    2.88 -    memcpy(cmsg.msg, &st, sizeof(st));
    2.89 -    ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
    2.90 -}
     3.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/interface.c	Tue Aug 03 16:46:07 2004 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,235 +0,0 @@
     3.4 -/******************************************************************************
     3.5 - * arch/xen/drivers/blkif/backend/interface.c
     3.6 - * 
     3.7 - * Block-device interface management.
     3.8 - * 
     3.9 - * Copyright (c) 2004, Keir Fraser
    3.10 - */
    3.11 -
    3.12 -#include "common.h"
    3.13 -
    3.14 -#define BLKIF_HASHSZ 1024
    3.15 -#define BLKIF_HASH(_d,_h) (((int)(_d)^(int)(_h))&(BLKIF_HASHSZ-1))
    3.16 -
    3.17 -static kmem_cache_t *blkif_cachep;
    3.18 -static blkif_t      *blkif_hash[BLKIF_HASHSZ];
    3.19 -
    3.20 -blkif_t *blkif_find_by_handle(domid_t domid, unsigned int handle)
    3.21 -{
    3.22 -    blkif_t *blkif = blkif_hash[BLKIF_HASH(domid, handle)];
    3.23 -    while ( (blkif != NULL) && 
    3.24 -            ((blkif->domid != domid) || (blkif->handle != handle)) )
    3.25 -        blkif = blkif->hash_next;
    3.26 -    return blkif;
    3.27 -}
    3.28 -
    3.29 -void __blkif_disconnect_complete(blkif_t *blkif)
    3.30 -{
    3.31 -    ctrl_msg_t            cmsg;
    3.32 -    blkif_be_disconnect_t disc;
    3.33 -
    3.34 -    /*
    3.35 -     * These can't be done in __blkif_disconnect() because at that point there
    3.36 -     * may be outstanding requests at the disc whose asynchronous responses
    3.37 -     * must still be notified to the remote driver.
    3.38 -     */
    3.39 -    unbind_evtchn_from_irq(blkif->evtchn);
    3.40 -    vfree(blkif->blk_ring_base);
    3.41 -
    3.42 -    /* Construct the deferred response message. */
    3.43 -    cmsg.type         = CMSG_BLKIF_BE;
    3.44 -    cmsg.subtype      = CMSG_BLKIF_BE_DISCONNECT;
    3.45 -    cmsg.id           = blkif->disconnect_rspid;
    3.46 -    cmsg.length       = sizeof(blkif_be_disconnect_t);
    3.47 -    disc.domid        = blkif->domid;
    3.48 -    disc.blkif_handle = blkif->handle;
    3.49 -    disc.status       = BLKIF_BE_STATUS_OKAY;
    3.50 -    memcpy(cmsg.msg, &disc, sizeof(disc));
    3.51 -
    3.52 -    /*
    3.53 -     * Make sure message is constructed /before/ status change, because
    3.54 -     * after the status change the 'blkif' structure could be deallocated at
    3.55 -     * any time. Also make sure we send the response /after/ status change,
    3.56 -     * as otherwise a subsequent CONNECT request could spuriously fail if
    3.57 -     * another CPU doesn't see the status change yet.
    3.58 -     */
    3.59 -    mb();
    3.60 -    if ( blkif->status != DISCONNECTING )
    3.61 -        BUG();
    3.62 -    blkif->status = DISCONNECTED;
    3.63 -    mb();
    3.64 -
    3.65 -    /* Send the successful response. */
    3.66 -    ctrl_if_send_response(&cmsg);
    3.67 -}
    3.68 -
    3.69 -void blkif_create(blkif_be_create_t *create)
    3.70 -{
    3.71 -    domid_t       domid  = create->domid;
    3.72 -    unsigned int  handle = create->blkif_handle;
    3.73 -    blkif_t     **pblkif, *blkif;
    3.74 -
    3.75 -    if ( (blkif = kmem_cache_alloc(blkif_cachep, GFP_KERNEL)) == NULL )
    3.76 -    {
    3.77 -        DPRINTK("Could not create blkif: out of memory\n");
    3.78 -        create->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
    3.79 -        return;
    3.80 -    }
    3.81 -
    3.82 -    memset(blkif, 0, sizeof(*blkif));
    3.83 -    blkif->domid  = domid;
    3.84 -    blkif->handle = handle;
    3.85 -    blkif->status = DISCONNECTED;
    3.86 -    spin_lock_init(&blkif->vbd_lock);
    3.87 -    spin_lock_init(&blkif->blk_ring_lock);
    3.88 -    atomic_set(&blkif->refcnt, 0);
    3.89 -
    3.90 -    pblkif = &blkif_hash[BLKIF_HASH(domid, handle)];
    3.91 -    while ( *pblkif != NULL )
    3.92 -    {
    3.93 -        if ( ((*pblkif)->domid == domid) && ((*pblkif)->handle == handle) )
    3.94 -        {
    3.95 -            DPRINTK("Could not create blkif: already exists\n");
    3.96 -            create->status = BLKIF_BE_STATUS_INTERFACE_EXISTS;
    3.97 -            kmem_cache_free(blkif_cachep, blkif);
    3.98 -            return;
    3.99 -        }
   3.100 -        pblkif = &(*pblkif)->hash_next;
   3.101 -    }
   3.102 -
   3.103 -    blkif->hash_next = *pblkif;
   3.104 -    *pblkif = blkif;
   3.105 -
   3.106 -    DPRINTK("Successfully created blkif\n");
   3.107 -    create->status = BLKIF_BE_STATUS_OKAY;
   3.108 -}
   3.109 -
   3.110 -void blkif_destroy(blkif_be_destroy_t *destroy)
   3.111 -{
   3.112 -    domid_t       domid  = destroy->domid;
   3.113 -    unsigned int  handle = destroy->blkif_handle;
   3.114 -    blkif_t     **pblkif, *blkif;
   3.115 -
   3.116 -    pblkif = &blkif_hash[BLKIF_HASH(domid, handle)];
   3.117 -    while ( (blkif = *pblkif) != NULL )
   3.118 -    {
   3.119 -        if ( (blkif->domid == domid) && (blkif->handle == handle) )
   3.120 -        {
   3.121 -            if ( blkif->status != DISCONNECTED )
   3.122 -                goto still_connected;
   3.123 -            goto destroy;
   3.124 -        }
   3.125 -        pblkif = &blkif->hash_next;
   3.126 -    }
   3.127 -
   3.128 -    destroy->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   3.129 -    return;
   3.130 -
   3.131 - still_connected:
   3.132 -    destroy->status = BLKIF_BE_STATUS_INTERFACE_CONNECTED;
   3.133 -    return;
   3.134 -
   3.135 - destroy:
   3.136 -    *pblkif = blkif->hash_next;
   3.137 -    destroy_all_vbds(blkif);
   3.138 -    kmem_cache_free(blkif_cachep, blkif);
   3.139 -    destroy->status = BLKIF_BE_STATUS_OKAY;
   3.140 -}
   3.141 -
   3.142 -void blkif_connect(blkif_be_connect_t *connect)
   3.143 -{
   3.144 -    domid_t       domid  = connect->domid;
   3.145 -    unsigned int  handle = connect->blkif_handle;
   3.146 -    unsigned int  evtchn = connect->evtchn;
   3.147 -    unsigned long shmem_frame = connect->shmem_frame;
   3.148 -    struct vm_struct *vma;
   3.149 -    pgprot_t      prot;
   3.150 -    int           error;
   3.151 -    blkif_t      *blkif;
   3.152 -
   3.153 -    blkif = blkif_find_by_handle(domid, handle);
   3.154 -    if ( unlikely(blkif == NULL) )
   3.155 -    {
   3.156 -        DPRINTK("blkif_connect attempted for non-existent blkif (%u,%u)\n", 
   3.157 -                connect->domid, connect->blkif_handle); 
   3.158 -        connect->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   3.159 -        return;
   3.160 -    }
   3.161 -
   3.162 -    if ( (vma = get_vm_area(PAGE_SIZE, VM_IOREMAP)) == NULL )
   3.163 -    {
   3.164 -        connect->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
   3.165 -        return;
   3.166 -    }
   3.167 -
   3.168 -    prot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED);
   3.169 -    error = direct_remap_area_pages(&init_mm, VMALLOC_VMADDR(vma->addr),
   3.170 -                                    shmem_frame<<PAGE_SHIFT, PAGE_SIZE,
   3.171 -                                    prot, domid);
   3.172 -    if ( error != 0 )
   3.173 -    {
   3.174 -        if ( error == -ENOMEM )
   3.175 -            connect->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
   3.176 -        else if ( error == -EFAULT )
   3.177 -            connect->status = BLKIF_BE_STATUS_MAPPING_ERROR;
   3.178 -        else
   3.179 -            connect->status = BLKIF_BE_STATUS_ERROR;
   3.180 -        vfree(vma->addr);
   3.181 -        return;
   3.182 -    }
   3.183 -
   3.184 -    if ( blkif->status != DISCONNECTED )
   3.185 -    {
   3.186 -        connect->status = BLKIF_BE_STATUS_INTERFACE_CONNECTED;
   3.187 -        vfree(vma->addr);
   3.188 -        return;
   3.189 -    }
   3.190 -
   3.191 -    blkif->evtchn        = evtchn;
   3.192 -    blkif->irq           = bind_evtchn_to_irq(evtchn);
   3.193 -    blkif->shmem_frame   = shmem_frame;
   3.194 -    blkif->blk_ring_base = (blkif_ring_t *)vma->addr;
   3.195 -    blkif->status        = CONNECTED;
   3.196 -    blkif_get(blkif);
   3.197 -
   3.198 -    request_irq(blkif->irq, blkif_be_int, 0, "blkif-backend", blkif);
   3.199 -
   3.200 -    connect->status = BLKIF_BE_STATUS_OKAY;
   3.201 -}
   3.202 -
   3.203 -int blkif_disconnect(blkif_be_disconnect_t *disconnect, u8 rsp_id)
   3.204 -{
   3.205 -    domid_t       domid  = disconnect->domid;
   3.206 -    unsigned int  handle = disconnect->blkif_handle;
   3.207 -    blkif_t      *blkif;
   3.208 -
   3.209 -    blkif = blkif_find_by_handle(domid, handle);
   3.210 -    if ( unlikely(blkif == NULL) )
   3.211 -    {
   3.212 -        DPRINTK("blkif_disconnect attempted for non-existent blkif"
   3.213 -                " (%u,%u)\n", disconnect->domid, disconnect->blkif_handle); 
   3.214 -        disconnect->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   3.215 -        return 1; /* Caller will send response error message. */
   3.216 -    }
   3.217 -
   3.218 -    if ( blkif->status == CONNECTED )
   3.219 -    {
   3.220 -        blkif->status = DISCONNECTING;
   3.221 -        blkif->disconnect_rspid = rsp_id;
   3.222 -        wmb(); /* Let other CPUs see the status change. */
   3.223 -        free_irq(blkif->irq, blkif);
   3.224 -        blkif_deschedule(blkif);
   3.225 -        blkif_put(blkif);
   3.226 -        return 0; /* Caller should not send response message. */
   3.227 -    }
   3.228 -
   3.229 -    disconnect->status = BLKIF_BE_STATUS_OKAY;
   3.230 -    return 1;
   3.231 -}
   3.232 -
   3.233 -void __init blkif_interface_init(void)
   3.234 -{
   3.235 -    blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t), 
   3.236 -                                     0, 0, NULL, NULL);
   3.237 -    memset(blkif_hash, 0, sizeof(blkif_hash));
   3.238 -}
     4.1 --- a/linux-2.4.26-xen-sparse/mkbuildtree	Tue Aug 03 16:46:07 2004 +0000
     4.2 +++ b/linux-2.4.26-xen-sparse/mkbuildtree	Tue Aug 03 17:21:57 2004 +0000
     4.3 @@ -256,3 +256,7 @@ ln -sf ../../../../../${LINUX_26}/driver
     4.4  ln -sf ../../../../../${LINUX_26}/drivers/xen/netback/control.c
     4.5  ln -sf ../../../../../${LINUX_26}/drivers/xen/netback/interface.c
     4.6  ln -sf ../../../../../${LINUX_26}/drivers/xen/netback/netback.c main.c
     4.7 +
     4.8 +cd ${AD}/arch/xen/drivers/blkif/backend
     4.9 +ln -sf ../../../../../${LINUX_26}/drivers/xen/blkback/control.c
    4.10 +ln -sf ../../../../../${LINUX_26}/drivers/xen/blkback/interface.c