WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Manual merge.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Manual merge.
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Fri, 20 May 2005 13:34:14 +0000
Delivery-date: Fri, 20 May 2005 14:02:33 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1483, 2005/05/20 14:34:14+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Manual merge.



 blkfront.c |  530 ++++++++++++++++++++++++++++++++++---------------------------
 block.h    |    5 
 2 files changed, 304 insertions(+), 231 deletions(-)


diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   2005-05-20 
10:03:13 -04:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   2005-05-20 
10:03:13 -04:00
@@ -6,6 +6,8 @@
  * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
  * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
  * Copyright (c) 2004, Christian Limpach
+ * Copyright (c) 2004, Andrew Warfield
+ * Copyright (c) 2005, Christopher Clark
  * 
  * This file may be distributed separately from the Linux kernel, or
  * incorporated into other software packages, subject to the following license:
@@ -29,6 +31,14 @@
  * IN THE SOFTWARE.
  */
 
+#if 1
+#define ASSERT(_p) \
+    if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
+    __LINE__, __FILE__); *(int*)0=0; }
+#else
+#define ASSERT(_p)
+#endif
+
 #include <linux/version.h>
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
@@ -44,6 +54,11 @@
 #include <linux/interrupt.h>
 #include <scsi/scsi.h>
 #include <asm-xen/ctrl_if.h>
+#include <asm-xen/evtchn.h>
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+#include <asm-xen/xen-public/grant_table.h>
+#include <asm-xen/gnttab.h>
+#endif
 
 typedef unsigned char byte; /* from linux/ide.h */
 
@@ -68,44 +83,47 @@
 static int blkif_control_rsp_valid;
 static blkif_response_t blkif_control_rsp;
 
-static blkif_ring_t *blk_ring = NULL;
-static BLKIF_RING_IDX resp_cons; /* Response consumer for comms ring. */
-static BLKIF_RING_IDX req_prod;  /* Private request producer.         */
-
-unsigned long rec_ring_free;
-blkif_request_t rec_ring[BLKIF_RING_SIZE];
-
-static int recovery = 0;           /* "Recovery in progress" flag.  Protected
-                                    * by the blkif_io_lock */
-
-/* We plug the I/O ring if the driver is suspended or if the ring is full. */
-#define BLKIF_RING_FULL (((req_prod - resp_cons) == BLKIF_RING_SIZE) || \
-                         (blkif_state != BLKIF_STATE_CONNECTED))
+static blkif_front_ring_t blk_ring;
 
-static void kick_pending_request_queues(void);
+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
 
-int __init xlblk_init(void);
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+static domid_t rdomid = 0;
+static grant_ref_t gref_head, gref_terminal;
+#define MAXIMUM_OUTSTANDING_BLOCK_REQS \
+    (BLKIF_MAX_SEGMENTS_PER_REQUEST * BLKIF_RING_SIZE)
+#define GRANTREF_INVALID (1<<15)
+#endif
 
-void blkif_completion( blkif_request_t *req );
+static struct blk_shadow {
+    blkif_request_t req;
+    unsigned long request;
+    unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+} blk_shadow[BLK_RING_SIZE];
+unsigned long blk_shadow_free;
 
