Skip to content

Commit a8070dd

Browse files
committed
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>
1 parent adbb39b commit a8070dd

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎fs/nilfs2/bmap.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,21 @@ void nilfs_bmap_commit_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap)
548548
lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
549549
bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode;
550550
}
551+
552+
void 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+
561+
void 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+
}

‎fs/nilfs2/bmap.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ struct nilfs_bmap {
135135
/* state */
136136
#define NILFS_BMAP_DIRTY 0x00000001
137137

138+
struct 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+
};
138144

139145
int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *);
140146
int nilfs_bmap_read(struct nilfs_bmap *, struct nilfs_inode *);
@@ -156,6 +162,8 @@ void nilfs_bmap_init_gc(struct nilfs_bmap *);
156162
void nilfs_bmap_init_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
157163
void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
158164

165+
void nilfs_bmap_save(const struct nilfs_bmap *, struct nilfs_bmap_store *);
166+
void nilfs_bmap_restore(struct nilfs_bmap *, const struct nilfs_bmap_store *);
159167

160168
static inline int nilfs_bmap_lookup(struct nilfs_bmap *bmap, __u64 key,
161169
__u64 *ptr)

0 commit comments

Comments
 (0)