ia64/xen-unstable

changeset 18065:5f529c74a712

fs-backend: Fix freelist implementation

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 15 17:59:31 2008 +0100 (2008-07-15)
parents b38bceff087a
children ea6a9793928d
files tools/fs-back/fs-backend.c tools/fs-back/fs-backend.h
line diff
     1.1 --- a/tools/fs-back/fs-backend.c	Tue Jul 15 17:58:39 2008 +0100
     1.2 +++ b/tools/fs-back/fs-backend.c	Tue Jul 15 17:59:31 2008 +0100
     1.3 @@ -110,9 +110,9 @@ void allocate_request_array(struct mount
     1.4      unsigned short *freelist;
     1.5      
     1.6      requests = malloc(sizeof(struct fs_request) *nr_entries);
     1.7 -    freelist = malloc(sizeof(unsigned short) * nr_entries); 
     1.8 +    freelist = malloc(sizeof(unsigned short) * (nr_entries + 1)); 
     1.9      memset(requests, 0, sizeof(struct fs_request) * nr_entries);
    1.10 -    memset(freelist, 0, sizeof(unsigned short) * nr_entries);
    1.11 +    memset(freelist, 0, sizeof(unsigned short) * (nr_entries + 1));
    1.12      for(i=0; i< nr_entries; i++)
    1.13      {
    1.14          requests[i].active = 0; 
     2.1 --- a/tools/fs-back/fs-backend.h	Tue Jul 15 17:58:39 2008 +0100
     2.2 +++ b/tools/fs-back/fs-backend.h	Tue Jul 15 17:59:31 2008 +0100
     2.3 @@ -72,14 +72,14 @@ extern struct fs_op *fsops[];
     2.4  
     2.5  static inline void add_id_to_freelist(unsigned int id,unsigned short* freelist)
     2.6  {
     2.7 -    freelist[id] = freelist[0];
     2.8 +    freelist[id + 1] = freelist[0];
     2.9      freelist[0]  = id;
    2.10  }
    2.11  
    2.12  static inline unsigned short get_id_from_freelist(unsigned short* freelist)
    2.13  {
    2.14      unsigned int id = freelist[0];
    2.15 -    freelist[0] = freelist[id];
    2.16 +    freelist[0] = freelist[id + 1];
    2.17      return id;
    2.18  }
    2.19