ia64/xen-unstable

changeset 17900:8fa124ab2e71

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@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 20 17:45:23 2008 +0100 (2008-06-20)
parents 2483923066dd
children 00af74d06652
files extras/mini-os/fs-front.c extras/mini-os/netfront.c
line diff
     1.1 --- a/extras/mini-os/fs-front.c	Fri Jun 20 17:44:50 2008 +0100
     1.2 +++ b/extras/mini-os/fs-front.c	Fri Jun 20 17:45:23 2008 +0100
     1.3 @@ -136,8 +136,8 @@ static inline void add_id_to_freelist(un
     1.4  again:    
     1.5      old_id = freelist[0];
     1.6      /* Note: temporal inconsistency, since freelist[0] can be changed by someone
     1.7 -     * else, but we are a sole owner of freelist[id], it's OK. */
     1.8 -    freelist[id] = old_id;
     1.9 +     * else, but we are a sole owner of freelist[id + 1], it's OK. */
    1.10 +    freelist[id + 1] = old_id;
    1.11      new_id = id;
    1.12      if(cmpxchg(&freelist[0], old_id, new_id) != old_id)
    1.13      {
    1.14 @@ -154,7 +154,7 @@ static inline unsigned short get_id_from
    1.15  
    1.16  again:    
    1.17      old_id = freelist[0];
    1.18 -    new_id = freelist[old_id];
    1.19 +    new_id = freelist[old_id + 1];
    1.20      if(cmpxchg(&freelist[0], old_id, new_id) != old_id)
    1.21      {
    1.22          printk("Cmpxchg on freelist remove failed.\n");
    1.23 @@ -785,8 +785,8 @@ static void alloc_request_table(struct f
    1.24      printk("Allocating request array for import %d, nr_entries = %d.\n",
    1.25              import->import_id, import->nr_entries);
    1.26      requests = xmalloc_array(struct fs_request, import->nr_entries);
    1.27 -    import->freelist = xmalloc_array(unsigned short, import->nr_entries);
    1.28 -    memset(import->freelist, 0, sizeof(unsigned short) * import->nr_entries);
    1.29 +    import->freelist = xmalloc_array(unsigned short, import->nr_entries + 1);
    1.30 +    memset(import->freelist, 0, sizeof(unsigned short) * (import->nr_entries + 1));
    1.31      for(i=0; i<import->nr_entries; i++)
    1.32      {
    1.33  	/* TODO: that's a lot of memory */
     2.1 --- a/extras/mini-os/netfront.c	Fri Jun 20 17:44:50 2008 +0100
     2.2 +++ b/extras/mini-os/netfront.c	Fri Jun 20 17:45:23 2008 +0100
     2.3 @@ -38,7 +38,7 @@ struct net_buffer {
     2.4  struct netfront_dev {
     2.5      domid_t dom;
     2.6  
     2.7 -    unsigned short tx_freelist[NET_TX_RING_SIZE];
     2.8 +    unsigned short tx_freelist[NET_TX_RING_SIZE + 1];
     2.9      struct semaphore tx_sem;
    2.10  
    2.11      struct net_buffer rx_buffers[NET_RX_RING_SIZE];
    2.12 @@ -70,14 +70,14 @@ void init_rx_buffers(struct netfront_dev
    2.13  
    2.14  static inline void add_id_to_freelist(unsigned int id,unsigned short* freelist)
    2.15  {
    2.16 -    freelist[id] = freelist[0];
    2.17 +    freelist[id + 1] = freelist[0];
    2.18      freelist[0]  = id;
    2.19  }
    2.20  
    2.21  static inline unsigned short get_id_from_freelist(unsigned short* freelist)
    2.22  {
    2.23      unsigned int id = freelist[0];
    2.24 -    freelist[0] = freelist[id];
    2.25 +    freelist[0] = freelist[id + 1];
    2.26      return id;
    2.27  }
    2.28