diff mbox

[v2,27/28] libext2fs: export inode cahce creation function

Message ID 1386072715-9869-28-git-send-email-wenqing.lz@taobao.com
State Superseded, archived
Headers show

Commit Message

Zheng Liu Dec. 3, 2013, 12:11 p.m. UTC
From: Zheng Liu <wenqing.lz@taobao.com>

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>
---
 lib/ext2fs/ext2fs.h |    1 +
 lib/ext2fs/inode.c  |    8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

Comments

Darrick Wong Dec. 3, 2013, 10:22 p.m. UTC | #1
On Tue, Dec 03, 2013 at 08:11:54PM +0800, Zheng Liu wrote:
> From: Zheng Liu <wenqing.lz@taobao.com>
> 
> 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>
> ---
>  lib/ext2fs/ext2fs.h |    1 +
>  lib/ext2fs/inode.c  |    8 ++++----
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
> index bf0ef26..a47bb40 100644
> --- a/lib/ext2fs/ext2fs.h
> +++ b/lib/ext2fs/ext2fs.h
> @@ -1369,6 +1369,7 @@ 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, 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,
> diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
> index 46c1c58..8cf76b0 100644
> --- a/lib/ext2fs/inode.c
> +++ b/lib/ext2fs/inode.c
> @@ -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, int cache_size)

cache_size should unsigned int; there's not much point in letting people pass
us a negative size.

Possibly ext2_inode_cache.cache_size should be unsigned too...

--D

>  {
>  	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;
>  	}
> -- 
> 1.7.9.7
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zheng Liu Dec. 4, 2013, 3:56 a.m. UTC | #2
On Tue, Dec 03, 2013 at 02:22:49PM -0800, Darrick J. Wong wrote:
> On Tue, Dec 03, 2013 at 08:11:54PM +0800, Zheng Liu wrote:
> > From: Zheng Liu <wenqing.lz@taobao.com>
> > 
> > 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>
> > ---
> >  lib/ext2fs/ext2fs.h |    1 +
> >  lib/ext2fs/inode.c  |    8 ++++----
> >  2 files changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
> > index bf0ef26..a47bb40 100644
> > --- a/lib/ext2fs/ext2fs.h
> > +++ b/lib/ext2fs/ext2fs.h
> > @@ -1369,6 +1369,7 @@ 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, 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,
> > diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
> > index 46c1c58..8cf76b0 100644
> > --- a/lib/ext2fs/inode.c
> > +++ b/lib/ext2fs/inode.c
> > @@ -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, int cache_size)
> 
> cache_size should unsigned int; there's not much point in letting people pass
> us a negative size.
> 
> Possibly ext2_inode_cache.cache_size should be unsigned too...

Fair enough.  I will fix it soon.

Thanks,
                                                - Zheng

> 
> --D
> 
> >  {
> >  	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;
> >  	}
> > -- 
> > 1.7.9.7
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index bf0ef26..a47bb40 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -1369,6 +1369,7 @@  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, 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,
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index 46c1c58..8cf76b0 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -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, 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;
 	}