aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/direct.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2015-04-16 15:46:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-17 09:04:03 -0400
commit5b20384fb32cc3f93857f44fb84736d6d62a9917 (patch)
treef6ab08afbf9777142c63d447a1f0e6b02df08679 /fs/nilfs2/direct.c
parent3568a13f4089aac90b3763a2b6c293cd2b638ec1 (diff)
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/direct.c')
-rw-r--r--fs/nilfs2/direct.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
index 82f4865e86dd..ebf89fd8ac1a 100644
--- a/fs/nilfs2/direct.c
+++ b/fs/nilfs2/direct.c
@@ -173,6 +173,21 @@ static int nilfs_direct_delete(struct nilfs_bmap *bmap, __u64 key)
173 return ret; 173 return ret;
174} 174}
175 175
176static int nilfs_direct_seek_key(const struct nilfs_bmap *direct, __u64 start,
177 __u64 *keyp)
178{
179 __u64 key;
180
181 for (key = start; key <= NILFS_DIRECT_KEY_MAX; key++) {
182 if (nilfs_direct_get_ptr(direct, key) !=
183 NILFS_BMAP_INVALID_PTR) {
184 *keyp = key;
185 return 0;
186 }
187 }
188 return -ENOENT;
189}
190
176static int nilfs_direct_last_key(const struct nilfs_bmap *direct, __u64 *keyp) 191static int nilfs_direct_last_key(const struct nilfs_bmap *direct, __u64 *keyp)
177{ 192{
178 __u64 key, lastkey; 193 __u64 key, lastkey;
@@ -355,7 +370,9 @@ static const struct nilfs_bmap_operations nilfs_direct_ops = {
355 .bop_assign = nilfs_direct_assign, 370 .bop_assign = nilfs_direct_assign,
356 .bop_mark = NULL, 371 .bop_mark = NULL,
357 372
373 .bop_seek_key = nilfs_direct_seek_key,
358 .bop_last_key = nilfs_direct_last_key, 374 .bop_last_key = nilfs_direct_last_key,
375
359 .bop_check_insert = nilfs_direct_check_insert, 376 .bop_check_insert = nilfs_direct_check_insert,
360 .bop_check_delete = NULL, 377 .bop_check_delete = NULL,
361 .bop_gather_data = nilfs_direct_gather_data, 378 .bop_gather_data = nilfs_direct_gather_data,