aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-30 10:42:18 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:37 -0400
commita8070dd365dd995f6139a2fc3aeee10159bdcc45 (patch)
tree11a16157b10ed0b6d3f773ded6bd5b82c3f8c4bc /fs
parentadbb39b5485b72dca963a2bc9b1b22bfc19d4967 (diff)
nilfs2: add routines to save and restore bmap state
This adds routines to save and restore the state of bmap structure. The bmap state is stored in a given nilfs_bmap_store object. These routines will be used to roll back the state of dat inode without using gcdat inode. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs')
-rw-r--r--fs/nilfs2/bmap.c18
-rw-r--r--fs/nilfs2/bmap.h8
2 files changed, 26 insertions, 0 deletions
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 3dbdc1d356bf..00244402d59e 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -548,3 +548,21 @@ void nilfs_bmap_commit_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap)
548 lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key); 548 lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
549 bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode; 549 bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode;
550} 550}
551
552void nilfs_bmap_save(const struct nilfs_bmap *bmap,
553 struct nilfs_bmap_store *store)
554{
555 memcpy(store->data, bmap->b_u.u_data, sizeof(store->data));
556 store->last_allocated_key = bmap->b_last_allocated_key;
557 store->last_allocated_ptr = bmap->b_last_allocated_ptr;
558 store->state = bmap->b_state;
559}
560
561void nilfs_bmap_restore(struct nilfs_bmap *bmap,
562 const struct nilfs_bmap_store *store)
563{
564 memcpy(bmap->b_u.u_data, store->data, sizeof(store->data));
565 bmap->b_last_allocated_key = store->last_allocated_key;
566 bmap->b_last_allocated_ptr = store->last_allocated_ptr;
567 bmap->b_state = store->state;
568}
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h
index a20569b19929..5f3339e3eac9 100644
--- a/fs/nilfs2/bmap.h
+++ b/fs/nilfs2/bmap.h
@@ -135,6 +135,12 @@ struct nilfs_bmap {
135/* state */ 135/* state */
136#define NILFS_BMAP_DIRTY 0x00000001 136#define NILFS_BMAP_DIRTY 0x00000001
137 137
138struct nilfs_bmap_store {
139 __le64 data[NILFS_BMAP_SIZE / sizeof(__le64)];
140 __u64 last_allocated_key;
141 __u64 last_allocated_ptr;
142 int state;
143};
138 144
139int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *); 145int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *);
140int nilfs_bmap_read(struct nilfs_bmap *, struct nilfs_inode *); 146int nilfs_bmap_read(struct nilfs_bmap *, struct nilfs_inode *);
@@ -156,6 +162,8 @@ void nilfs_bmap_init_gc(struct nilfs_bmap *);
156void nilfs_bmap_init_gcdat(struct nilfs_bmap *, struct nilfs_bmap *); 162void nilfs_bmap_init_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
157void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *); 163void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
158 164
165void nilfs_bmap_save(const struct nilfs_bmap *, struct nilfs_bmap_store *);
166void nilfs_bmap_restore(struct nilfs_bmap *, const struct nilfs_bmap_store *);
159 167
160static inline int nilfs_bmap_lookup(struct nilfs_bmap *bmap, __u64 key, 168static inline int nilfs_bmap_lookup(struct nilfs_bmap *bmap, __u64 key,
161 __u64 *ptr) 169 __u64 *ptr)