[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Incremental fixes to plx stuff.



ChangeSet 1.1311.8.1, 2005/03/21 19:57:02+00:00, akw27@xxxxxxxxxxxxxxxxxxxxxx

        Incremental fixes to plx stuff.
        
        Signed-off-by: andrew.warfield@xxxxxxxxxxxx



 Makefile            |   33 ++
 blktaplib.c         |   24 +
 blockstore-tls.c    |  161 ++++++++++++
 blockstore.c        |  218 ++++++++++++++++-
 blockstore.h        |   26 ++
 parallax-threaded.c |  654 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 parallax-threaded.h |   23 +
 parallax.c          |    6 
 radix.c             |  125 ++++++++-
 radix.h             |    1 
 snaplog.c           |   64 +++++
 snaplog.h           |   11 
 vdi.c               |    5 
 vdi_snap_delete.c   |   48 +++
 vdi_snap_list.c     |   13 -
 15 files changed, 1352 insertions(+), 60 deletions(-)


diff -Nru a/tools/blktap/Makefile b/tools/blktap/Makefile
--- a/tools/blktap/Makefile     2005-03-22 05:03:11 -05:00
+++ b/tools/blktap/Makefile     2005-03-22 05:03:11 -05:00
@@ -21,8 +21,12 @@
 PLX_SRCS := 
 PLX_SRCS += vdi.c 
 PLX_SRCS += radix.c 
-PLX_SRCS += blockstore.c 
 PLX_SRCS += snaplog.c
+PLXT_SRCS := $(PLX_SRCS)
+#PLXT_SRCS += blockstore-tls.c
+PLXT_SRCS += blockstore.c
+PLXT_SRCS += parallax-threaded.c
+PLX_SRCS += blockstore.c 
 VDI_SRCS := $(PLX_SRCS)
 PLX_SRCS += parallax.c
 
@@ -31,6 +35,7 @@
 VDI_TOOLS += vdi_list
 VDI_TOOLS += vdi_snap
 VDI_TOOLS += vdi_snap_list
+VDI_TOOLS += vdi_snap_delete
 VDI_TOOLS += vdi_fill
 VDI_TOOLS += vdi_tree
 VDI_TOOLS += vdi_validate
@@ -91,7 +96,7 @@
 libblktap.so.$(MAJOR):
        ln -sf libblktap.so.$(MAJOR).$(MINOR) $@
 libblktap.so.$(MAJOR).$(MINOR): $(OBJS)
-       $(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -L../libxutil -lxutil 
-lz
+       $(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -lpthread 
-L../libxutil -lxutil -lz
 
 blkdump: $(LIB)
        $(CC) $(CFLAGS) -o blkdump -L$(XEN_LIBXC) -L$(XEN_LIBXUTIL) -L. -l 
blktap blkdump.c
@@ -117,6 +122,9 @@
 parallax: $(LIB) $(PLX_SRCS)
        $(CC) $(CFLAGS) -o parallax -L$(XEN_LIBXC) -L$(XEN_LIBXUTIL) -L. 
-lblktap $(PLX_SRCS) libgnbd/libgnbd.a
 
+parallax-threaded: $(LIB) $(PLXT_SRCS)
+       $(CC) $(CFLAGS) -o parallax-threaded -L$(XEN_LIBXC) -L$(XEN_LIBXUTIL) 
-L. -lpthread -lblktap $(PLXT_SRCS) libgnbd/libgnbd.a
+
 vdi_test: $(LIB) $(VDI_SRCS)
        $(CC) $(CFLAGS) -g3 -o vdi_test -DVDI_STANDALONE $(VDI_SRCS)
 
@@ -132,6 +140,9 @@
 vdi_snap_list: $(LIB) vdi_snap_list.c $(VDI_SRCS)
        $(CC) $(CFLAGS) -g3 -o vdi_snap_list vdi_snap_list.c $(VDI_SRCS)
 
+vdi_snap_delete: $(LIB) vdi_snap_delete.c $(VDI_SRCS)
+       $(CC) $(CFLAGS) -g3 -o vdi_snap_delete vdi_snap_delete.c $(VDI_SRCS)
+
 vdi_tree: $(LIB) vdi_tree.c $(VDI_SRCS)
        $(CC) $(CFLAGS) -g3 -o vdi_tree vdi_tree.c $(VDI_SRCS)
 
@@ -142,12 +153,22 @@
        $(CC) $(CFLAGS) -g3 -o vdi_validate vdi_validate.c $(VDI_SRCS)
 
 
-rdx_cmp: $(LIB) rdx_cmp.c $(VDI_SRCS)
-       $(CC) $(CFLAGS) -g3 -o rdx_cmp rdx_cmp.c $(VDI_SRCS)
-
-
 .PHONY: TAGS clean install mk-symlinks rpm
 TAGS:
        etags -t $(SRCS) *.h
 
 -include $(DEPS)
+
+#Random testing targets.  To be removed eventually.
+
+rdx_cmp: $(LIB) rdx_cmp.c $(VDI_SRCS)
+       $(CC) $(CFLAGS) -g3 -o rdx_cmp rdx_cmp.c $(VDI_SRCS)
+
+bb-tls: $(LIB) blockstore-benchmark.c
+       $(CC) $(CFLAGS) -o bb-tls blockstore-benchmark.c blockstore-tls.c 
-lpthread
+
+bb-trans: $(LIB) blockstore-benchmark.c
+       $(CC) $(CFLAGS) -o bb-trans blockstore-benchmark.c blockstore.c 
-lpthread
+
+radix-test: $(LIB) radix.c blockstore-threaded-trans.c
+       $(CC) $(CFLAGS) -g3 -D RADIX_STANDALONE -o radix-test radix.c 
blockstore-threaded-trans.c
diff -Nru a/tools/blktap/blktaplib.c b/tools/blktap/blktaplib.c
--- a/tools/blktap/blktaplib.c  2005-03-22 05:03:11 -05:00
+++ b/tools/blktap/blktaplib.c  2005-03-22 05:03:11 -05:00
@@ -3,6 +3,8 @@
  * 
  * userspace interface routines for the blktap driver.
  *
+ * (threadsafe(r) version) 
+ *
  * (c) 2004 Andrew Warfield.
  */
 
@@ -21,11 +23,13 @@
 #include <sys/ioctl.h>
 #include <string.h>
 #include <unistd.h>
+#include <pthread.h>
+
                                                                      
 #define __COMPILING_BLKTAP_LIB
 #include "blktaplib.h"
 
-#if 1
+#if 0
 #define DPRINTF(_f, _a...) printf ( _f , ## _a )
 #else
 #define DPRINTF(_f, _a...) ((void)0)
@@ -194,15 +198,19 @@
         
 /*-----[ Data to/from Backend (server) VM ]------------------------------*/
 
+
+
 inline int write_req_to_be_ring(blkif_request_t *req)
 {
     blkif_request_t *req_d;
+    static pthread_mutex_t be_prod_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-    //req_d = FRONT_RING_NEXT_EMPTY_REQUEST(&be_ring);
+    pthread_mutex_lock(&be_prod_mutex);
     req_d = RING_GET_REQUEST(&be_ring, be_ring.req_prod_pvt);
     memcpy(req_d, req, sizeof(blkif_request_t));
     wmb();
     be_ring.req_prod_pvt++;
+    pthread_mutex_unlock(&be_prod_mutex);
     
     return 0;
 }
@@ -210,12 +218,14 @@
 inline int write_rsp_to_fe_ring(blkif_response_t *rsp)
 {
     blkif_response_t *rsp_d;
+    static pthread_mutex_t fe_prod_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-    //rsp_d = BACK_RING_NEXT_EMPTY_RESPONSE(&fe_ring);
+    pthread_mutex_lock(&fe_prod_mutex);
     rsp_d = RING_GET_RESPONSE(&fe_ring, fe_ring.rsp_prod_pvt);
     memcpy(rsp_d, rsp, sizeof(blkif_response_t));
     wmb();
     fe_ring.rsp_prod_pvt++;
+    pthread_mutex_unlock(&fe_prod_mutex);
 
     return 0;
 }
@@ -336,6 +346,10 @@
     ctrl_sring_t     *csring;
     RING_IDX          rp, i, pfd_count; 
     
+    /* pending rings */
+    blkif_request_t req_pending[BLKIF_RING_SIZE];
+    blkif_response_t rsp_pending[BLKIF_RING_SIZE];
+    
     /* handler hooks: */
     request_hook_t   *req_hook;
     response_hook_t  *rsp_hook;
@@ -447,6 +461,8 @@
                 int done = 0; /* stop forwarding this request */
 
                 req = RING_GET_REQUEST(&fe_ring, i);
+                memcpy(&req_pending[ID_TO_IDX(req->id)], req, sizeof(*req));
+                req = &req_pending[ID_TO_IDX(req->id)];
 
                 DPRINTF("copying an fe request\n");
 
@@ -487,6 +503,8 @@
             {
 
                 rsp = RING_GET_RESPONSE(&be_ring, i);
+                memcpy(&rsp_pending[ID_TO_IDX(rsp->id)], rsp, sizeof(*rsp));
+                rsp = &rsp_pending[ID_TO_IDX(rsp->id)];
 
                 DPRINTF("copying a be request\n");
 
diff -Nru a/tools/blktap/blockstore-tls.c b/tools/blktap/blockstore-tls.c
--- /dev/null   Wed Dec 31 16:00:00 196900
+++ b/tools/blktap/blockstore-tls.c     2005-03-22 05:03:11 -05:00
@@ -0,0 +1,161 @@
+/**************************************************************************
+ * 
+ * blockstore.c
+ *
+ * Simple block store interface
+ *
+ */
+ 
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "blockstore.h"
+#include "parallax-threaded.h"
+
+/*static int block_fp = -1;*/
+ 
+static int fd_list[READ_POOL_SIZE+1];
+ 
+/**
+ * readblock: read a block from disk
+ *   @id: block id to read
+ *
+ *   @return: pointer to block, NULL on error
+ */
+
+void *readblock(u64 id) 
+{
+    void *block;
+    int tid = (int)pthread_getspecific(tid_key);
+    
+    if (lseek64(fd_list[tid], ((off64_t) id - 1LL) * BLOCK_SIZE, SEEK_SET) < 
0) {
+        printf ("%Ld\n", (id - 1) * BLOCK_SIZE);
+        perror("readblock lseek");
+        goto err;
+    }
+    if ((block = malloc(BLOCK_SIZE)) == NULL) {
+        perror("readblock malloc");
+        goto err;
+    }
+    if (read(fd_list[tid], block, BLOCK_SIZE) != BLOCK_SIZE) {
+        perror("readblock read");
+        free(block);
+        goto err;
+    }
+    return block;
+    
+err:
+    return NULL;
+}
+
+/**
+ * writeblock: write an existing block to disk
+ *   @id: block id
+ *   @block: pointer to block
+ *
+ *   @return: zero on success, -1 on failure
+ */
+int writeblock(u64 id, void *block) 
+{
+    int tid = (int)pthread_getspecific(tid_key);
+    
+    if (lseek64(fd_list[tid], ((off64_t) id - 1LL) * BLOCK_SIZE, SEEK_SET) < 
0) {
+        perror("writeblock lseek");
+        goto err;
+    }
+    if (write(fd_list[tid], block, BLOCK_SIZE) < 0) {
+        perror("writeblock write");


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.