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] [xen-unstable] [BLKTAP] Various cleanups necessary for i

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [BLKTAP] Various cleanups necessary for ia64 support.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 07 Nov 2006 12:30:25 +0000
Delivery-date: Tue, 07 Nov 2006 04:31:35 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 862aca401601062aa6207a00549c19cdac054bbb
# Parent  6f3c40ee248856b84053adb9f6edfc5d31955684
[BLKTAP] Various cleanups necessary for ia64 support.
- remove magic number 8 and 64.
  page size / sector size is 8 on x86, however on ia64 page size is
  16kb.
  blkring size is 64 on x86. however it's 128 on ia64.
- replace 0xFFFF with INVALID_GRANT_HANDLE
- don't map io ring into user space with uncachable.
  kernel access the page with cacable and tapdisk uses memory barrier
  so that it isn't necessary.
- remove printk warning and inserted new line.
- remove unused variable, page.
- add one BUG()

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c |   33 +++++++++++------------
 linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c |    6 ++--
 tools/blktap/drivers/blktapctrl.c                |    4 ++
 tools/blktap/drivers/tapdisk.c                   |    4 ++
 tools/blktap/drivers/tapdisk.h                   |    1 
 tools/blktap/lib/blktaplib.h                     |    7 ++--
 6 files changed, 29 insertions(+), 26 deletions(-)

diff -r 6f3c40ee2488 -r 862aca401601 
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Tue Nov 07 10:48:48 
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Tue Nov 07 11:01:35 
2006 +0000
@@ -93,8 +93,9 @@ int setup_xen_class(void)
  * mmap_alloc is initialised to 2 and should be adjustable on the fly via
  * sysfs.
  */
-#define MAX_DYNAMIC_MEM 64
-#define MAX_PENDING_REQS 64   
+#define BLK_RING_SIZE          __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+#define MAX_DYNAMIC_MEM                BLK_RING_SIZE
+#define MAX_PENDING_REQS       BLK_RING_SIZE
 #define MMAP_PAGES (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
 #define MMAP_VADDR(_start, _req,_seg)                                   \
         (_start +                                                       \
@@ -215,6 +216,7 @@ struct grant_handle_pair
         grant_handle_t kernel;
         grant_handle_t user;
 };
+#define INVALID_GRANT_HANDLE   0xFFFF
 
 static struct grant_handle_pair 
     pending_grant_handles[MAX_DYNAMIC_MEM][MMAP_PAGES];
@@ -293,10 +295,11 @@ static inline int GET_NEXT_REQ(unsigned 
 
 
 #define BLKTAP_INVALID_HANDLE(_g) \
-    (((_g->kernel) == 0xFFFF) && ((_g->user) == 0xFFFF))
+    (((_g->kernel) == INVALID_GRANT_HANDLE) &&  \
+     ((_g->user) == INVALID_GRANT_HANDLE))
 
 #define BLKTAP_INVALIDATE_HANDLE(_g) do {       \
-    (_g)->kernel = 0xFFFF; (_g)->user = 0xFFFF; \
+    (_g)->kernel = INVALID_GRANT_HANDLE; (_g)->user = INVALID_GRANT_HANDLE; \
     } while(0)
 
 
