Changeset 520 for packages/main

Show
Ignore:
Timestamp:
24/06/2008 10:18:55 (2 months ago)
Author:
nextime
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • packages/main/cloop/tags/venus/compressed_loop.c

    r487 r520  
    2121 
    2222#define CLOOP_NAME "cloop" 
    23 #define CLOOP_VERSION "2.624
     23#define CLOOP_VERSION "2.625
    2424#define CLOOP_MAX 8 
    2525 
     
    125125 void *buffer[BUFFERED_BLOCKS]; 
    126126 void *compressed_buffer; 
     127 size_t preload_size; 
    127128 void *preload_cache; 
    128129 
     
    132133 struct inode  *backing_inode; /* for bmap */ 
    133134 
     135 unsigned long largest_block; 
    134136 unsigned int underlying_blksize; 
    135137 int clo_number; 
     
    157159#endif 
    158160 
     161/* Use __get_free_pages instead of vmalloc, allows up to 32 pages, 
     162 * 2MB in one piece */ 
     163static void *cloop_malloc(size_t size) 
     164{ 
     165 return (void *)__get_free_pages(GFP_KERNEL, get_order(size)); 
     166} 
     167 
     168static void cloop_free(void *mem, size_t size) 
     169{ 
     170 free_pages((unsigned long)mem, get_order(size)); 
     171} 
     172 
    159173static int uncompress(struct cloop_device *clo, 
    160174                      unsigned char *dest, unsigned long *destLen, 
     
    179193} 
    180194 
    181 /* This is more complicated than it looks. */ 
    182 struct cloop_read_data 
    183 { 
    184  struct cloop_device *clo; 
    185  char *data; /* We need to keep track of where we are in the buffer */ 
    186  int bsize; 
    187 }; 
    188  
    189 /* We need this for do_generic_file_read() because the default function */ 
    190 /* wants to read into user-space for an unknown reason. :-/ See loop.c. */ 
    191 static int cloop_read_actor(read_descriptor_t * desc, struct page *page, 
    192                           unsigned long offset, unsigned long size) 
    193 { 
    194  unsigned long count = desc->count; 
    195  struct cloop_read_data *p = (struct cloop_read_data*)desc->arg.data; 
    196  char *kaddr_page; 
    197  if (size > count) size = count; 
    198  kaddr_page = kmap(page); 
    199  memcpy(p->data, kaddr_page + offset, size); 
    200  kunmap(page); 
    201  desc->count = count - size; 
    202  desc->written += size; 
    203  p->data += size; 
    204  return size; 
    205 } 
    206  
    207195static size_t cloop_read_from_file(struct cloop_device *clo, struct file *f, char *buf, 
    208196  loff_t pos, size_t buf_len) 
     
    212200  { 
    213201   size_t size = buf_len - buf_done; 
    214    struct cloop_read_data cd={ /* do_generic_file_read() needs this. */ 
    215            clo,              /* struct cloop_device *clo */ 
    216            (char *)(buf + buf_done), /* char *data */ 
    217            size};            /* Actual data size */ 
    218    read_descriptor_t desc; 
    219    desc.written = 0; 
    220    desc.count   = size; 
    221    desc.arg.data = (char*)&cd; 
    222    desc.error   = 0; 
    223 #ifdef REDHAT_KERNEL /* Greenshoe Linux */ 
    224    do_generic_file_read(f, &pos, &desc, cloop_read_actor, 0); 
    225 #else /* Normal Kernel */ 
    226    do_generic_file_read(f, &pos, &desc, cloop_read_actor); 
    227 #endif 
    228    if(desc.error||desc.written<=0) 
    229     { 
    230      int left = size - desc.written; 
     202   size_t size_read = do_sync_read(f, buf +  buf_done, size, &pos); 
     203   if(size_read <= 0) 
     204    { 
     205     size_t left = size - size_read; 
    231206     if(left<0) left = 0; /* better safe than sorry */ 
    232207     printk(KERN_ERR "%s: Read error at pos %Lu in file %s, " 
     
    235210     break; 
    236211    } 
    237    buf_done += desc.written
     212   buf_done += size_read
    238213  } 
    239214 return buf_done; 
    240215} 
    241  
    242216 
    243217/* This looks more complicated than it is */ 
     
    301275 int buffered_blocknum = -1; 
    302276 int preloaded = 0; 
    303  struct bio *bio; 
    304277 loff_t offset     = (loff_t) req->sector<<9; 
    305278#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)  /* New kernel */ 
     
    352325  } /* end rq_for_each_segment*/ 
    353326#else /* Old Kernel */ 
     327 struct bio *bio; 
    354328 rq_for_each_bio(bio, req) 
    355329  { 
     
    426400    { 
    427401     int uptodate; 
     402     unsigned long flags; 
    428403     struct request *req; 
     404     spin_lock_irqsave(&clo->queue_lock, flags); 
    429405     req = list_entry(p, struct request, queuelist); 
    430      spin_lock_irq(&clo->queue_lock); 
    431406     list_del_init(&req->queuelist); 
    432      spin_unlock_irq(&clo->queue_lock); 
    433 /*     DEBUGP(KERN_ERR "cloop_handle_request(%p, %p), sector=%d, nr_sectors=%d, current_nr_sectors=%d ", clo, req, (int)req->sector, (int)req->nr_sectors, (int)req->current_nr_sectors); */ 
     407     spin_unlock_irqrestore(&clo->queue_lock, flags); 
    434408     uptodate = cloop_handle_request(clo, req); 
    435 /*     DEBUGP(KERN_ERR "cloop_handle_request done, uptodate=%d\n", uptodate); */ 
    436      spin_lock_irq(&clo->queue_lock); 
     409     spin_lock_irqsave(&clo->queue_lock, flags); 
     410#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)  /* New kernel */ 
     411     __blk_end_request(req, uptodate ? 0 : -EIO, req->nr_sectors << 9); 
     412#else 
    437413     if(!end_that_request_first(req, uptodate, req->nr_sectors)) 
    438414       end_that_request_last(req, uptodate); 
    439      spin_unlock_irq(&clo->queue_lock); 
     415#endif 
     416     spin_unlock_irqrestore(&clo->queue_lock, flags); 
    440417    } 
     418#if 0 
    441419   spin_lock_irq(&clo->queue_lock); 
    442420   blk_start_queue(clo->clo_queue); 
    443421   spin_unlock_irq(&clo->queue_lock); 
     422#endif 
    444423  } 
    445424 DEBUGP(KERN_ERR "cloop_thread exited.\n"); 
     
    476455    } 
    477456   blkdev_dequeue_request(req); /* Dequeue request first. */ 
     457#if 0 
    478458   blk_stop_queue(q);           /* Stop queue processing */ 
     459#endif 
    479460   list_add(&req->queuelist, &clo->clo_list); /* Add to working list for thread */ 
    480461   count++; 
     
    484465   DEBUGP(KERN_ERR "cloop_do_request: Discarding request %p.\n", req); 
    485466   req->errors++; 
     467#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)  /* New kernel */ 
     468   __blk_end_request(req, -EIO, req->nr_sectors << 9); 
     469#else 
    486470   end_request(req, 0); /* Discard */ 
     471#endif 
    487472  } 
    488473} 
     
    495480 char *bbuf=NULL; 
    496481 unsigned int i, offsets_read, total_offsets; 
    497  unsigned long largest_block=0; 
    498482 int isblkdev; 
    499483 int error = 0; 
     
    532516   clo->underlying_blksize = PAGE_SIZE; 
    533517 DEBUGP("Underlying blocksize is %u\n", clo->underlying_blksize); 
    534  bbuf = vmalloc(clo->underlying_blksize); 
     518 bbuf = cloop_malloc(clo->underlying_blksize); 
    535519 if(!bbuf) 
    536520  { 
     
    581565       error=-EBADF; goto error_release; 
    582566      } 
    583      clo->offsets = vmalloc(sizeof(loff_t) * total_offsets); 
     567     clo->offsets = cloop_malloc(sizeof(loff_t) * total_offsets); 
    584568     if (!clo->offsets) 
    585569      { 
     
    599583    { 
    600584     loff_t d=be64_to_cpu(clo->offsets[i+1]) - be64_to_cpu(clo->offsets[i]); 
    601      largest_block=MAX(largest_block,d); 
     585     clo->largest_block=MAX(clo->largest_block,d); 
    602586    } 
    603587   printk(KERN_INFO "%s: %s: %u blocks, %u bytes/block, largest block is %lu bytes.\n", 
    604588          cloop_name, filename, ntohl(clo->head.num_blocks), 
    605           ntohl(clo->head.block_size), largest_block); 
     589          ntohl(clo->head.block_size), clo->largest_block); 
    606590  } 
    607591/* Combo kmalloc used too large chunks (>130000). */ 
     
    610594  for(i=0;i<BUFFERED_BLOCKS;i++) 
    611595   { 
    612     clo->buffer[i] = vmalloc(ntohl(clo->head.block_size)); 
     596    clo->buffer[i] = cloop_malloc(ntohl(clo->head.block_size)); 
    613597    if(!clo->buffer[i]) 
    614598     { 
     
    619603   } 
    620604 } 
    621  clo->compressed_buffer = vmalloc(largest_block); 
     605 clo->compressed_buffer = cloop_malloc(clo->largest_block); 
    622606 if(!clo->compressed_buffer) 
    623607  { 
    624608   printk(KERN_ERR "%s: out of memory for compressed buffer %lu\n", 
    625           cloop_name, largest_block); 
     609          cloop_name, clo->largest_block); 
    626610   error=-ENOMEM; goto error_release_free_buffer; 
    627611  } 
    628  clo->zstream.workspace = vmalloc(zlib_inflate_workspacesize()); 
     612 clo->zstream.workspace = cloop_malloc(zlib_inflate_workspacesize()); 
    629613 if(!clo->zstream.workspace) 
    630614  { 
     
    641625          be64_to_cpu(clo->offsets[ntohl(clo->head.num_blocks)]), 
    642626          inode->i_size); 
    643    vfree(clo->zstream.workspace); clo->zstream.workspace=NULL; 
     627   cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); clo->zstream.workspace=NULL; 
    644628   goto error_release_free_all; 
    645629  } 
     
    660644 if(preload > 0) 
    661645  { 
    662    size_t preload_size = ((preload<=ntohl(clo->head.num_blocks))?preload:ntohl(clo->head.num_blocks)) 
     646   clo->preload_size = ((preload<=ntohl(clo->head.num_blocks))?preload:ntohl(clo->head.num_blocks)) 
    663647                          * ntohl(clo->head.block_size); 
    664    if((clo->preload_cache = vmalloc(preload_size)) != NULL) 
     648   if((clo->preload_cache = cloop_malloc(clo->preload_size)) != NULL) 
    665649    { 
    666650     int i; 
     
    675659        { 
    676660         printk(KERN_WARNING "%s: can't read block %d into preload cache, ignored.\n", cloop_name, i); 
    677          vfree(clo->preload_cache); 
     661         cloop_free(clo->preload_cache, clo->preload_size); 
    678662         clo->preload_cache = NULL; 
    679663         break; 
     
    687671 return error; 
    688672error_release_free_all: 
    689  vfree(clo->compressed_buffer); 
     673 cloop_free(clo->compressed_buffer, clo->largest_block); 
    690674 clo->compressed_buffer=NULL; 
    691675error_release_free_buffer: 
     
    696680    if(clo->buffer[i]) 
    697681     { 
    698       vfree(clo->buffer[i]); 
     682      cloop_free(clo->buffer[i], ntohl(clo->head.block_size)); 
    699683      clo->buffer[i]=NULL; 
    700684     } 
     
    702686 } 
    703687error_release_free: 
    704  vfree(clo->offsets); 
     688 cloop_free(clo->offsets, sizeof(loff_t) * total_offsets); 
    705689 clo->offsets=NULL; 
    706690error_release: 
    707  if(bbuf) vfree(bbuf); 
     691 if(bbuf) cloop_free(bbuf, clo->underlying_blksize); 
    708692 clo->backing_file=NULL; 
    709693 return error; 
     
    741725 clo->backing_file  = NULL; 
    742726 clo->backing_inode = NULL; 
    743  if(clo->offsets) { vfree(clo->offsets); clo->offsets = NULL; } 
    744  if(clo->preload_cache) { vfree(clo->preload_cache); clo->preload_cache = NULL; } 
     727 if(clo->offsets) { cloop_free(clo->offsets, clo->underlying_blksize); clo->offsets = NULL; } 
     728 if(clo->preload_cache) { cloop_free(clo->preload_cache, clo->preload_size); clo->preload_cache = NULL; } 
    745729 for(i=0; i<BUFFERED_BLOCKS; i++) 
    746       if(clo->buffer[i]) { vfree(clo->buffer[i]); clo->buffer[i]=NULL; } 
    747  if(clo->compressed_buffer) { vfree(clo->compressed_buffer); clo->compressed_buffer = NULL; } 
     730      if(clo->buffer[i]) { cloop_free(clo->buffer[i], ntohl(clo->head.block_size)); clo->buffer[i]=NULL; } 
     731 if(clo->compressed_buffer) { cloop_free(clo->compressed_buffer, clo->largest_block); clo->compressed_buffer = NULL; } 
    748732 zlib_inflateEnd(&clo->zstream); 
    749  if(clo->zstream.workspace) { vfree(clo->zstream.workspace); clo->zstream.workspace = NULL; } 
     733 if(clo->zstream.workspace) { cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); clo->zstream.workspace = NULL; } 
    750734#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) 
    751735 if(bdev) invalidate_bdev(bdev, 0); 
  • packages/main/cloop/tags/venus/debian/changelog

    r489 r520  
     1cloop (2.625.venus-1) stable; urgency=low 
     2 
     3  * Fix build issue with kernel 2.6.25 
     4 
     5 -- Unixmedia S.r.l. (Medianix Devel) <devel@unixmedia.it>  Tue, 24 Jun 2008 10:18:31 +0200 
     6 
    17cloop (2.624.venus-1) stable; urgency=low 
    28 
  • packages/main/cloop/trunk/compressed_loop.c

    r487 r520  
    2121 
    2222#define CLOOP_NAME "cloop" 
    23 #define CLOOP_VERSION "2.624
     23#define CLOOP_VERSION "2.625
    2424#define CLOOP_MAX 8 
    2525 
     
    125125 void *buffer[BUFFERED_BLOCKS]; 
    126126 void *compressed_buffer; 
     127 size_t preload_size; 
    127128 void *preload_cache; 
    128129 
     
    132133 struct inode  *backing_inode; /* for bmap */ 
    133134 
     135 unsigned long largest_block; 
    134136 unsigned int underlying_blksize; 
    135137 int clo_number; 
     
    157159#endif 
    158160 
     161/* Use __get_free_pages instead of vmalloc, allows up to 32 pages, 
     162 * 2MB in one piece */ 
     163static void *cloop_malloc(size_t size) 
     164{ 
     165 return (void *)__get_free_pages(GFP_KERNEL, get_order(size)); 
     166} 
     167 
     168static void cloop_free(void *mem, size_t size) 
     169{ 
     170 free_pages((unsigned long)mem, get_order(size)); 
     171} 
     172 
    159173static int uncompress(struct cloop_device *clo, 
    160174                      unsigned char *dest, unsigned long *destLen, 
     
    179193} 
    180194 
    181 /* This is more complicated than it looks. */ 
    182 struct cloop_read_data 
    183 { 
    184  struct cloop_device *clo; 
    185  char *data; /* We need to keep track of where we are in the buffer */ 
    186  int bsize; 
    187 }; 
    188  
    189 /* We need this for do_generic_file_read() because the default function */ 
    190 /* wants to read into user-space for an unknown reason. :-/ See loop.c. */ 
    191 static int cloop_read_actor(read_descriptor_t * desc, struct page *page, 
    192                           unsigned long offset, unsigned long size) 
    193 { 
    194  unsigned long count = desc->count; 
    195  struct cloop_read_data *p = (struct cloop_read_data*)desc->arg.data; 
    196  char *kaddr_page; 
    197  if (size > count) size = count; 
    198  kaddr_page = kmap(page); 
    199  memcpy(p->data, kaddr_page + offset, size); 
    200  kunmap(page); 
    201  desc->count = count - size; 
    202  desc->written += size; 
    203  p->data += size; 
    204  return size; 
    205 } 
    206  
    207195static size_t cloop_read_from_file(struct cloop_device *clo, struct file *f, char *buf, 
    208196  loff_t pos, size_t buf_len) 
     
    212200  { 
    213201   size_t size = buf_len - buf_done; 
    214    struct cloop_read_data cd={ /* do_generic_file_read() needs this. */ 
    215            clo,              /* struct cloop_device *clo */ 
    216            (char *)(buf + buf_done), /* char *data */ 
    217            size};            /* Actual data size */ 
    218    read_descriptor_t desc; 
    219    desc.written = 0; 
    220    desc.count   = size; 
    221    desc.arg.data = (char*)&cd; 
    222    desc.error   = 0; 
    223 #ifdef REDHAT_KERNEL /* Greenshoe Linux */ 
    224    do_generic_file_read(f, &pos, &desc, cloop_read_actor, 0); 
    225 #else /* Normal Kernel */ 
    226    do_generic_file_read(f, &pos, &desc, cloop_read_actor); 
    227 #endif 
    228    if(desc.error||desc.written<=0) 
    229     { 
    230      int left = size - desc.written; 
     202   size_t size_read = do_sync_read(f, buf +  buf_done, size, &pos); 
     203   if(size_read <= 0) 
     204    { 
     205     size_t left = size - size_read; 
    231206     if(left<0) left = 0; /* better safe than sorry */ 
    232207     printk(KERN_ERR "%s: Read error at pos %Lu in file %s, " 
     
    235210     break; 
    236211    } 
    237    buf_done += desc.written
     212   buf_done += size_read
    238213  } 
    239214 return buf_done; 
    240215} 
    241  
    242216 
    243217/* This looks more complicated than it is */ 
     
    301275 int buffered_blocknum = -1; 
    302276 int preloaded = 0; 
    303  struct bio *bio; 
    304277 loff_t offset     = (loff_t) req->sector<<9; 
    305278#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)  /* New kernel */ 
     
    352325  } /* end rq_for_each_segment*/ 
    353326#else /* Old Kernel */ 
     327 struct bio *bio; 
    354328 rq_for_each_bio(bio, req) 
    355329  { 
     
    426400    { 
    427401     int uptodate; 
     402     unsigned long flags; 
    428403     struct request *req; 
     404     spin_lock_irqsave(&clo->queue_lock, flags); 
    429405     req = list_entry(p, struct request, queuelist); 
    430      spin_lock_irq(&clo->queue_lock); 
    431406     list_del_init(&req->queuelist); 
    432      spin_unlock_irq(&clo->queue_lock); 
    433 /*     DEBUGP(KERN_ERR "cloop_handle_request(%p, %p), sector=%d, nr_sectors=%d, current_nr_sectors=%d ", clo, req, (int)req->sector, (int)req->nr_sectors, (int)req->current_nr_sectors); */ 
     407     spin_unlock_irqrestore(&clo->queue_lock, flags); 
    434408     uptodate = cloop_handle_request(clo, req); 
    435 /*     DEBUGP(KERN_ERR "cloop_handle_request done, uptodate=%d\n", uptodate); */ 
    436      spin_lock_irq(&clo->queue_lock); 
     409     spin_lock_irqsave(&clo->queue_lock, flags); 
     410#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)  /* New kernel */ 
     411     __blk_end_request(req, uptodate ? 0 : -EIO, req->nr_sectors << 9); 
     412#else 
    437413     if(!end_that_request_first(req, uptodate, req->nr_sectors)) 
    438414       end_that_request_last(req, uptodate); 
    439      spin_unlock_irq(&clo->queue_lock); 
     415#endif 
     416     spin_unlock_irqrestore(&clo->queue_lock, flags); 
    440417    } 
     418#if 0 
    441419   spin_lock_irq(&clo->queue_lock); 
    442420   blk_start_queue(clo->clo_queue); 
    443421   spin_unlock_irq(&clo->queue_lock); 
     422#endif 
    444423  } 
    445424 DEBUGP(KERN_ERR "cloop_thread exited.\n"); 
     
    476455    } 
    477456   blkdev_dequeue_request(req); /* Dequeue request first. */ 
     457#if 0 
    478458   blk_stop_queue(q);           /* Stop queue processing */ 
     459#endif 
    479460   list_add(&req->queuelist, &clo->clo_list); /* Add to working list for thread */ 
    480461   count++; 
     
    484465   DEBUGP(KERN_ERR "cloop_do_request: Discarding request %p.\n", req); 
    485466   req->errors++; 
     467#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)  /* New kernel */ 
     468   __blk_end_request(req, -EIO, req->nr_sectors << 9); 
     469#else 
    486470   end_request(req, 0); /* Discard */ 
     471#endif 
    487472  } 
    488473} 
     
    495480 char *bbuf=NULL; 
    496481 unsigned int i, offsets_read, total_offsets; 
    497  unsigned long largest_block=0; 
    498482 int isblkdev; 
    499483 int error = 0; 
     
    532516   clo->underlying_blksize = PAGE_SIZE; 
    533517 DEBUGP("Underlying blocksize is %u\n", clo->underlying_blksize); 
    534  bbuf = vmalloc(clo->underlying_blksize); 
     518 bbuf = cloop_malloc(clo->underlying_blksize); 
    535519 if(!bbuf) 
    536520  { 
     
    581565       error=-EBADF; goto error_release; 
    582566      } 
    583      clo->offsets = vmalloc(sizeof(loff_t) * total_offsets); 
     567     clo->offsets = cloop_malloc(sizeof(loff_t) * total_offsets); 
    584568     if (!clo->offsets) 
    585569      { 
     
    599583    { 
    600584     loff_t d=be64_to_cpu(clo->offsets[i+1]) - be64_to_cpu(clo->offsets[i]); 
    601      largest_block=MAX(largest_block,d); 
     585     clo->largest_block=MAX(clo->largest_block,d); 
    602586    } 
    603587   printk(KERN_INFO "%s: %s: %u blocks, %u bytes/block, largest block is %lu bytes.\n", 
    604588          cloop_name, filename, ntohl(clo->head.num_blocks), 
    605           ntohl(clo->head.block_size), largest_block); 
     589          ntohl(clo->head.block_size), clo->largest_block); 
    606590  } 
    607591/* Combo kmalloc used too large chunks (>130000). */ 
     
    610594  for(i=0;i<BUFFERED_BLOCKS;i++) 
    611595   { 
    612     clo->buffer[i] = vmalloc(ntohl(clo->head.block_size)); 
     596    clo->buffer[i] = cloop_malloc(ntohl(clo->head.block_size)); 
    613597    if(!clo->buffer[i]) 
    614598     { 
     
    619603   } 
    620604 } 
    621  clo->compressed_buffer = vmalloc(largest_block); 
     605 clo->compressed_buffer = cloop_malloc(clo->largest_block); 
    622606 if(!clo->compressed_buffer) 
    623607  { 
    624608   printk(KERN_ERR "%s: out of memory for compressed buffer %lu\n", 
    625           cloop_name, largest_block); 
     609          cloop_name, clo->largest_block); 
    626610   error=-ENOMEM; goto error_release_free_buffer; 
    627611  } 
    628  clo->zstream.workspace = vmalloc(zlib_inflate_workspacesize()); 
     612 clo->zstream.workspace = cloop_malloc(zlib_inflate_workspacesize()); 
    629613 if(!clo->zstream.workspace) 
    630614  { 
     
    641625          be64_to_cpu(clo->offsets[ntohl(clo->head.num_blocks)]), 
    642626          inode->i_size); 
    643    vfree(clo->zstream.workspace); clo->zstream.workspace=NULL; 
     627   cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); clo->zstream.workspace=NULL; 
    644628   goto error_release_free_all; 
    645629  } 
     
    660644 if(preload > 0) 
    661645  { 
    662    size_t preload_size = ((preload<=ntohl(clo->head.num_blocks))?preload:ntohl(clo->head.num_blocks)) 
     646   clo->preload_size = ((preload<=ntohl(clo->head.num_blocks))?preload:ntohl(clo->head.num_blocks)) 
    663647                          * ntohl(clo->head.block_size); 
    664    if((clo->preload_cache = vmalloc(preload_size)) != NULL) 
     648   if((clo->preload_cache = cloop_malloc(clo->preload_size)) != NULL) 
    665649    { 
    666650     int i; 
     
    675659        { 
    676660         printk(KERN_WARNING "%s: can't read block %d into preload cache, ignored.\n", cloop_name, i); 
    677          vfree(clo->preload_cache); 
     661         cloop_free(clo->preload_cache, clo->preload_size); 
    678662         clo->preload_cache = NULL; 
    679663         break; 
     
    687671 return error; 
    688672error_release_free_all: 
    689  vfree(clo->compressed_buffer); 
     673 cloop_free(clo->compressed_buffer, clo->largest_block); 
    690674 clo->compressed_buffer=NULL; 
    691675error_release_free_buffer: 
     
    696680    if(clo->buffer[i]) 
    697681     { 
    698       vfree(clo->buffer[i]); 
     682      cloop_free(clo->buffer[i], ntohl(clo->head.block_size)); 
    699683      clo->buffer[i]=NULL; 
    700684     } 
     
    702686 } 
    703687error_release_free: 
    704  vfree(clo->offsets); 
     688 cloop_free(clo->offsets, sizeof(loff_t) * total_offsets); 
    705689 clo->offsets=NULL; 
    706690error_release: 
    707  if(bbuf) vfree(bbuf); 
     691 if(bbuf) cloop_free(bbuf, clo->underlying_blksize); 
    708692 clo->backing_file=NULL; 
    709693 return error; 
     
    741725 clo->backing_file  = NULL; 
    742726 clo->backing_inode = NULL; 
    743  if(clo->offsets) { vfree(clo->offsets); clo->offsets = NULL; } 
    744  if(clo->preload_cache) { vfree(clo->preload_cache); clo->preload_cache = NULL; } 
     727 if(clo->offsets) { cloop_free(clo->offsets, clo->underlying_blksize); clo->offsets = NULL; } 
     728 if(clo->preload_cache) { cloop_free(clo->preload_cache, clo->preload_size); clo->preload_cache = NULL; } 
    745729 for(i=0; i<BUFFERED_BLOCKS; i++) 
    746       if(clo->buffer[i]) { vfree(clo->buffer[i]); clo->buffer[i]=NULL; } 
    747  if(clo->compressed_buffer) { vfree(clo->compressed_buffer); clo->compressed_buffer = NULL; } 
     730      if(clo->buffer[i]) { cloop_free(clo->buffer[i], ntohl(clo->head.block_size)); clo->buffer[i]=NULL; } 
     731 if(clo->compressed_buffer) { cloop_free(clo->compressed_buffer, clo->largest_block); clo->compressed_buffer = NULL; } 
    748732 zlib_inflateEnd(&clo->zstream); 
    749  if(clo->zstream.workspace) { vfree(clo->zstream.workspace); clo->zstream.workspace = NULL; } 
     733 if(clo->zstream.workspace) { cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); clo->zstream.workspace = NULL; } 
    750734#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) 
    751735 if(bdev) invalidate_bdev(bdev, 0); 
  • packages/main/cloop/trunk/debian/changelog

    r487 r520  
     1cloop (2.625) unstable; urgency=low 
     2 
     3  * Fix compiling issue for kernel 2.6.25  
     4 
     5 -- Unixmedia S.r.l. (Medianix Devel) <devel@unixmedia.it>  Tue, 24 Jun 2008 10:16:56 +0200 
     6 
    17cloop (2.624) unstable; urgency=low 
    28