From: charles Date: Sun, 9 Oct 2005 07:55:00 +0000 (+0000) Subject: Use vmalloc for large memory allocations X-Git-Tag: pre-name-change~395 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=56f93d87556bc0802ea8d5b080d9e8265bc4e9c1;hp=f67d10d7a5a6d1cc7d1cb6eaada2522873ce5e99 Use vmalloc for large memory allocations --- diff --git a/yaffs_guts.c b/yaffs_guts.c index eafbaa9..4783f85 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -13,7 +13,7 @@ */ const char *yaffs_guts_c_version = - "$Id: yaffs_guts.c,v 1.20 2005-10-07 02:46:49 charles Exp $"; + "$Id: yaffs_guts.c,v 1.21 2005-10-09 07:55:00 charles Exp $"; #include "yportenv.h" @@ -1757,6 +1757,13 @@ static int yaffs_InitialiseBlocks(yaffs_Device * dev, int nBlocks) /* Set up dynamic blockinfo stuff. */ dev->chunkBitmapStride = (dev->nChunksPerBlock + 7) / 8; dev->chunkBits = YMALLOC(dev->chunkBitmapStride * nBlocks); + if(!dev->chunkBits){ + dev->chunkBits = YMALLOC_ALT(dev->chunkBitmapStride * nBlocks); + dev->chunkBitsAlt = 1; + } + else + dev->chunkBitsAlt = 0; + if (dev->blockInfo && dev->chunkBits) { memset(dev->blockInfo, 0, nBlocks * sizeof(yaffs_BlockInfo)); memset(dev->chunkBits, 0, dev->chunkBitmapStride * nBlocks); @@ -1776,7 +1783,12 @@ static void yaffs_DeinitialiseBlocks(yaffs_Device * dev) dev->blockInfoAlt = 0; dev->blockInfo = NULL; - YFREE(dev->chunkBits); + + if(dev->chunkBitsAlt) + YFREE_ALT(dev->chunkBits); + else + YFREE(dev->chunkBits); + dev->chunkBitsAlt = 0; dev->chunkBits = NULL; } diff --git a/yaffs_guts.h b/yaffs_guts.h index c5eee97..73375cc 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -14,7 +14,7 @@ * * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. * - * $Id: yaffs_guts.h,v 1.15 2005-10-07 02:46:50 charles Exp $ + * $Id: yaffs_guts.h,v 1.16 2005-10-09 07:55:00 charles Exp $ */ #ifndef __YAFFS_GUTS_H__ @@ -561,8 +561,9 @@ struct yaffs_DeviceStruct { /* Block Info */ yaffs_BlockInfo *blockInfo; - int blockInfoAlt; /* was allocated using alternative strategy */ __u8 *chunkBits; /* bitmap of chunks in use */ + unsigned blockInfoAlt:1; /* was allocated using alternative strategy */ + unsigned chunkBitsAlt:1; /* was allocated using alternative strategy */ int chunkBitmapStride; /* Number of bytes of chunkBits per block. * Must be consistent with nChunksPerBlock. */