@@ -588,8 +591,6 @@ static int blktap_mmap(struct file *filp
        info->user_vstart  = info->rings_vstart + (RING_PAGES << PAGE_SHIFT);
     
        /* Map the ring pages to the start of the region and reserve it. */
-       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
        if (remap_pfn_range(vma, vma->vm_start, 
                            __pa(info->ufe_ring.sring) >> PAGE_SHIFT, 
                            PAGE_SIZE, vma->vm_page_prot)) {
@@ -892,14 +893,14 @@ static void fast_flush_area(pending_req_
 
                khandle = &pending_handle(mmap_idx, k_idx, i);
 
-               if (khandle->kernel != 0xFFFF) {
+               if (khandle->kernel != INVALID_GRANT_HANDLE) {
                        gnttab_set_unmap_op(&unmap[invcount],
                                            idx_to_kaddr(mmap_idx, k_idx, i),
                                            GNTMAP_host_map, khandle->kernel);
                        invcount++;
                }
 
-               if (khandle->user != 0xFFFF) {
+               if (khandle->user != INVALID_GRANT_HANDLE) {
                        if (create_lookup_pte_addr(
                                info->vma->vm_mm,
                                MMAP_VADDR(info->user_vstart, u_idx, i),
@@ -1186,8 +1187,10 @@ static void dispatch_rw_block_io(blkif_t
 
        /* Check we have space on user ring - should never fail. */
        usr_idx = GET_NEXT_REQ(info->idx_map);
-       if (usr_idx == INVALID_REQ)
+       if (usr_idx == INVALID_REQ) {
+               BUG();
                goto fail_response;
+       }
 
        /* Check that number of segments is sane. */
        nseg = req->nr_segments;
@@ -1221,14 +1224,12 @@ static void dispatch_rw_block_io(blkif_t
                unsigned long uvaddr;
                unsigned long kvaddr;
                uint64_t ptep;
-               struct page *page;
                uint32_t flags;
 
                uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i);
                kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
-               page = virt_to_page(kvaddr);
-
-               sector = req->sector_number + (8*i);
+
+               sector = req->sector_number + ((PAGE_SIZE / 512) * i);
                if( (blkif->sectors > 0) && (sector >= blkif->sectors) ) {
                        WPRINTK("BLKTAP: Sector request greater" 
                               "than size\n");
@@ -1238,7 +1239,7 @@ static void dispatch_rw_block_io(blkif_t
                                BLKIF_OP_WRITE ? "WRITE" : "READ"),
                                (long long unsigned) sector,
                                (long long unsigned) sector>>9,
-                               blkif->sectors);
+                               (long long unsigned) blkif->sectors);
                }
 
                flags = GNTMAP_host_map;
@@ -1281,14 +1282,14 @@ static void dispatch_rw_block_io(blkif_t
                        WPRINTK("invalid kernel buffer -- "
                                "could not remap it\n");
                        ret |= 1;
-                       map[i].handle = 0xFFFF;
+                       map[i].handle = INVALID_GRANT_HANDLE;
                }
 
                if (unlikely(map[i+1].status != 0)) {
                        WPRINTK("invalid user buffer -- "
                                "could not remap it\n");
                        ret |= 1;
-                       map[i+1].handle = 0xFFFF;
+                       map[i+1].handle = INVALID_GRANT_HANDLE;
                }
 
                pending_handle(mmap_idx, pending_idx, i/2).kernel 
diff -r 6f3c40ee2488 -r 862aca401601 
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Tue Nov 07 10:48:48 
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Tue Nov 07 11:01:35 
2006 +0000
@@ -189,7 +189,7 @@ static int blktap_probe(struct xenbus_de
        return 0;
 
 fail:
-       DPRINTK("blktap probe failed");
+       DPRINTK("blktap probe failed\n");
        blktap_remove(dev);
        return err;
 }
@@ -243,7 +243,7 @@ static void tap_frontend_changed(struct 
        struct backend_info *be = dev->dev.driver_data;
        int err;
 
-       DPRINTK("");
+       DPRINTK("\n");
 
        switch (frontend_state) {
        case XenbusStateInitialising:
@@ -318,7 +318,7 @@ static int connect_ring(struct backend_i
        unsigned int evtchn;
        int err;
 
-       DPRINTK("%s", dev->otherend);
+       DPRINTK("%s\n", dev->otherend);
 
        err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu", 
                            &ring_ref, "event-channel", "%u", &evtchn, NULL);
diff -r 6f3c40ee2488 -r 862aca401601 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Tue Nov 07 10:48:48 2006 +0000
+++ b/tools/blktap/drivers/blktapctrl.c Tue Nov 07 11:01:35 2006 +0000
@@ -607,9 +607,11 @@ int main(int argc, char *argv[])
        struct xs_handle *h;
        struct pollfd  pfd[NUM_POLL_FDS];
        pid_t process;
+       char buf[128];
 
        __init_blkif();
-       openlog("BLKTAPCTRL", LOG_CONS|LOG_ODELAY, LOG_DAEMON);
+       snprintf(buf, sizeof(buf), "BLKTAPCTRL[%d]", getpid());
+       openlog(buf, LOG_CONS|LOG_ODELAY, LOG_DAEMON);
        daemon(0,0);
 
        print_drivers();
diff -r 6f3c40ee2488 -r 862aca401601 tools/blktap/drivers/tapdisk.c
--- a/tools/blktap/drivers/tapdisk.c    Tue Nov 07 10:48:48 2006 +0000
+++ b/tools/blktap/drivers/tapdisk.c    Tue Nov 07 11:01:35 2006 +0000
@@ -562,12 +562,14 @@ int main(int argc, char *argv[])
        fd_list_entry_t *ptr;
        struct tap_disk *drv;
        struct td_state *s;
+       char openlogbuf[128];
        
        if (argc != 3) usage();
 
        daemonize();
 
-       openlog("TAPDISK", LOG_CONS|LOG_ODELAY, LOG_DAEMON);
+       snprintf(openlogbuf, sizeof(openlogbuf), "TAPDISK[%d]", getpid());
+       openlog(openlogbuf, LOG_CONS|LOG_ODELAY, LOG_DAEMON);
        /*Setup signal handlers*/
        signal (SIGBUS, sig_handler);
        signal (SIGINT, sig_handler);
diff -r 6f3c40ee2488 -r 862aca401601 tools/blktap/drivers/tapdisk.h
--- a/tools/blktap/drivers/tapdisk.h    Tue Nov 07 10:48:48 2006 +0000
+++ b/tools/blktap/drivers/tapdisk.h    Tue Nov 07 11:01:35 2006 +0000
@@ -61,7 +61,6 @@
 
 /* Things disks need to know about, these should probably be in a higher-level
  * header. */
-#define MAX_REQUESTS            64
 #define MAX_SEGMENTS_PER_REQ    11
 #define SECTOR_SHIFT             9
 #define DEFAULT_SECTOR_SIZE    512
diff -r 6f3c40ee2488 -r 862aca401601 tools/blktap/lib/blktaplib.h
--- a/tools/blktap/lib/blktaplib.h      Tue Nov 07 10:48:48 2006 +0000
+++ b/tools/blktap/lib/blktaplib.h      Tue Nov 07 11:01:35 2006 +0000
@@ -41,7 +41,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, getpagesize())
+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, XC_PAGE_SIZE)
 
 /* size of the extra VMA area to map in attached pages. */
 #define BLKTAP_VMA_PAGES BLK_RING_SIZE
@@ -74,10 +74,10 @@ static inline int BLKTAP_MODE_VALID(unsi
                ( arg == BLKTAP_MODE_INTERPOSE    ) );
 }
 
-#define MAX_REQUESTS            64
+#define MAX_REQUESTS            BLK_RING_SIZE
 
 #define BLKTAP_IOCTL_KICK 1
-#define MAX_PENDING_REQS 64
+#define MAX_PENDING_REQS       BLK_RING_SIZE
 #define BLKTAP_DEV_DIR   "/dev/xen"
 #define BLKTAP_DEV_NAME  "blktap"
 #define BLKTAP_DEV_MINOR 0
@@ -199,7 +199,6 @@ int xs_fire_next_watch(struct xs_handle 
 
 
 /* Abitrary values, must match the underlying driver... */
-#define MAX_PENDING_REQS 64
 #define MAX_TAP_DEV 100
 
 /* Accessing attached data page mappings */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [BLKTAP] Various cleanups necessary for ia64 support., Xen patchbot-unstable <=