Lines Matching full:dat
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
45 ret = nilfs_palloc_get_entry_block(dat, req->pr_entry_nr, in nilfs_dat_prepare_entry()
48 nilfs_err(dat->i_sb, in nilfs_dat_prepare_entry()
49 "DAT doesn't have a block to manage vblocknr = %llu", in nilfs_dat_prepare_entry()
60 static void nilfs_dat_commit_entry(struct inode *dat, in nilfs_dat_commit_entry() argument
64 nilfs_mdt_mark_dirty(dat); in nilfs_dat_commit_entry()
68 static void nilfs_dat_abort_entry(struct inode *dat, in nilfs_dat_abort_entry() argument
74 int nilfs_dat_prepare_alloc(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_prepare_alloc() argument
78 ret = nilfs_palloc_prepare_alloc_entry(dat, req, true); in nilfs_dat_prepare_alloc()
82 ret = nilfs_dat_prepare_entry(dat, req, 1); in nilfs_dat_prepare_alloc()
84 nilfs_palloc_abort_alloc_entry(dat, req); in nilfs_dat_prepare_alloc()
89 void nilfs_dat_commit_alloc(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_commit_alloc() argument
94 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_alloc()
102 nilfs_palloc_commit_alloc_entry(dat, req); in nilfs_dat_commit_alloc()
103 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_alloc()
106 void nilfs_dat_abort_alloc(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_abort_alloc() argument
108 nilfs_dat_abort_entry(dat, req); in nilfs_dat_abort_alloc()
109 nilfs_palloc_abort_alloc_entry(dat, req); in nilfs_dat_abort_alloc()
112 static void nilfs_dat_commit_free(struct inode *dat, in nilfs_dat_commit_free() argument
118 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_free()
126 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_free()
129 nilfs_error(dat->i_sb, in nilfs_dat_commit_free()
134 nilfs_palloc_commit_free_entry(dat, req); in nilfs_dat_commit_free()
137 int nilfs_dat_prepare_start(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_prepare_start() argument
139 return nilfs_dat_prepare_entry(dat, req, 0); in nilfs_dat_prepare_start()
142 void nilfs_dat_commit_start(struct inode *dat, struct nilfs_palloc_req *req, in nilfs_dat_commit_start() argument
148 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_start()
151 entry->de_start = cpu_to_le64(nilfs_mdt_cno(dat)); in nilfs_dat_commit_start()
155 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_start()
158 int nilfs_dat_prepare_end(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_prepare_end() argument
166 ret = nilfs_dat_prepare_entry(dat, req, 0); in nilfs_dat_prepare_end()
170 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_prepare_end()
178 ret = nilfs_palloc_prepare_free_entry(dat, req); in nilfs_dat_prepare_end()
180 nilfs_dat_abort_entry(dat, req); in nilfs_dat_prepare_end()
184 if (unlikely(start > nilfs_mdt_cno(dat))) { in nilfs_dat_prepare_end()
185 nilfs_err(dat->i_sb, in nilfs_dat_prepare_end()
189 (unsigned long long)nilfs_mdt_cno(dat)); in nilfs_dat_prepare_end()
190 nilfs_dat_abort_entry(dat, req); in nilfs_dat_prepare_end()
197 void nilfs_dat_commit_end(struct inode *dat, struct nilfs_palloc_req *req, in nilfs_dat_commit_end() argument
205 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_end()
210 end = nilfs_mdt_cno(dat); in nilfs_dat_commit_end()
218 nilfs_dat_commit_free(dat, req); in nilfs_dat_commit_end()
220 nilfs_dat_commit_entry(dat, req); in nilfs_dat_commit_end()
223 void nilfs_dat_abort_end(struct inode *dat, struct nilfs_palloc_req *req) in nilfs_dat_abort_end() argument
230 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_abort_end()
237 if (start == nilfs_mdt_cno(dat) && blocknr == 0) in nilfs_dat_abort_end()
238 nilfs_palloc_abort_free_entry(dat, req); in nilfs_dat_abort_end()
239 nilfs_dat_abort_entry(dat, req); in nilfs_dat_abort_end()
242 int nilfs_dat_prepare_update(struct inode *dat, in nilfs_dat_prepare_update() argument
248 ret = nilfs_dat_prepare_end(dat, oldreq); in nilfs_dat_prepare_update()
250 ret = nilfs_dat_prepare_alloc(dat, newreq); in nilfs_dat_prepare_update()
252 nilfs_dat_abort_end(dat, oldreq); in nilfs_dat_prepare_update()
257 void nilfs_dat_commit_update(struct inode *dat, in nilfs_dat_commit_update() argument
261 nilfs_dat_commit_end(dat, oldreq, dead); in nilfs_dat_commit_update()
262 nilfs_dat_commit_alloc(dat, newreq); in nilfs_dat_commit_update()
265 void nilfs_dat_abort_update(struct inode *dat, in nilfs_dat_abort_update() argument
269 nilfs_dat_abort_end(dat, oldreq); in nilfs_dat_abort_update()
270 nilfs_dat_abort_alloc(dat, newreq); in nilfs_dat_abort_update()
274 * nilfs_dat_mark_dirty - mark the DAT block buffer containing the specified
276 * @dat: DAT file inode
281 * * %-EINVAL - Invalid DAT entry (internal code).
285 int nilfs_dat_mark_dirty(struct inode *dat, __u64 vblocknr) in nilfs_dat_mark_dirty() argument
291 ret = nilfs_dat_prepare_entry(dat, &req, 0); in nilfs_dat_mark_dirty()
293 nilfs_dat_commit_entry(dat, &req); in nilfs_dat_mark_dirty()
299 * @dat: DAT file inode
312 int nilfs_dat_freev(struct inode *dat, __u64 *vblocknrs, size_t nitems) in nilfs_dat_freev() argument
314 return nilfs_palloc_freev(dat, vblocknrs, nitems); in nilfs_dat_freev()
319 * @dat: DAT file inode
331 int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr) in nilfs_dat_move() argument
338 ret = nilfs_palloc_get_entry_block(dat, vblocknr, 0, &entry_bh); in nilfs_dat_move()
351 ret = nilfs_mdt_freeze_buffer(dat, entry_bh); in nilfs_dat_move()
358 offset = nilfs_palloc_entry_offset(dat, vblocknr, entry_bh); in nilfs_dat_move()
361 nilfs_crit(dat->i_sb, in nilfs_dat_move()
375 nilfs_mdt_mark_dirty(dat); in nilfs_dat_move()
384 * @dat: DAT file inode
398 int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp) in nilfs_dat_translate() argument
406 ret = nilfs_palloc_get_entry_block(dat, vblocknr, 0, &entry_bh); in nilfs_dat_translate()
411 bh = nilfs_mdt_get_frozen_buffer(dat, entry_bh); in nilfs_dat_translate()
419 offset = nilfs_palloc_entry_offset(dat, vblocknr, entry_bh); in nilfs_dat_translate()
434 ssize_t nilfs_dat_get_vinfo(struct inode *dat, void *buf, unsigned int visz, in nilfs_dat_get_vinfo() argument
442 unsigned long entries_per_block = NILFS_MDT(dat)->mi_entries_per_block; in nilfs_dat_get_vinfo()
443 unsigned int entry_size = NILFS_MDT(dat)->mi_entry_size; in nilfs_dat_get_vinfo()
447 ret = nilfs_palloc_get_entry_block(dat, vinfo->vi_vblocknr, in nilfs_dat_get_vinfo()
460 offset = nilfs_palloc_entry_offset(dat, first, entry_bh); in nilfs_dat_get_vinfo()
480 * nilfs_dat_read - read or get dat inode
482 * @entry_size: size of a dat entry
483 * @raw_inode: on-disk dat inode
492 struct inode *dat; in nilfs_dat_read() local
497 nilfs_err(sb, "too large DAT entry size: %zu bytes", in nilfs_dat_read()
501 nilfs_err(sb, "too small DAT entry size: %zu bytes", in nilfs_dat_read()
506 dat = nilfs_iget_locked(sb, NULL, NILFS_DAT_INO); in nilfs_dat_read()
507 if (unlikely(!dat)) in nilfs_dat_read()
509 if (!(dat->i_state & I_NEW)) in nilfs_dat_read()
512 err = nilfs_mdt_init(dat, NILFS_MDT_GFP, sizeof(*di)); in nilfs_dat_read()
516 err = nilfs_palloc_init_blockgroup(dat, entry_size); in nilfs_dat_read()
520 di = NILFS_DAT_I(dat); in nilfs_dat_read()
522 nilfs_palloc_setup_cache(dat, &di->palloc_cache); in nilfs_dat_read()
523 err = nilfs_mdt_setup_shadow_map(dat, &di->shadow); in nilfs_dat_read()
527 err = nilfs_read_inode_common(dat, raw_inode); in nilfs_dat_read()
531 unlock_new_inode(dat); in nilfs_dat_read()
533 *inodep = dat; in nilfs_dat_read()
536 iget_failed(dat); in nilfs_dat_read()