diff options
Diffstat (limited to 'fs/nilfs2/dat.c')
-rw-r--r-- | fs/nilfs2/dat.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c index 1ff8e15bd36b..013146755683 100644 --- a/fs/nilfs2/dat.c +++ b/fs/nilfs2/dat.c | |||
@@ -33,6 +33,16 @@ | |||
33 | #define NILFS_CNO_MIN ((__u64)1) | 33 | #define NILFS_CNO_MIN ((__u64)1) |
34 | #define NILFS_CNO_MAX (~(__u64)0) | 34 | #define NILFS_CNO_MAX (~(__u64)0) |
35 | 35 | ||
36 | struct nilfs_dat_info { | ||
37 | struct nilfs_mdt_info mi; | ||
38 | struct nilfs_palloc_cache palloc_cache; | ||
39 | }; | ||
40 | |||
41 | static inline struct nilfs_dat_info *NILFS_DAT_I(struct inode *dat) | ||
42 | { | ||
43 | return (struct nilfs_dat_info *)NILFS_MDT(dat); | ||
44 | } | ||
45 | |||
36 | static int nilfs_dat_prepare_entry(struct inode *dat, | 46 | static int nilfs_dat_prepare_entry(struct inode *dat, |
37 | struct nilfs_palloc_req *req, int create) | 47 | struct nilfs_palloc_req *req, int create) |
38 | { | 48 | { |
@@ -278,7 +288,7 @@ int nilfs_dat_mark_dirty(struct inode *dat, __u64 vblocknr) | |||
278 | * @vblocknrs and @nitems. | 288 | * @vblocknrs and @nitems. |
279 | * | 289 | * |
280 | * Return Value: On success, 0 is returned. On error, one of the following | 290 | * Return Value: On success, 0 is returned. On error, one of the following |
281 | * nagative error codes is returned. | 291 | * negative error codes is returned. |
282 | * | 292 | * |
283 | * %-EIO - I/O error. | 293 | * %-EIO - I/O error. |
284 | * | 294 | * |
@@ -378,8 +388,7 @@ int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp) | |||
378 | ret = -ENOENT; | 388 | ret = -ENOENT; |
379 | goto out; | 389 | goto out; |
380 | } | 390 | } |
381 | if (blocknrp != NULL) | 391 | *blocknrp = blocknr; |
382 | *blocknrp = blocknr; | ||
383 | 392 | ||
384 | out: | 393 | out: |
385 | kunmap_atomic(kaddr, KM_USER0); | 394 | kunmap_atomic(kaddr, KM_USER0); |
@@ -425,3 +434,40 @@ ssize_t nilfs_dat_get_vinfo(struct inode *dat, void *buf, unsigned visz, | |||
425 | 434 | ||
426 | return nvi; | 435 | return nvi; |
427 | } | 436 | } |
437 | |||
438 | /** | ||
439 | * nilfs_dat_read - read dat inode | ||
440 | * @dat: dat inode | ||
441 | * @raw_inode: on-disk dat inode | ||
442 | */ | ||
443 | int nilfs_dat_read(struct inode *dat, struct nilfs_inode *raw_inode) | ||
444 | { | ||
445 | return nilfs_read_inode_common(dat, raw_inode); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * nilfs_dat_new - create dat file | ||
450 | * @nilfs: nilfs object | ||
451 | * @entry_size: size of a dat entry | ||
452 | */ | ||
453 | struct inode *nilfs_dat_new(struct the_nilfs *nilfs, size_t entry_size) | ||
454 | { | ||
455 | static struct lock_class_key dat_lock_key; | ||
456 | struct inode *dat; | ||
457 | struct nilfs_dat_info *di; | ||
458 | int err; | ||
459 | |||
460 | dat = nilfs_mdt_new(nilfs, NULL, NILFS_DAT_INO, sizeof(*di)); | ||
461 | if (dat) { | ||
462 | err = nilfs_palloc_init_blockgroup(dat, entry_size); | ||
463 | if (unlikely(err)) { | ||
464 | nilfs_mdt_destroy(dat); | ||
465 | return NULL; | ||
466 | } | ||
467 | |||
468 | di = NILFS_DAT_I(dat); | ||
469 | lockdep_set_class(&di->mi.mi_sem, &dat_lock_key); | ||
470 | nilfs_palloc_setup_cache(dat, &di->palloc_cache); | ||
471 | } | ||
472 | return dat; | ||
473 | } | ||