diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-05-03 08:43:01 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-06-10 10:41:09 -0400 |
commit | d97a51a7e3c298d9899ea91165dfa0783fa5cc5c (patch) | |
tree | 31c3b082565cd3004c2036fe79657297a29a5824 /fs | |
parent | 65822070646ed7f2cf520439006dd863529be16e (diff) |
nilfs2: unify bmap operations starting use of indirect block address
This simplifies some low level functions of bmap.
Three bmap pointer operations, nilfs_bmap_start_v(),
nilfs_bmap_commit_v(), and nilfs_bmap_abort_v(), are unified into one
nilfs_bmap_start_v() function. And the related indirect function calls
are replaced with it.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nilfs2/bmap.c | 36 | ||||
-rw-r--r-- | fs/nilfs2/bmap.h | 9 | ||||
-rw-r--r-- | fs/nilfs2/btree.c | 7 | ||||
-rw-r--r-- | fs/nilfs2/direct.c | 7 |
4 files changed, 14 insertions, 45 deletions
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 064279e33bbb..4f2523f5c0b1 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c | |||
@@ -511,24 +511,16 @@ static void nilfs_bmap_abort_alloc_v(struct nilfs_bmap *bmap, | |||
511 | nilfs_dat_abort_alloc(nilfs_bmap_get_dat(bmap), &req->bpr_req); | 511 | nilfs_dat_abort_alloc(nilfs_bmap_get_dat(bmap), &req->bpr_req); |
512 | } | 512 | } |
513 | 513 | ||
514 | static int nilfs_bmap_prepare_start_v(struct nilfs_bmap *bmap, | 514 | int nilfs_bmap_start_v(struct nilfs_bmap *bmap, union nilfs_bmap_ptr_req *req, |
515 | union nilfs_bmap_ptr_req *req) | 515 | sector_t blocknr) |
516 | { | 516 | { |
517 | return nilfs_dat_prepare_start(nilfs_bmap_get_dat(bmap), &req->bpr_req); | 517 | struct inode *dat = nilfs_bmap_get_dat(bmap); |
518 | } | 518 | int ret; |
519 | |||
520 | static void nilfs_bmap_commit_start_v(struct nilfs_bmap *bmap, | ||
521 | union nilfs_bmap_ptr_req *req, | ||
522 | sector_t blocknr) | ||
523 | { | ||
524 | nilfs_dat_commit_start(nilfs_bmap_get_dat(bmap), &req->bpr_req, | ||
525 | blocknr); | ||
526 | } | ||
527 | 519 | ||
528 | static void nilfs_bmap_abort_start_v(struct nilfs_bmap *bmap, | 520 | ret = nilfs_dat_prepare_start(dat, &req->bpr_req); |
529 | union nilfs_bmap_ptr_req *req) | 521 | if (likely(!ret)) |
530 | { | 522 | nilfs_dat_commit_start(dat, &req->bpr_req, blocknr); |
531 | nilfs_dat_abort_start(nilfs_bmap_get_dat(bmap), &req->bpr_req); | 523 | return ret; |
532 | } | 524 | } |
533 | 525 | ||
534 | static int nilfs_bmap_prepare_end_v(struct nilfs_bmap *bmap, | 526 | static int nilfs_bmap_prepare_end_v(struct nilfs_bmap *bmap, |
@@ -636,9 +628,6 @@ static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_v = { | |||
636 | .bpop_prepare_alloc_ptr = nilfs_bmap_prepare_alloc_v, | 628 | .bpop_prepare_alloc_ptr = nilfs_bmap_prepare_alloc_v, |
637 | .bpop_commit_alloc_ptr = nilfs_bmap_commit_alloc_v, | 629 | .bpop_commit_alloc_ptr = nilfs_bmap_commit_alloc_v, |
638 | .bpop_abort_alloc_ptr = nilfs_bmap_abort_alloc_v, | 630 | .bpop_abort_alloc_ptr = nilfs_bmap_abort_alloc_v, |
639 | .bpop_prepare_start_ptr = nilfs_bmap_prepare_start_v, | ||
640 | .bpop_commit_start_ptr = nilfs_bmap_commit_start_v, | ||
641 | .bpop_abort_start_ptr = nilfs_bmap_abort_start_v, | ||
642 | .bpop_prepare_end_ptr = nilfs_bmap_prepare_end_v, | 631 | .bpop_prepare_end_ptr = nilfs_bmap_prepare_end_v, |
643 | .bpop_commit_end_ptr = nilfs_bmap_commit_end_v, | 632 | .bpop_commit_end_ptr = nilfs_bmap_commit_end_v, |
644 | .bpop_abort_end_ptr = nilfs_bmap_abort_end_v, | 633 | .bpop_abort_end_ptr = nilfs_bmap_abort_end_v, |
@@ -650,9 +639,6 @@ static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_vmdt = { | |||
650 | .bpop_prepare_alloc_ptr = nilfs_bmap_prepare_alloc_v, | 639 | .bpop_prepare_alloc_ptr = nilfs_bmap_prepare_alloc_v, |
651 | .bpop_commit_alloc_ptr = nilfs_bmap_commit_alloc_v, | 640 | .bpop_commit_alloc_ptr = nilfs_bmap_commit_alloc_v, |
652 | .bpop_abort_alloc_ptr = nilfs_bmap_abort_alloc_v, | 641 | .bpop_abort_alloc_ptr = nilfs_bmap_abort_alloc_v, |
653 | .bpop_prepare_start_ptr = nilfs_bmap_prepare_start_v, | ||
654 | .bpop_commit_start_ptr = nilfs_bmap_commit_start_v, | ||
655 | .bpop_abort_start_ptr = nilfs_bmap_abort_start_v, | ||
656 | .bpop_prepare_end_ptr = nilfs_bmap_prepare_end_v, | 642 | .bpop_prepare_end_ptr = nilfs_bmap_prepare_end_v, |
657 | .bpop_commit_end_ptr = nilfs_bmap_commit_end_vmdt, | 643 | .bpop_commit_end_ptr = nilfs_bmap_commit_end_vmdt, |
658 | .bpop_abort_end_ptr = nilfs_bmap_abort_end_v, | 644 | .bpop_abort_end_ptr = nilfs_bmap_abort_end_v, |
@@ -664,9 +650,6 @@ static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_p = { | |||
664 | .bpop_prepare_alloc_ptr = nilfs_bmap_prepare_alloc_p, | 650 | .bpop_prepare_alloc_ptr = nilfs_bmap_prepare_alloc_p, |
665 | .bpop_commit_alloc_ptr = nilfs_bmap_commit_alloc_p, | 651 | .bpop_commit_alloc_ptr = nilfs_bmap_commit_alloc_p, |
666 | .bpop_abort_alloc_ptr = nilfs_bmap_abort_alloc_p, | 652 | .bpop_abort_alloc_ptr = nilfs_bmap_abort_alloc_p, |
667 | .bpop_prepare_start_ptr = NULL, | ||
668 | .bpop_commit_start_ptr = NULL, | ||
669 | .bpop_abort_start_ptr = NULL, | ||
670 | .bpop_prepare_end_ptr = NULL, | 653 | .bpop_prepare_end_ptr = NULL, |
671 | .bpop_commit_end_ptr = NULL, | 654 | .bpop_commit_end_ptr = NULL, |
672 | .bpop_abort_end_ptr = NULL, | 655 | .bpop_abort_end_ptr = NULL, |
@@ -678,9 +661,6 @@ static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_gc = { | |||
678 | .bpop_prepare_alloc_ptr = NULL, | 661 | .bpop_prepare_alloc_ptr = NULL, |
679 | .bpop_commit_alloc_ptr = NULL, | 662 | .bpop_commit_alloc_ptr = NULL, |
680 | .bpop_abort_alloc_ptr = NULL, | 663 | .bpop_abort_alloc_ptr = NULL, |
681 | .bpop_prepare_start_ptr = NULL, | ||
682 | .bpop_commit_start_ptr = NULL, | ||
683 | .bpop_abort_start_ptr = NULL, | ||
684 | .bpop_prepare_end_ptr = NULL, | 664 | .bpop_prepare_end_ptr = NULL, |
685 | .bpop_commit_end_ptr = NULL, | 665 | .bpop_commit_end_ptr = NULL, |
686 | .bpop_abort_end_ptr = NULL, | 666 | .bpop_abort_end_ptr = NULL, |
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index 4f2708abb1ba..ad251d3e6752 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h | |||
@@ -96,13 +96,6 @@ struct nilfs_bmap_ptr_operations { | |||
96 | union nilfs_bmap_ptr_req *); | 96 | union nilfs_bmap_ptr_req *); |
97 | void (*bpop_abort_alloc_ptr)(struct nilfs_bmap *, | 97 | void (*bpop_abort_alloc_ptr)(struct nilfs_bmap *, |
98 | union nilfs_bmap_ptr_req *); | 98 | union nilfs_bmap_ptr_req *); |
99 | int (*bpop_prepare_start_ptr)(struct nilfs_bmap *, | ||
100 | union nilfs_bmap_ptr_req *); | ||
101 | void (*bpop_commit_start_ptr)(struct nilfs_bmap *, | ||
102 | union nilfs_bmap_ptr_req *, | ||
103 | sector_t); | ||
104 | void (*bpop_abort_start_ptr)(struct nilfs_bmap *, | ||
105 | union nilfs_bmap_ptr_req *); | ||
106 | int (*bpop_prepare_end_ptr)(struct nilfs_bmap *, | 99 | int (*bpop_prepare_end_ptr)(struct nilfs_bmap *, |
107 | union nilfs_bmap_ptr_req *); | 100 | union nilfs_bmap_ptr_req *); |
108 | void (*bpop_commit_end_ptr)(struct nilfs_bmap *, | 101 | void (*bpop_commit_end_ptr)(struct nilfs_bmap *, |
@@ -183,6 +176,8 @@ void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *); | |||
183 | * Internal use only | 176 | * Internal use only |
184 | */ | 177 | */ |
185 | 178 | ||
179 | int nilfs_bmap_start_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *, | ||
180 | sector_t); | ||
186 | int nilfs_bmap_move_v(const struct nilfs_bmap *, __u64, sector_t); | 181 | int nilfs_bmap_move_v(const struct nilfs_bmap *, __u64, sector_t); |
187 | int nilfs_bmap_mark_dirty(const struct nilfs_bmap *, __u64); | 182 | int nilfs_bmap_mark_dirty(const struct nilfs_bmap *, __u64); |
188 | 183 | ||
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 6b37a2767293..959e5a7a8035 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -2066,12 +2066,9 @@ static int nilfs_btree_assign_v(struct nilfs_btree *btree, | |||
2066 | ptr = nilfs_btree_node_get_ptr(btree, parent, | 2066 | ptr = nilfs_btree_node_get_ptr(btree, parent, |
2067 | path[level + 1].bp_index); | 2067 | path[level + 1].bp_index); |
2068 | req.bpr_ptr = ptr; | 2068 | req.bpr_ptr = ptr; |
2069 | ret = btree->bt_bmap.b_pops->bpop_prepare_start_ptr(&btree->bt_bmap, | 2069 | ret = nilfs_bmap_start_v(&btree->bt_bmap, &req, blocknr); |
2070 | &req); | 2070 | if (unlikely(ret < 0)) |
2071 | if (ret < 0) | ||
2072 | return ret; | 2071 | return ret; |
2073 | btree->bt_bmap.b_pops->bpop_commit_start_ptr(&btree->bt_bmap, | ||
2074 | &req, blocknr); | ||
2075 | 2072 | ||
2076 | key = nilfs_btree_node_get_key(btree, parent, | 2073 | key = nilfs_btree_node_get_key(btree, parent, |
2077 | path[level + 1].bp_index); | 2074 | path[level + 1].bp_index); |
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c index c6379e482781..5cbba8284bea 100644 --- a/fs/nilfs2/direct.c +++ b/fs/nilfs2/direct.c | |||
@@ -327,12 +327,9 @@ static int nilfs_direct_assign_v(struct nilfs_direct *direct, | |||
327 | int ret; | 327 | int ret; |
328 | 328 | ||
329 | req.bpr_ptr = ptr; | 329 | req.bpr_ptr = ptr; |
330 | ret = direct->d_bmap.b_pops->bpop_prepare_start_ptr( | 330 | ret = nilfs_bmap_start_v(&direct->d_bmap, &req, blocknr); |
331 | &direct->d_bmap, &req); | 331 | if (unlikely(ret < 0)) |
332 | if (ret < 0) | ||
333 | return ret; | 332 | return ret; |
334 | direct->d_bmap.b_pops->bpop_commit_start_ptr(&direct->d_bmap, | ||
335 | &req, blocknr); | ||
336 | 333 | ||
337 | binfo->bi_v.bi_vblocknr = nilfs_bmap_ptr_to_dptr(ptr); | 334 | binfo->bi_v.bi_vblocknr = nilfs_bmap_ptr_to_dptr(ptr); |
338 | binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key); | 335 | binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key); |