Lines Matching full:dat
3 * dat.c - NILFS disk address translation.
17 #include "dat.h"
24 * struct nilfs_dat_info - on-memory private data of DAT file
26 * @palloc_cache: persistent object allocator cache of DAT file
27 * @shadow: shadow map of DAT file
35 static inline struct nilfs_dat_info *NILFS_DAT_I(struct inode *dat) in NILFS_DAT_I() argument
37 return (struct nilfs_dat_info *)NILFS_MDT(dat); in NILFS_DAT_I()
40 static int nilfs_dat_prepare_entry(struct inode *dat, in nilfs_dat_prepare_entry() argument
43 return nilfs_palloc_get_entry_block(dat, req->pr_entry_nr, in nilfs_dat_prepare_entry()
47 static void nilfs_dat_commit_entry(struct inode *dat, in nilfs_dat_commit_entry() argument
51 nilfs_mdt_mark_dirty(dat); in nilfs_dat_commit_entry()
55 static void nilfs_dat_abort_entry(struct inode *dat, in nilfs_dat_abort_entry() argument
61 int nilfs_dat_prepare_alloc(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_prepare_alloc() argument
65 ret = nilfs_palloc_prepare_alloc_entry(dat, req); in nilfs_dat_prepare_alloc()
69 ret = nilfs_dat_prepare_entry(dat, req, 1); in nilfs_dat_prepare_alloc()
71 nilfs_palloc_abort_alloc_entry(dat, req); in nilfs_dat_prepare_alloc()
76 void nilfs_dat_commit_alloc(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_commit_alloc() argument
82 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr, in nilfs_dat_commit_alloc()
89 nilfs_palloc_commit_alloc_entry(dat, req); in nilfs_dat_commit_alloc()
90 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_alloc()
93 void nilfs_dat_abort_alloc(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_abort_alloc() argument
95 nilfs_dat_abort_entry(dat, req); in nilfs_dat_abort_alloc()
96 nilfs_palloc_abort_alloc_entry(dat, req); in nilfs_dat_abort_alloc()
99 static void nilfs_dat_commit_free(struct inode *dat, in nilfs_dat_commit_free() argument
106 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr, in nilfs_dat_commit_free()
113 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_free()
116 nilfs_error(dat->i_sb, in nilfs_dat_commit_free()
121 nilfs_palloc_commit_free_entry(dat, req); in nilfs_dat_commit_free()
124 int nilfs_dat_prepare_start(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_prepare_start() argument
128 ret = nilfs_dat_prepare_entry(dat, req, 0); in nilfs_dat_prepare_start()
133 void nilfs_dat_commit_start(struct inode *dat, struct nilfs_palloc_req *req, in nilfs_dat_commit_start() argument
140 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr, in nilfs_dat_commit_start()
142 entry->de_start = cpu_to_le64(nilfs_mdt_cno(dat)); in nilfs_dat_commit_start()
146 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_start()
149 int nilfs_dat_prepare_end(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_prepare_end() argument
156 ret = nilfs_dat_prepare_entry(dat, req, 0); in nilfs_dat_prepare_end()
163 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr, in nilfs_dat_prepare_end()
169 ret = nilfs_palloc_prepare_free_entry(dat, req); in nilfs_dat_prepare_end()
171 nilfs_dat_abort_entry(dat, req); in nilfs_dat_prepare_end()
179 void nilfs_dat_commit_end(struct inode *dat, struct nilfs_palloc_req *req, in nilfs_dat_commit_end() argument
188 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr, in nilfs_dat_commit_end()
192 end = nilfs_mdt_cno(dat); in nilfs_dat_commit_end()
200 nilfs_dat_commit_free(dat, req); in nilfs_dat_commit_end()
202 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_end()
205 void nilfs_dat_abort_end(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_abort_end() argument
213 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr, in nilfs_dat_abort_end()
219 if (start == nilfs_mdt_cno(dat) && blocknr == 0) in nilfs_dat_abort_end()
220 nilfs_palloc_abort_free_entry(dat, req); in nilfs_dat_abort_end()
221 nilfs_dat_abort_entry(dat, req); in nilfs_dat_abort_end()
224 int nilfs_dat_prepare_update(struct inode *dat, in nilfs_dat_prepare_update() argument
230 ret = nilfs_dat_prepare_end(dat, oldreq); in nilfs_dat_prepare_update()
232 ret = nilfs_dat_prepare_alloc(dat, newreq); in nilfs_dat_prepare_update()
234 nilfs_dat_abort_end(dat, oldreq); in nilfs_dat_prepare_update()
239 void nilfs_dat_commit_update(struct inode *dat, in nilfs_dat_commit_update() argument
243 nilfs_dat_commit_end(dat, oldreq, dead); in nilfs_dat_commit_update()
244 nilfs_dat_commit_alloc(dat, newreq); in nilfs_dat_commit_update()
247 void nilfs_dat_abort_update(struct inode *dat, in nilfs_dat_abort_update() argument
251 nilfs_dat_abort_end(dat, oldreq); in nilfs_dat_abort_update()
252 nilfs_dat_abort_alloc(dat, newreq); in nilfs_dat_abort_update()
257 * @dat: DAT file inode
269 int nilfs_dat_mark_dirty(struct inode *dat, __u64 vblocknr) in nilfs_dat_mark_dirty() argument
275 ret = nilfs_dat_prepare_entry(dat, &req, 0); in nilfs_dat_mark_dirty()
277 nilfs_dat_commit_entry(dat, &req); in nilfs_dat_mark_dirty()
283 * @dat: DAT file inode
299 int nilfs_dat_freev(struct inode *dat, __u64 *vblocknrs, size_t nitems) in nilfs_dat_freev() argument
301 return nilfs_palloc_freev(dat, vblocknrs, nitems); in nilfs_dat_freev()
306 * @dat: DAT file inode
320 int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr) in nilfs_dat_move() argument
327 ret = nilfs_palloc_get_entry_block(dat, vblocknr, 0, &entry_bh); in nilfs_dat_move()
340 ret = nilfs_mdt_freeze_buffer(dat, entry_bh); in nilfs_dat_move()
348 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr); in nilfs_dat_move()
350 nilfs_crit(dat->i_sb, in nilfs_dat_move()
364 nilfs_mdt_mark_dirty(dat); in nilfs_dat_move()
373 * @dat: DAT file inode
390 int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp) in nilfs_dat_translate() argument
398 ret = nilfs_palloc_get_entry_block(dat, vblocknr, 0, &entry_bh); in nilfs_dat_translate()
403 bh = nilfs_mdt_get_frozen_buffer(dat, entry_bh); in nilfs_dat_translate()
412 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr); in nilfs_dat_translate()
426 ssize_t nilfs_dat_get_vinfo(struct inode *dat, void *buf, unsigned int visz, in nilfs_dat_get_vinfo() argument
434 unsigned long entries_per_block = NILFS_MDT(dat)->mi_entries_per_block; in nilfs_dat_get_vinfo()
438 ret = nilfs_palloc_get_entry_block(dat, vinfo->vi_vblocknr, in nilfs_dat_get_vinfo()
453 dat, vinfo->vi_vblocknr, entry_bh, kaddr); in nilfs_dat_get_vinfo()
466 * nilfs_dat_read - read or get dat inode
468 * @entry_size: size of a dat entry
469 * @raw_inode: on-disk dat inode
476 struct inode *dat; in nilfs_dat_read() local
481 nilfs_err(sb, "too large DAT entry size: %zu bytes", in nilfs_dat_read()
485 nilfs_err(sb, "too small DAT entry size: %zu bytes", in nilfs_dat_read()
490 dat = nilfs_iget_locked(sb, NULL, NILFS_DAT_INO); in nilfs_dat_read()
491 if (unlikely(!dat)) in nilfs_dat_read()
493 if (!(dat->i_state & I_NEW)) in nilfs_dat_read()
496 err = nilfs_mdt_init(dat, NILFS_MDT_GFP, sizeof(*di)); in nilfs_dat_read()
500 err = nilfs_palloc_init_blockgroup(dat, entry_size); in nilfs_dat_read()
504 di = NILFS_DAT_I(dat); in nilfs_dat_read()
506 nilfs_palloc_setup_cache(dat, &di->palloc_cache); in nilfs_dat_read()
507 err = nilfs_mdt_setup_shadow_map(dat, &di->shadow); in nilfs_dat_read()
511 err = nilfs_read_inode_common(dat, raw_inode); in nilfs_dat_read()
515 unlock_new_inode(dat); in nilfs_dat_read()
517 *inodep = dat; in nilfs_dat_read()
520 iget_failed(dat); in nilfs_dat_read()