diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2015-04-16 12:46:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:04:03 -0400 |
commit | 5b20384fb32cc3f93857f44fb84736d6d62a9917 (patch) | |
tree | f6ab08afbf9777142c63d447a1f0e6b02df08679 /fs/nilfs2/bmap.c | |
parent | 3568a13f4089aac90b3763a2b6c293cd2b638ec1 (diff) | |
download | linux-5b20384fb32cc3f93857f44fb84736d6d62a9917.tar.gz linux-5b20384fb32cc3f93857f44fb84736d6d62a9917.tar.bz2 linux-5b20384fb32cc3f93857f44fb84736d6d62a9917.zip |
nilfs2: add bmap function to seek a valid key
Add a new bmap function, nilfs_bmap_seek_key(), which seeks a valid
entry and returns its key starting from a given key. This function
can be used to skip hole blocks efficiently.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nilfs2/bmap.c')
-rw-r--r-- | fs/nilfs2/bmap.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index c82f4361c1f9..27f75bcbeb30 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -189,6 +189,37 @@ static int nilfs_bmap_do_delete(struct nilfs_bmap *bmap, __u64 key) return bmap->b_ops->bop_delete(bmap, key); } +/** + * nilfs_bmap_seek_key - seek a valid entry and return its key + * @bmap: bmap struct + * @start: start key number + * @keyp: place to store valid key + * + * Description: nilfs_bmap_seek_key() seeks a valid key on @bmap + * starting from @start, and stores it to @keyp if found. + * + * Return Value: On success, 0 is returned. On error, one of the following + * negative error codes is returned. + * + * %-EIO - I/O error. + * + * %-ENOMEM - Insufficient amount of memory available. + * + * %-ENOENT - No valid entry was found + */ +int nilfs_bmap_seek_key(struct nilfs_bmap *bmap, __u64 start, __u64 *keyp) +{ + int ret; + + down_read(&bmap->b_sem); + ret = bmap->b_ops->bop_seek_key(bmap, start, keyp); + up_read(&bmap->b_sem); + + if (ret < 0) + ret = nilfs_bmap_convert_error(bmap, __func__, ret); + return ret; +} + int nilfs_bmap_last_key(struct nilfs_bmap *bmap, __u64 *keyp) { int ret; |