提交 bd8169ef 编写于 作者: R Ryusuke Konishi

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: NRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
上级 7a102b09
...@@ -533,38 +533,25 @@ int nilfs_bmap_prepare_update_v(struct nilfs_bmap *bmap, ...@@ -533,38 +533,25 @@ int nilfs_bmap_prepare_update_v(struct nilfs_bmap *bmap,
union nilfs_bmap_ptr_req *oldreq, union nilfs_bmap_ptr_req *oldreq,
union nilfs_bmap_ptr_req *newreq) union nilfs_bmap_ptr_req *newreq)
{ {
struct inode *dat = nilfs_bmap_get_dat(bmap); return nilfs_dat_prepare_update(nilfs_bmap_get_dat(bmap),
int ret; &oldreq->bpr_req, &newreq->bpr_req);
ret = nilfs_dat_prepare_end(dat, &oldreq->bpr_req);
if (ret < 0)
return ret;
ret = nilfs_dat_prepare_alloc(dat, &newreq->bpr_req);
if (ret < 0)
nilfs_dat_abort_end(dat, &oldreq->bpr_req);
return ret;
} }
void nilfs_bmap_commit_update_v(struct nilfs_bmap *bmap, void nilfs_bmap_commit_update_v(struct nilfs_bmap *bmap,
union nilfs_bmap_ptr_req *oldreq, union nilfs_bmap_ptr_req *oldreq,
union nilfs_bmap_ptr_req *newreq) union nilfs_bmap_ptr_req *newreq)
{ {
struct inode *dat = nilfs_bmap_get_dat(bmap); nilfs_dat_commit_update(nilfs_bmap_get_dat(bmap),
&oldreq->bpr_req, &newreq->bpr_req,
nilfs_dat_commit_end(dat, &oldreq->bpr_req, bmap->b_ptr_type == NILFS_BMAP_PTR_VS);
bmap->b_ptr_type == NILFS_BMAP_PTR_VS);
nilfs_dat_commit_alloc(dat, &newreq->bpr_req);
} }
void nilfs_bmap_abort_update_v(struct nilfs_bmap *bmap, void nilfs_bmap_abort_update_v(struct nilfs_bmap *bmap,
union nilfs_bmap_ptr_req *oldreq, union nilfs_bmap_ptr_req *oldreq,
union nilfs_bmap_ptr_req *newreq) union nilfs_bmap_ptr_req *newreq)
{ {
struct inode *dat = nilfs_bmap_get_dat(bmap); nilfs_dat_abort_update(nilfs_bmap_get_dat(bmap),
&oldreq->bpr_req, &newreq->bpr_req);
nilfs_dat_abort_end(dat, &oldreq->bpr_req);
nilfs_dat_abort_alloc(dat, &newreq->bpr_req);
} }
static struct lock_class_key nilfs_bmap_dat_lock_key; static struct lock_class_key nilfs_bmap_dat_lock_key;
......
...@@ -211,6 +211,37 @@ void nilfs_dat_abort_end(struct inode *dat, struct nilfs_palloc_req *req) ...@@ -211,6 +211,37 @@ void nilfs_dat_abort_end(struct inode *dat, struct nilfs_palloc_req *req)
nilfs_dat_abort_entry(dat, req); nilfs_dat_abort_entry(dat, req);
} }
int nilfs_dat_prepare_update(struct inode *dat,
struct nilfs_palloc_req *oldreq,
struct nilfs_palloc_req *newreq)
{
int ret;
ret = nilfs_dat_prepare_end(dat, oldreq);
if (!ret) {
ret = nilfs_dat_prepare_alloc(dat, newreq);
if (ret < 0)
nilfs_dat_abort_end(dat, oldreq);
}
return ret;
}
void nilfs_dat_commit_update(struct inode *dat,
struct nilfs_palloc_req *oldreq,
struct nilfs_palloc_req *newreq, int dead)
{
nilfs_dat_commit_end(dat, oldreq, dead);
nilfs_dat_commit_alloc(dat, newreq);
}
void nilfs_dat_abort_update(struct inode *dat,
struct nilfs_palloc_req *oldreq,
struct nilfs_palloc_req *newreq)
{
nilfs_dat_abort_end(dat, oldreq);
nilfs_dat_abort_alloc(dat, newreq);
}
/** /**
* nilfs_dat_mark_dirty - * nilfs_dat_mark_dirty -
* @dat: DAT file inode * @dat: DAT file inode
......
...@@ -41,6 +41,12 @@ void nilfs_dat_commit_start(struct inode *, struct nilfs_palloc_req *, ...@@ -41,6 +41,12 @@ void nilfs_dat_commit_start(struct inode *, struct nilfs_palloc_req *,
int nilfs_dat_prepare_end(struct inode *, struct nilfs_palloc_req *); int nilfs_dat_prepare_end(struct inode *, struct nilfs_palloc_req *);
void nilfs_dat_commit_end(struct inode *, struct nilfs_palloc_req *, int); void nilfs_dat_commit_end(struct inode *, struct nilfs_palloc_req *, int);
void nilfs_dat_abort_end(struct inode *, struct nilfs_palloc_req *); void nilfs_dat_abort_end(struct inode *, struct nilfs_palloc_req *);
int nilfs_dat_prepare_update(struct inode *, struct nilfs_palloc_req *,
struct nilfs_palloc_req *);
void nilfs_dat_commit_update(struct inode *, struct nilfs_palloc_req *,
struct nilfs_palloc_req *, int);
void nilfs_dat_abort_update(struct inode *, struct nilfs_palloc_req *,
struct nilfs_palloc_req *);
int nilfs_dat_mark_dirty(struct inode *, __u64); int nilfs_dat_mark_dirty(struct inode *, __u64);
int nilfs_dat_freev(struct inode *, __u64 *, size_t); int nilfs_dat_freev(struct inode *, __u64 *, size_t);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册