~ubuntu-branches/ubuntu/raring/aufs/raring

« back to all changes in this revision

Viewing changes to fs/aufs/file.h

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20080506183550-7y7mrzkzkh2tjlfu
Tags: upstream-0+20080506
ImportĀ upstreamĀ versionĀ 0+20080506

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
/*
20
20
 * file operations
21
21
 *
22
 
 * $Id: file.h,v 1.35 2008/03/31 07:45:32 sfjro Exp $
 
22
 * $Id: file.h,v 1.36 2008/04/13 23:40:58 sfjro Exp $
23
23
 */
24
24
 
25
25
#ifndef __AUFS_FILE_H__
29
29
 
30
30
#include <linux/file.h>
31
31
#include <linux/fs.h>
 
32
#include <linux/mm.h>
32
33
#include <linux/version.h>
33
34
#include <linux/aufs_type.h>
34
35
#include "misc.h"
43
44
 
44
45
/* ---------------------------------------------------------------------- */
45
46
 
46
 
struct aufs_branch;
47
 
struct aufs_hfile {
 
47
struct au_branch;
 
48
struct au_hfile {
48
49
        struct file             *hf_file;
49
 
        struct aufs_branch      *hf_br;
 
50
        struct au_branch        *hf_br;
50
51
};
51
52
 
52
 
struct aufs_vdir;
53
 
struct aufs_finfo {
 
53
struct au_vdir;
 
54
struct au_finfo {
54
55
        atomic_t                fi_generation;
55
56
 
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;
59
60
 
60
61
        union {
61
62
                struct vm_operations_struct     *fi_h_vm_ops;
62
 
                struct aufs_vdir                *fi_vdir_cache;
 
63
                struct au_vdir                  *fi_vdir_cache;
63
64
        };
64
65
};
65
66
 
86
87
#endif
87
88
 
88
89
/* finfo.c */
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);
96
93
 
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,
 
96
                   struct file *h_file);
103
97
 
104
98
void au_finfo_fin(struct file *file);
105
99
int au_finfo_init(struct file *file);
106
100
 
 
101
#ifdef CONFIG_AUFS_ROBR
 
102
/* robr.c */
 
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);
 
105
#else
 
106
static inline
 
107
struct file *au_robr_safe_file(struct vm_area_struct *vma)
 
108
{
 
109
        struct file *file;
 
110
 
 
111
        file = vma->vm_file;
 
112
        if (file->private_data && au_test_aufs(file->f_dentry->d_sb))
 
113
                return file;
 
114
        return NULL;
 
115
}
 
116
 
 
117
static inline
 
118
void au_robr_reset_file(struct vm_area_struct *vma, struct file *file)
 
119
{
 
120
        vma->vm_file = file;
 
121
        smp_mb(); /* flush vm_file */
 
122
}
 
123
#endif /* CONFIG_AUFS_ROBR */
 
124
 
107
125
/* ---------------------------------------------------------------------- */
108
126
 
109
127
static inline au_gen_t au_figen(struct file *f)
110
128
{
111
 
        return atomic_read(&ftofi(f)->fi_generation);
 
129
        return atomic_read(&au_fi(f)->fi_generation);
112
130
}
113
131
 
114
132
static inline int au_test_mmapped(struct file *f)
115
133
{
116
 
        return !!(ftofi(f)->fi_h_vm_ops);
 
134
        return !!(au_fi(f)->fi_h_vm_ops);
117
135
}
118
136
 
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
167
185
 */
168
 
SimpleRwsemFuncs(fi, struct file *f, ftofi(f)->fi_rwsem);
 
186
AuSimpleRwsemFuncs(fi, struct file *f, au_fi(f)->fi_rwsem);
169
187
 
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); \
174
192
} while (0)
175
193
 
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); \
179
197
} while (0)
180
198
 
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); \
184
202
} while (0)
185
203
 
186
 
#define FiMustNoWaiters(f)      RwMustNoWaiters(&ftofi(f)->fi_rwsem)
 
204
#define FiMustNoWaiters(f)      AuRwMustNoWaiters(&au_fi(f)->fi_rwsem)
 
205
 
 
206
/* ---------------------------------------------------------------------- */
 
207
 
 
208
// hard/soft set
 
209
static inline aufs_bindex_t au_fbstart(struct file *file)
 
210
{
 
211
        FiMustAnyLock(file);
 
212
        return au_fi(file)->fi_bstart;
 
213
}
 
214
 
 
215
static inline aufs_bindex_t au_fbend(struct file *file)
 
216
{
 
217
        FiMustAnyLock(file);
 
218
        return au_fi(file)->fi_bend;
 
219
}
 
220
 
 
221
static inline struct au_vdir *au_fvdir_cache(struct file *file)
 
222
{
 
223
        FiMustAnyLock(file);
 
224
        return au_fi(file)->fi_vdir_cache;
 
225
}
 
226
 
 
227
static inline struct file *au_h_fptr(struct file *file)
 
228
{
 
229
        return au_h_fptr_i(file, au_fbstart(file));
 
230
}
 
231
 
 
232
static inline void au_set_fbstart(struct file *file, aufs_bindex_t bindex)
 
233
{
 
234
        FiMustWriteLock(file);
 
235
        AuDebugOn(au_sbend(file->f_dentry->d_sb) < bindex);
 
236
        au_fi(file)->fi_bstart = bindex;
 
237
}
 
238
 
 
239
static inline void au_set_fbend(struct file *file, aufs_bindex_t bindex)
 
240
{
 
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;
 
245
}
 
246
 
 
247
static inline void au_set_fvdir_cache(struct file *file,
 
248
                                      struct au_vdir *vdir_cache)
 
249
{
 
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;
 
254
}
 
255
 
 
256
static inline void au_update_figen(struct file *file)
 
257
{
 
258
        atomic_set(&au_fi(file)->fi_generation, au_digen(file->f_dentry));
 
259
        //smp_mb(); /* atomic_set */
 
260
}
187
261
 
188
262
#endif /* __KERNEL__ */
189
263
#endif /* __AUFS_FILE_H__ */