mirror of https://gitee.com/openkylin/linux.git
nilfs2: convert nilfs_bmap_lookup to an inline function
The nilfs_bmap_lookup() is now a wrapper function of nilfs_bmap_lookup_at_level(). This moves the nilfs_bmap_lookup() to a header file converting it to an inline function and gives an opportunity for optimization. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
This commit is contained in:
parent
2e0c2c7392
commit
0f3fe33b39
|
@ -36,6 +36,26 @@ struct inode *nilfs_bmap_get_dat(const struct nilfs_bmap *bmap)
|
|||
return nilfs_dat_inode(NILFS_I_NILFS(bmap->b_inode));
|
||||
}
|
||||
|
||||
/**
|
||||
* nilfs_bmap_lookup_at_level - find a data block or node block
|
||||
* @bmap: bmap
|
||||
* @key: key
|
||||
* @level: level
|
||||
* @ptrp: place to store the value associated to @key
|
||||
*
|
||||
* Description: nilfs_bmap_lookup_at_level() finds a record whose key
|
||||
* matches @key in the block at @level of the bmap.
|
||||
*
|
||||
* Return Value: On success, 0 is returned and the record associated with @key
|
||||
* is stored in the place pointed by @ptrp. On error, one of the following
|
||||
* negative error codes is returned.
|
||||
*
|
||||
* %-EIO - I/O error.
|
||||
*
|
||||
* %-ENOMEM - Insufficient amount of memory available.
|
||||
*
|
||||
* %-ENOENT - A record associated with @key does not exist.
|
||||
*/
|
||||
int nilfs_bmap_lookup_at_level(struct nilfs_bmap *bmap, __u64 key, int level,
|
||||
__u64 *ptrp)
|
||||
{
|
||||
|
@ -69,39 +89,6 @@ int nilfs_bmap_lookup_contig(struct nilfs_bmap *bmap, __u64 key, __u64 *ptrp,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* nilfs_bmap_lookup - find a record
|
||||
* @bmap: bmap
|
||||
* @key: key
|
||||
* @recp: pointer to record
|
||||
*
|
||||
* Description: nilfs_bmap_lookup() finds a record whose key matches @key in
|
||||
* @bmap.
|
||||
*
|
||||
* Return Value: On success, 0 is returned and the record associated with @key
|
||||
* is stored in the place pointed by @recp. On error, one of the following
|
||||
* negative error codes is returned.
|
||||
*
|
||||
* %-EIO - I/O error.
|
||||
*
|
||||
* %-ENOMEM - Insufficient amount of memory available.
|
||||
*
|
||||
* %-ENOENT - A record associated with @key does not exist.
|
||||
*/
|
||||
int nilfs_bmap_lookup(struct nilfs_bmap *bmap,
|
||||
unsigned long key,
|
||||
unsigned long *recp)
|
||||
{
|
||||
__u64 ptr;
|
||||
int ret;
|
||||
|
||||
/* XXX: use macro for level 1 */
|
||||
ret = nilfs_bmap_lookup_at_level(bmap, key, 1, &ptr);
|
||||
if (recp != NULL)
|
||||
*recp = ptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int nilfs_bmap_do_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
|
||||
{
|
||||
__u64 keys[NILFS_BMAP_SMALL_HIGH + 1];
|
||||
|
|
|
@ -142,7 +142,6 @@ struct nilfs_bmap {
|
|||
int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *);
|
||||
int nilfs_bmap_read(struct nilfs_bmap *, struct nilfs_inode *);
|
||||
void nilfs_bmap_write(struct nilfs_bmap *, struct nilfs_inode *);
|
||||
int nilfs_bmap_lookup(struct nilfs_bmap *, unsigned long, unsigned long *);
|
||||
int nilfs_bmap_lookup_contig(struct nilfs_bmap *, __u64, __u64 *, unsigned);
|
||||
int nilfs_bmap_insert(struct nilfs_bmap *, unsigned long, unsigned long);
|
||||
int nilfs_bmap_delete(struct nilfs_bmap *, unsigned long);
|
||||
|
@ -161,6 +160,12 @@ void nilfs_bmap_init_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
|
|||
void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
|
||||
|
||||
|
||||
static inline int nilfs_bmap_lookup(struct nilfs_bmap *bmap, __u64 key,
|
||||
__u64 *ptr)
|
||||
{
|
||||
return nilfs_bmap_lookup_at_level(bmap, key, 1, ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal use only
|
||||
*/
|
||||
|
|
|
@ -136,7 +136,7 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff,
|
|||
int mode, struct buffer_head **out_bh)
|
||||
{
|
||||
struct buffer_head *bh;
|
||||
unsigned long blknum = 0;
|
||||
__u64 blknum = 0;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
bh = nilfs_grab_buffer(inode, inode->i_mapping, blkoff, 0);
|
||||
|
@ -166,7 +166,7 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff,
|
|||
goto failed_bh;
|
||||
}
|
||||
bh->b_bdev = NILFS_MDT(inode)->mi_nilfs->ns_bdev;
|
||||
bh->b_blocknr = blknum;
|
||||
bh->b_blocknr = (sector_t)blknum;
|
||||
set_buffer_mapped(bh);
|
||||
|
||||
bh->b_end_io = end_buffer_read_sync;
|
||||
|
|
Loading…
Reference in New Issue