1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _NILFS_MDT_H
24#define _NILFS_MDT_H
25
26#include <linux/buffer_head.h>
27#include <linux/blockgroup_lock.h>
28#include "nilfs.h"
29#include "page.h"
30
31
32
33
34
35
36
37
38struct nilfs_shadow_map {
39 struct nilfs_bmap_store bmap_store;
40 struct address_space frozen_data;
41 struct address_space frozen_btnodes;
42 struct list_head frozen_buffers;
43};
44
45
46
47
48
49
50
51
52
53
54
55
56
57struct nilfs_mdt_info {
58 struct rw_semaphore mi_sem;
59 struct blockgroup_lock *mi_bgl;
60 unsigned mi_entry_size;
61 unsigned mi_first_entry_offset;
62 unsigned long mi_entries_per_block;
63 struct nilfs_palloc_cache *mi_palloc_cache;
64 struct nilfs_shadow_map *mi_shadow;
65 unsigned long mi_blocks_per_group;
66 unsigned long mi_blocks_per_desc_block;
67};
68
69static inline struct nilfs_mdt_info *NILFS_MDT(const struct inode *inode)
70{
71 return inode->i_private;
72}
73
74
75#define NILFS_MDT_GFP (__GFP_RECLAIM | __GFP_IO | __GFP_HIGHMEM)
76
77int nilfs_mdt_get_block(struct inode *, unsigned long, int,
78 void (*init_block)(struct inode *,
79 struct buffer_head *, void *),
80 struct buffer_head **);
81int nilfs_mdt_find_block(struct inode *inode, unsigned long start,
82 unsigned long end, unsigned long *blkoff,
83 struct buffer_head **out_bh);
84int nilfs_mdt_delete_block(struct inode *, unsigned long);
85int nilfs_mdt_forget_block(struct inode *, unsigned long);
86int nilfs_mdt_mark_block_dirty(struct inode *, unsigned long);
87int nilfs_mdt_fetch_dirty(struct inode *);
88
89int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz);
90void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned);
91
92int nilfs_mdt_setup_shadow_map(struct inode *inode,
93 struct nilfs_shadow_map *shadow);
94int nilfs_mdt_save_to_shadow_map(struct inode *inode);
95void nilfs_mdt_restore_from_shadow_map(struct inode *inode);
96void nilfs_mdt_clear_shadow_map(struct inode *inode);
97int nilfs_mdt_freeze_buffer(struct inode *inode, struct buffer_head *bh);
98struct buffer_head *nilfs_mdt_get_frozen_buffer(struct inode *inode,
99 struct buffer_head *bh);
100
101static inline void nilfs_mdt_mark_dirty(struct inode *inode)
102{
103 if (!test_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state))
104 set_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
105}
106
107static inline void nilfs_mdt_clear_dirty(struct inode *inode)
108{
109 clear_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
110}
111
112static inline __u64 nilfs_mdt_cno(struct inode *inode)
113{
114 return ((struct the_nilfs *)inode->i_sb->s_fs_info)->ns_cno;
115}
116
117static inline spinlock_t *
118nilfs_mdt_bgl_lock(struct inode *inode, unsigned int block_group)
119{
120 return bgl_lock_ptr(NILFS_MDT(inode)->mi_bgl, block_group);
121}
122
123#endif
124