aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-08-15 04:22:13 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-09-14 05:27:15 -0400
commitbd8169efae8bdd292675c386010f6b35f0771057 (patch)
treeaea73bd670910874eb78fd1f2c8ce8b2a494dfcb /fs
parent7a102b09232be1ad7c180dfd1f46c7aa95dff1e0 (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.c27
-rw-r--r--fs/nilfs2/dat.c31
-rw-r--r--fs/nilfs2/dat.h6
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
549void nilfs_bmap_commit_update_v(struct nilfs_bmap *bmap, 540void 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
560void nilfs_bmap_abort_update_v(struct nilfs_bmap *bmap, 549void 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
570static struct lock_class_key nilfs_bmap_dat_lock_key; 557static 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
214int 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
229void 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
237void 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 *,
41int nilfs_dat_prepare_end(struct inode *, struct nilfs_palloc_req *); 41int nilfs_dat_prepare_end(struct inode *, struct nilfs_palloc_req *);
42void nilfs_dat_commit_end(struct inode *, struct nilfs_palloc_req *, int); 42void nilfs_dat_commit_end(struct inode *, struct nilfs_palloc_req *, int);
43void nilfs_dat_abort_end(struct inode *, struct nilfs_palloc_req *); 43void nilfs_dat_abort_end(struct inode *, struct nilfs_palloc_req *);
44int nilfs_dat_prepare_update(struct inode *, struct nilfs_palloc_req *,
45 struct nilfs_palloc_req *);
46void nilfs_dat_commit_update(struct inode *, struct nilfs_palloc_req *,
47 struct nilfs_palloc_req *, int);
48void nilfs_dat_abort_update(struct inode *, struct nilfs_palloc_req *,
49 struct nilfs_palloc_req *);
44 50
45int nilfs_dat_mark_dirty(struct inode *, __u64); 51int nilfs_dat_mark_dirty(struct inode *, __u64);
46int nilfs_dat_freev(struct inode *, __u64 *, size_t); 52int nilfs_dat_freev(struct inode *, __u64 *, size_t);