libext2fs: export inode cache creation function

Currently we have already exported inode cache flush and free functions
for users.  This commit exports inode cache creation function.  Later
we will use this function to initialize inode cache and do some unit
tests for inline data.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
pu
Zheng Liu 2014-03-03 01:03:24 -05:00 committed by Theodore Ts'o
parent 3c1388d99c
commit be31a8de5a
3 changed files with 7 additions and 5 deletions

View File

@ -1387,6 +1387,8 @@ extern errcode_t ext2fs_get_memalign(unsigned long size,
unsigned long align, void *ptr);
/* inode.c */
extern errcode_t ext2fs_create_inode_cache(ext2_filsys fs,
unsigned int cache_size);
extern void ext2fs_free_inode_cache(struct ext2_inode_cache *icache);
extern errcode_t ext2fs_flush_icache(ext2_filsys fs);
extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan,

View File

@ -69,7 +69,7 @@ struct ext2_inode_cache {
void * buffer;
blk64_t buffer_blk;
int cache_last;
int cache_size;
unsigned int cache_size;
int refcount;
struct ext2_inode_cache_ent *cache;
};

View File

@ -91,7 +91,7 @@ void ext2fs_free_inode_cache(struct ext2_inode_cache *icache)
ext2fs_free_mem(&icache);
}
static errcode_t create_icache(ext2_filsys fs)
errcode_t ext2fs_create_inode_cache(ext2_filsys fs, unsigned int cache_size)
{
int i;
errcode_t retval;
@ -109,7 +109,7 @@ static errcode_t create_icache(ext2_filsys fs)
fs->icache->buffer_blk = 0;
fs->icache->cache_last = -1;
fs->icache->cache_size = 4;
fs->icache->cache_size = cache_size;
fs->icache->refcount = 1;
retval = ext2fs_get_array(fs->icache->cache_size,
sizeof(struct ext2_inode_cache_ent),
@ -596,7 +596,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
return EXT2_ET_BAD_INODE_NUM;
/* Create inode cache if not present */
if (!fs->icache) {
retval = create_icache(fs);
retval = ext2fs_create_inode_cache(fs, 4);
if (retval)
return retval;
}
@ -732,7 +732,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
}
}
} else {
retval = create_icache(fs);
retval = ext2fs_create_inode_cache(fs, 4);
if (retval)
goto errout;
}