-static inline int GET_ID_FROM_FREELIST( void )
-{
-    unsigned long free = rec_ring_free;
+static int recovery = 0; /* Recovery in progress: protected by blkif_io_lock */
 
-    if ( free > BLKIF_RING_SIZE )
-        BUG();
+static void kick_pending_request_queues(void);
 
-    rec_ring_free = rec_ring[free].id;
+int __init xlblk_init(void);
 
-    rec_ring[free].id = 0x0fffffee; /* debug */
+static void blkif_completion(struct blk_shadow *s);
 
+static inline int GET_ID_FROM_FREELIST(void)
+{
+    unsigned long free = blk_shadow_free;
+    BUG_ON(free > BLK_RING_SIZE);
+    blk_shadow_free = blk_shadow[free].req.id;
+    blk_shadow[free].req.id = 0x0fffffee; /* debug */
     return free;
 }
 
-static inline void ADD_ID_TO_FREELIST( unsigned long id )
+static inline void ADD_ID_TO_FREELIST(unsigned long id)
 {
-    rec_ring[id].id = rec_ring_free;
-    rec_ring_free = id;
+    blk_shadow[id].req.id  = blk_shadow_free;
+    blk_shadow[id].request = 0;
+    blk_shadow_free = id;
 }
 
 
@@ -119,48 +137,43 @@
 #define DISABLE_SCATTERGATHER() (sg_operation = -1)
 #endif
 
-static inline void translate_req_to_pfn(blkif_request_t *xreq,
-                                        blkif_request_t *req)
+static inline void pickle_request(struct blk_shadow *s, blkif_request_t *r)
 {
+#ifndef CONFIG_XEN_BLKDEV_GRANT
     int i;
+#endif
 
-    xreq->operation     = req->operation;
-    xreq->nr_segments   = req->nr_segments;
-    xreq->device        = req->device;
-    /* preserve id */
-    xreq->sector_number = req->sector_number;
+    s->req = *r;
 
-    for ( i = 0; i < req->nr_segments; i++ )
-        xreq->frame_and_sects[i] = machine_to_phys(req->frame_and_sects[i]);
+#ifndef CONFIG_XEN_BLKDEV_GRANT
+    for ( i = 0; i < r->nr_segments; i++ )
+        s->req.frame_and_sects[i] = machine_to_phys(r->frame_and_sects[i]);
+#endif
 }
 
-static inline void translate_req_to_mfn(blkif_request_t *xreq,
-                                        blkif_request_t *req)
+static inline void unpickle_request(blkif_request_t *r, struct blk_shadow *s)
 {
+#ifndef CONFIG_XEN_BLKDEV_GRANT
     int i;
+#endif
 
-    xreq->operation     = req->operation;
-    xreq->nr_segments   = req->nr_segments;
-    xreq->device        = req->device;
-    xreq->id            = req->id;   /* copy id (unlike above) */
-    xreq->sector_number = req->sector_number;
+    *r = s->req;
 
-    for ( i = 0; i < req->nr_segments; i++ )
-        xreq->frame_and_sects[i] = phys_to_machine(req->frame_and_sects[i]);
+#ifndef CONFIG_XEN_BLKDEV_GRANT
+    for ( i = 0; i < s->req.nr_segments; i++ )
+        r->frame_and_sects[i] = phys_to_machine(s->req.frame_and_sects[i]);
+#endif
 }
 
 
 static inline void flush_requests(void)
 {
     DISABLE_SCATTERGATHER();
-    wmb(); /* Ensure that the frontend can see the requests. */
-    blk_ring->req_prod = req_prod;
+    RING_PUSH_REQUESTS(&blk_ring);
     notify_via_evtchn(blkif_evtchn);
 }
 
 
-
-
 /**************************  KERNEL VERSION 2.6  **************************/
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
@@ -182,7 +195,6 @@
 
 static void kick_pending_request_queues(void)
 {
-
     if ( (xlbd_blk_queue != NULL) &&
          test_bit(QUEUE_FLAG_STOPPED, &xlbd_blk_queue->queue_flags) )
     {
@@ -192,7 +204,6 @@
          */
         xlbd_blk_queue->request_fn(xlbd_blk_queue);
     }
-
 }
 
 
@@ -217,9 +228,8 @@
      * When usage drops to zero it may allow more VBD updates to occur.
      * Update of usage count is protected by a per-device semaphore.
      */
-    if (--di->mi->usage == 0) {
+    if ( --di->mi->usage == 0 )
         vbd_update();
-    }
 
     return 0;
 }
@@ -228,14 +238,13 @@
 int blkif_ioctl(struct inode *inode, struct file *filep,
                 unsigned command, unsigned long argument)
 {
-       int i;
-    /*  struct gendisk *gd = inode->i_bdev->bd_disk; */
+    int i;
 
     DPRINTK_IOCTL("command: 0x%x, argument: 0x%lx, dev: 0x%04x\n",
                   command, (long)argument, inode->i_rdev); 
   
-    switch (command) {
-
+    switch ( command )
+    {
     case HDIO_GETGEO:
         /* return ENOSYS to use defaults */
         return -ENOSYS;
@@ -255,65 +264,6 @@
     return 0;
 }
 
-#if 0
-/* check media change: should probably do something here in some cases :-) */
-int blkif_check(kdev_t dev)
-{
-    DPRINTK("blkif_check\n");
-    return 0;
-}
-
-int blkif_revalidate(kdev_t dev)
-{
-    struct block_device *bd;
-    struct gendisk *gd;
-    xen_block_t *disk;
-    unsigned long capacity;
-    int i, rc = 0;
-    
-    if ( (bd = bdget(dev)) == NULL )
-        return -EINVAL;
-
-    /*
-     * Update of partition info, and check of usage count, is protected
-     * by the per-block-device semaphore.

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>