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-devel

[Xen-devel] [PATCH] minios: fix add_id_to_freelist(0)

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] minios: fix add_id_to_freelist(0)
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Wed, 18 Jun 2008 12:29:10 +0100
Delivery-date: Wed, 18 Jun 2008 04:29:35 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
minios: fix add_id_to_freelist(0)

add_id_to_freelist(0) would make get_id_from_freelist() always return 0.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r 78f90b0f707f extras/mini-os/fs-front.c
--- a/extras/mini-os/fs-front.c Tue Jun 17 14:45:18 2008 +0100
+++ b/extras/mini-os/fs-front.c Wed Jun 18 12:23:59 2008 +0100
@@ -136,8 +136,8 @@
 again:    
     old_id = freelist[0];
     /* Note: temporal inconsistency, since freelist[0] can be changed by 
someone
-     * else, but we are a sole owner of freelist[id], it's OK. */
-    freelist[id] = old_id;
+     * else, but we are a sole owner of freelist[id + 1], it's OK. */
+    freelist[id + 1] = old_id;
     new_id = id;
     if(cmpxchg(&freelist[0], old_id, new_id) != old_id)
     {
@@ -154,7 +154,7 @@
 
 again:    
     old_id = freelist[0];
-    new_id = freelist[old_id];
+    new_id = freelist[old_id + 1];
     if(cmpxchg(&freelist[0], old_id, new_id) != old_id)
     {
         printk("Cmpxchg on freelist remove failed.\n");
@@ -785,8 +785,8 @@
     printk("Allocating request array for import %d, nr_entries = %d.\n",
             import->import_id, import->nr_entries);
     requests = xmalloc_array(struct fs_request, import->nr_entries);
-    import->freelist = xmalloc_array(unsigned short, import->nr_entries);
-    memset(import->freelist, 0, sizeof(unsigned short) * import->nr_entries);
+    import->freelist = xmalloc_array(unsigned short, import->nr_entries + 1);
+    memset(import->freelist, 0, sizeof(unsigned short) * (import->nr_entries + 
1));
     for(i=0; i<import->nr_entries; i++)
     {
        /* TODO: that's a lot of memory */
diff -r 78f90b0f707f extras/mini-os/netfront.c
--- a/extras/mini-os/netfront.c Tue Jun 17 14:45:18 2008 +0100
+++ b/extras/mini-os/netfront.c Wed Jun 18 12:25:47 2008 +0100
@@ -38,7 +38,7 @@
 struct netfront_dev {
     domid_t dom;
 
-    unsigned short tx_freelist[NET_TX_RING_SIZE];
+    unsigned short tx_freelist[NET_TX_RING_SIZE + 1];
     struct semaphore tx_sem;
 
     struct net_buffer rx_buffers[NET_RX_RING_SIZE];
@@ -70,14 +70,14 @@
 
 static inline void add_id_to_freelist(unsigned int id,unsigned short* freelist)
 {
-    freelist[id] = freelist[0];
+    freelist[id + 1] = freelist[0];
     freelist[0]  = id;
 }
 
 static inline unsigned short get_id_from_freelist(unsigned short* freelist)
 {
     unsigned int id = freelist[0];
-    freelist[0] = freelist[id];
+    freelist[0] = freelist[id + 1];
     return id;
 }
 

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

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