44
45
/* ---------------------------------------------------------------------- */
48
49
struct file *hf_file;
49
struct aufs_branch *hf_br;
50
struct au_branch *hf_br;
54
55
atomic_t fi_generation;
56
struct aufs_rwsem fi_rwsem;
57
struct aufs_hfile *fi_hfile;
57
struct au_rwsem fi_rwsem;
58
struct au_hfile *fi_hfile;
58
59
aufs_bindex_t fi_bstart, fi_bend;
61
62
struct vm_operations_struct *fi_h_vm_ops;
62
struct aufs_vdir *fi_vdir_cache;
63
struct au_vdir *fi_vdir_cache;
89
struct aufs_finfo *ftofi(struct file *file);
90
aufs_bindex_t fbstart(struct file *file);
91
aufs_bindex_t fbend(struct file *file);
92
struct aufs_vdir *fvdir_cache(struct file *file);
93
struct aufs_branch *ftobr(struct file *file, aufs_bindex_t bindex);
90
struct au_finfo *au_fi(struct file *file);
91
struct au_branch *au_fbr(struct file *file, aufs_bindex_t bindex);
94
92
struct file *au_h_fptr_i(struct file *file, aufs_bindex_t bindex);
95
struct file *au_h_fptr(struct file *file);
97
void set_fbstart(struct file *file, aufs_bindex_t bindex);
98
void set_fbend(struct file *file, aufs_bindex_t bindex);
99
void set_fvdir_cache(struct file *file, struct aufs_vdir *vdir_cache);
100
void au_hfput(struct aufs_hfile *hf);
101
void set_h_fptr(struct file *file, aufs_bindex_t bindex, struct file *h_file);
102
void au_update_figen(struct file *file);
94
void au_hfput(struct au_hfile *hf);
95
void au_set_h_fptr(struct file *file, aufs_bindex_t bindex,
104
98
void au_finfo_fin(struct file *file);
105
99
int au_finfo_init(struct file *file);
101
#ifdef CONFIG_AUFS_ROBR
103
struct file *au_robr_safe_file(struct vm_area_struct *vma);
104
void au_robr_reset_file(struct vm_area_struct *vma, struct file *file);
107
struct file *au_robr_safe_file(struct vm_area_struct *vma)
112
if (file->private_data && au_test_aufs(file->f_dentry->d_sb))
118
void au_robr_reset_file(struct vm_area_struct *vma, struct file *file)
121
smp_mb(); /* flush vm_file */
123
#endif /* CONFIG_AUFS_ROBR */
107
125
/* ---------------------------------------------------------------------- */
109
127
static inline au_gen_t au_figen(struct file *f)
111
return atomic_read(&ftofi(f)->fi_generation);
129
return atomic_read(&au_fi(f)->fi_generation);
114
132
static inline int au_test_mmapped(struct file *f)
116
return !!(ftofi(f)->fi_h_vm_ops);
134
return !!(au_fi(f)->fi_h_vm_ops);
119
137
static inline int au_test_aufs_file(struct file *f)
165
183
* fi_read_lock, fi_write_lock,
166
184
* fi_read_unlock, fi_write_unlock, fi_downgrade_lock
168
SimpleRwsemFuncs(fi, struct file *f, ftofi(f)->fi_rwsem);
186
AuSimpleRwsemFuncs(fi, struct file *f, au_fi(f)->fi_rwsem);
170
188
/* to debug easier, do not make them inlined functions */
171
189
#define FiMustReadLock(f) do { \
172
190
SiMustAnyLock((f)->f_dentry->d_sb); \
173
RwMustReadLock(&ftofi(f)->fi_rwsem); \
191
AuRwMustReadLock(&au_fi(f)->fi_rwsem); \
176
194
#define FiMustWriteLock(f) do { \
177
195
SiMustAnyLock((f)->f_dentry->d_sb); \
178
RwMustWriteLock(&ftofi(f)->fi_rwsem); \
196
AuRwMustWriteLock(&au_fi(f)->fi_rwsem); \
181
199
#define FiMustAnyLock(f) do { \
182
200
SiMustAnyLock((f)->f_dentry->d_sb); \
183
RwMustAnyLock(&ftofi(f)->fi_rwsem); \
201
AuRwMustAnyLock(&au_fi(f)->fi_rwsem); \
186
#define FiMustNoWaiters(f) RwMustNoWaiters(&ftofi(f)->fi_rwsem)
204
#define FiMustNoWaiters(f) AuRwMustNoWaiters(&au_fi(f)->fi_rwsem)
206
/* ---------------------------------------------------------------------- */
209
static inline aufs_bindex_t au_fbstart(struct file *file)
212
return au_fi(file)->fi_bstart;
215
static inline aufs_bindex_t au_fbend(struct file *file)
218
return au_fi(file)->fi_bend;
221
static inline struct au_vdir *au_fvdir_cache(struct file *file)
224
return au_fi(file)->fi_vdir_cache;
227
static inline struct file *au_h_fptr(struct file *file)
229
return au_h_fptr_i(file, au_fbstart(file));
232
static inline void au_set_fbstart(struct file *file, aufs_bindex_t bindex)
234
FiMustWriteLock(file);
235
AuDebugOn(au_sbend(file->f_dentry->d_sb) < bindex);
236
au_fi(file)->fi_bstart = bindex;
239
static inline void au_set_fbend(struct file *file, aufs_bindex_t bindex)
241
FiMustWriteLock(file);
242
AuDebugOn(au_sbend(file->f_dentry->d_sb) < bindex
243
|| bindex < au_fbstart(file));
244
au_fi(file)->fi_bend = bindex;
247
static inline void au_set_fvdir_cache(struct file *file,
248
struct au_vdir *vdir_cache)
250
FiMustWriteLock(file);
251
AuDebugOn(!S_ISDIR(file->f_dentry->d_inode->i_mode)
252
|| (au_fi(file)->fi_vdir_cache && vdir_cache));
253
au_fi(file)->fi_vdir_cache = vdir_cache;
256
static inline void au_update_figen(struct file *file)
258
atomic_set(&au_fi(file)->fi_generation, au_digen(file->f_dentry));
259
//smp_mb(); /* atomic_set */
188
262
#endif /* __KERNEL__ */
189
263
#endif /* __AUFS_FILE_H__ */