diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-08-15 04:22:13 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-09-14 05:27:15 -0400 |
commit | bd8169efae8bdd292675c386010f6b35f0771057 (patch) | |
tree | aea73bd670910874eb78fd1f2c8ce8b2a494dfcb /fs | |
parent | 7a102b09232be1ad7c180dfd1f46c7aa95dff1e0 (diff) |
nilfs2: add update functions of virtual block address to dat
This is a preparation for the successive cleanup ("nilfs2: allow btree
to directly call dat operations").
This adds functions bundling a few operations to change an entry of
virtual block address on the dat file.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nilfs2/bmap.c | 27 | ||||
-rw-r--r-- | fs/nilfs2/dat.c | 31 | ||||
-rw-r--r-- | fs/nilfs2/dat.h | 6 |
3 files changed, 44 insertions, 20 deletions
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 99d58a028b94..13e95a907ece 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c | |||
@@ -533,38 +533,25 @@ int nilfs_bmap_prepare_update_v(struct nilfs_bmap *bmap, | |||
533 | union nilfs_bmap_ptr_req *oldreq, | 533 | union nilfs_bmap_ptr_req *oldreq, |
534 | union nilfs_bmap_ptr_req *newreq) | 534 | union nilfs_bmap_ptr_req *newreq) |
535 | { | 535 | { |
536 | struct inode *dat = nilfs_bmap_get_dat(bmap); | 536 | return nilfs_dat_prepare_update(nilfs_bmap_get_dat(bmap), |
537 | int ret; | 537 | &oldreq->bpr_req, &newreq->bpr_req); |
538 | |||
539 | ret = nilfs_dat_prepare_end(dat, &oldreq->bpr_req); | ||
540 | if (ret < 0) | ||
541 | return ret; | ||
542 | ret = nilfs_dat_prepare_alloc(dat, &newreq->bpr_req); | ||
543 | if (ret < 0) | ||
544 | nilfs_dat_abort_end(dat, &oldreq->bpr_req); | ||
545 | |||
546 | return ret; | ||
547 | } | 538 | } |
548 | 539 | ||
549 | void nilfs_bmap_commit_update_v(struct nilfs_bmap *bmap, | 540 | void nilfs_bmap_commit_update_v(struct nilfs_bmap *bmap, |
550 | union nilfs_bmap_ptr_req *oldreq, | 541 | union nilfs_bmap_ptr_req *oldreq, |
551 | union nilfs_bmap_ptr_req *newreq) | 542 | union nilfs_bmap_ptr_req *newreq) |
552 | { | 543 | { |
553 | struct inode *dat = nilfs_bmap_get_dat(bmap); | 544 | nilfs_dat_commit_update(nilfs_bmap_get_dat(bmap), |
554 | 545 | &oldreq->bpr_req, &newreq->bpr_req, | |
555 | nilfs_dat_commit_end(dat, &oldreq->bpr_req, | 546 | bmap->b_ptr_type == NILFS_BMAP_PTR_VS); |
556 | bmap->b_ptr_type == NILFS_BMAP_PTR_VS); | ||
557 | nilfs_dat_commit_alloc(dat, &newreq->bpr_req); | ||
558 | } | 547 | } |
559 | 548 | ||
560 | void nilfs_bmap_abort_update_v(struct nilfs_bmap *bmap, | 549 | void nilfs_bmap_abort_update_v(struct nilfs_bmap *bmap, |
561 | union nilfs_bmap_ptr_req *oldreq, | 550 | union nilfs_bmap_ptr_req *oldreq, |
562 | union nilfs_bmap_ptr_req *newreq) | 551 | union nilfs_bmap_ptr_req *newreq) |
563 | { | 552 | { |
564 | struct inode *dat = nilfs_bmap_get_dat(bmap); | 553 | nilfs_dat_abort_update(nilfs_bmap_get_dat(bmap), |
565 | 554 | &oldreq->bpr_req, &newreq->bpr_req); | |
566 | nilfs_dat_abort_end(dat, &oldreq->bpr_req); | ||
567 | nilfs_dat_abort_alloc(dat, &newreq->bpr_req); | ||
568 | } | 555 | } |
569 | 556 | ||
570 | static struct lock_class_key nilfs_bmap_dat_lock_key; | 557 | static struct lock_class_key nilfs_bmap_dat_lock_key; |
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c index 1cfcc1a0fdf1..1ff8e15bd36b 100644 --- a/fs/nilfs2/dat.c +++ b/fs/nilfs2/dat.c | |||
@@ -211,6 +211,37 @@ void nilfs_dat_abort_end(struct inode *dat, struct nilfs_palloc_req *req) | |||
211 | nilfs_dat_abort_entry(dat, req); | 211 | nilfs_dat_abort_entry(dat, req); |
212 | } | 212 | } |
213 | 213 | ||
214 | int nilfs_dat_prepare_update(struct inode *dat, | ||
215 | struct nilfs_palloc_req *oldreq, | ||
216 | struct nilfs_palloc_req *newreq) | ||
217 | { | ||
218 | int ret; | ||
219 | |||
220 | ret = nilfs_dat_prepare_end(dat, oldreq); | ||
221 | if (!ret) { | ||
222 | ret = nilfs_dat_prepare_alloc(dat, newreq); | ||
223 | if (ret < 0) | ||
224 | nilfs_dat_abort_end(dat, oldreq); | ||
225 | } | ||
226 | return ret; | ||
227 | } | ||
228 | |||
229 | void nilfs_dat_commit_update(struct inode *dat, | ||
230 | struct nilfs_palloc_req *oldreq, | ||
231 | struct nilfs_palloc_req *newreq, int dead) | ||
232 | { | ||
233 | nilfs_dat_commit_end(dat, oldreq, dead); | ||
234 | nilfs_dat_commit_alloc(dat, newreq); | ||
235 | } | ||
236 | |||
237 | void nilfs_dat_abort_update(struct inode *dat, | ||
238 | struct nilfs_palloc_req *oldreq, | ||
239 | struct nilfs_palloc_req *newreq) | ||
240 | { | ||
241 | nilfs_dat_abort_end(dat, oldreq); | ||
242 | nilfs_dat_abort_alloc(dat, newreq); | ||
243 | } | ||
244 | |||
214 | /** | 245 | /** |
215 | * nilfs_dat_mark_dirty - | 246 | * nilfs_dat_mark_dirty - |
216 | * @dat: DAT file inode | 247 | * @dat: DAT file inode |
diff --git a/fs/nilfs2/dat.h b/fs/nilfs2/dat.h index 91dc3372a39a..406070d3ff49 100644 --- a/fs/nilfs2/dat.h +++ b/fs/nilfs2/dat.h | |||
@@ -41,6 +41,12 @@ void nilfs_dat_commit_start(struct inode *, struct nilfs_palloc_req *, | |||
41 | int nilfs_dat_prepare_end(struct inode *, struct nilfs_palloc_req *); | 41 | int nilfs_dat_prepare_end(struct inode *, struct nilfs_palloc_req *); |
42 | void nilfs_dat_commit_end(struct inode *, struct nilfs_palloc_req *, int); | 42 | void nilfs_dat_commit_end(struct inode *, struct nilfs_palloc_req *, int); |
43 | void nilfs_dat_abort_end(struct inode *, struct nilfs_palloc_req *); | 43 | void nilfs_dat_abort_end(struct inode *, struct nilfs_palloc_req *); |
44 | int nilfs_dat_prepare_update(struct inode *, struct nilfs_palloc_req *, | ||
45 | struct nilfs_palloc_req *); | ||
46 | void nilfs_dat_commit_update(struct inode *, struct nilfs_palloc_req *, | ||
47 | struct nilfs_palloc_req *, int); | ||
48 | void nilfs_dat_abort_update(struct inode *, struct nilfs_palloc_req *, | ||
49 | struct nilfs_palloc_req *); | ||
44 | 50 | ||
45 | int nilfs_dat_mark_dirty(struct inode *, __u64); | 51 | int nilfs_dat_mark_dirty(struct inode *, __u64); |
46 | int nilfs_dat_freev(struct inode *, __u64 *, size_t); | 52 | int nilfs_dat_freev(struct inode *, __u64 *, size_t); |