~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs/inode.h

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
/*
20
20
 * inode operations
21
21
 *
22
 
 * $Id: inode.h,v 1.51 2008/03/31 07:45:32 sfjro Exp $
 
22
 * $Id: inode.h,v 1.53 2008/04/13 23:43:16 sfjro Exp $
23
23
 */
24
24
 
25
25
#ifndef __AUFS_INODE_H__
29
29
 
30
30
#include <linux/fs.h>
31
31
#include <linux/namei.h>
 
32
#include <linux/security.h>
32
33
#include <linux/aufs_type.h>
33
34
#include "misc.h"
34
35
 
35
 
struct aufs_hinode;
36
 
struct aufs_vdir;
37
 
struct aufs_iinfo {
 
36
struct au_hinode;
 
37
struct au_vdir;
 
38
struct au_iinfo {
38
39
        atomic_t                ii_generation;
39
40
        struct super_block      *ii_hsb1;       /* no get/put */
40
41
 
41
 
        struct aufs_rwsem       ii_rwsem;
 
42
        struct au_rwsem         ii_rwsem;
42
43
        aufs_bindex_t           ii_bstart, ii_bend;
43
 
        struct aufs_hinode      *ii_hinode;
44
 
        struct aufs_vdir        *ii_vdir;
 
44
        struct au_hinode        *ii_hinode;
 
45
        struct au_vdir          *ii_vdir;
45
46
};
46
47
 
47
48
struct aufs_icntnr {
48
 
        struct aufs_iinfo iinfo;
 
49
        struct au_iinfo iinfo;
49
50
        struct inode vfs_inode;
50
51
};
51
52
 
55
56
int au_refresh_hinode_self(struct inode *inode);
56
57
int au_refresh_hinode(struct inode *inode, struct dentry *dentry);
57
58
struct inode *au_new_inode(struct dentry *dentry);
 
59
int au_test_ro(struct super_block *sb, aufs_bindex_t bindex,
 
60
               struct inode *inode);
 
61
int au_test_h_perm(struct inode *h_inode, int mask, int dlgt);
 
62
int au_test_h_perm_sio(struct inode *h_inode, int mask, int dlgt);
58
63
 
59
64
/* i_op.c */
60
65
extern struct inode_operations aufs_iop, aufs_symlink_iop, aufs_dir_iop;
75
80
              struct au_wr_dir_args *args);
76
81
 
77
82
/* i_op_add.c */
78
 
struct aufs_ndx;
 
83
struct au_ndx;
79
84
int au_may_add(struct dentry *dentry, aufs_bindex_t bindex,
80
 
               struct dentry *h_parent, int isdir, struct aufs_ndx *ndx);
 
85
               struct dentry *h_parent, int isdir, struct au_ndx *ndx);
81
86
int aufs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
82
87
int aufs_symlink(struct inode *dir, struct dentry *dentry, const char *symname);
83
88
int aufs_create(struct inode *dir, struct dentry *dentry, int mode,
90
95
int au_wr_dir_need_wh(struct dentry *dentry, int isdir, aufs_bindex_t *bcpup,
91
96
                      struct dentry *locked);
92
97
int au_may_del(struct dentry *dentry, aufs_bindex_t bindex,
93
 
               struct dentry *h_parent, int isdir, struct aufs_ndx *ndx);
 
98
               struct dentry *h_parent, int isdir, struct au_ndx *ndx);
94
99
int aufs_unlink(struct inode *dir, struct dentry *dentry);
95
100
int aufs_rmdir(struct inode *dir, struct dentry *dentry);
96
101
 
99
104
int aufs_rename(struct inode *src_dir, struct dentry *src_dentry,
100
105
                struct inode *dir, struct dentry *dentry);
101
106
 
 
107
#ifdef CONFIG_AUFS_DLGT
 
108
/* dlgt.c */
 
109
int au_security_inode_permission(struct inode *h_inode, int mask,
 
110
                                 struct nameidata *fake_nd, int dlgt);
 
111
#else
 
112
static inline
 
113
int au_security_inode_permission(struct inode *h_inode, int mask,
 
114
                                 struct nameidata *fake_nd, int dlgt)
 
115
{
 
116
        return security_inode_permission(h_inode, mask, fake_nd);
 
117
}
 
118
#endif /* CONFIG_AUFS_DLGT */
 
119
 
 
120
#ifdef CONFIG_AUFS_WORKAROUND_FUSE
 
121
/* br_fuse.c */
 
122
int aufs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *st);
 
123
#endif
 
124
 
102
125
#if 0 // xattr
103
126
/* xattr.c */
104
127
int aufs_setxattr(struct dentry *dentry, const char *name, const void *value,
110
133
#endif
111
134
 
112
135
/* iinfo.c */
113
 
struct aufs_iinfo *itoii(struct inode *inode);
114
 
aufs_bindex_t ibstart(struct inode *inode);
115
 
aufs_bindex_t ibend(struct inode *inode);
116
 
struct aufs_vdir *ivdir(struct inode *inode);
117
 
struct dentry *au_hi_wh(struct inode *inode, aufs_bindex_t bindex);
 
136
struct au_iinfo *au_ii(struct inode *inode);
118
137
struct inode *au_h_iptr_i(struct inode *inode, aufs_bindex_t bindex);
119
 
struct inode *au_h_iptr(struct inode *inode);
120
 
aufs_bindex_t itoid_index(struct inode *inode, aufs_bindex_t bindex);
 
138
aufs_bindex_t au_ii_br_id(struct inode *inode, aufs_bindex_t bindex);
121
139
 
122
 
void set_ibstart(struct inode *inode, aufs_bindex_t bindex);
123
 
void set_ibend(struct inode *inode, aufs_bindex_t bindex);
124
 
void set_ivdir(struct inode *inode, struct aufs_vdir *vdir);
125
 
void set_hi_wh(struct inode *inode, aufs_bindex_t bindex, struct dentry *h_wh);
126
 
void aufs_hiput(struct aufs_hinode *hinode);
 
140
void au_set_ibstart(struct inode *inode, aufs_bindex_t bindex);
 
141
void au_set_hi_wh(struct inode *inode, aufs_bindex_t bindex,
 
142
                  struct dentry *h_wh);
127
143
unsigned int au_hi_flags(struct inode *inode, int isdir);
128
 
struct aufs_hinode *itohi(struct inode *inode, aufs_bindex_t bindex);
129
144
 
130
145
/* hinode flags */
131
146
#define AuHi_XINO       1
133
148
#define au_ftest_hi(flags, name)        ((flags) & AuHi_##name)
134
149
#define au_fset_hi(flags, name)         { (flags) |= AuHi_##name; }
135
150
#define au_fclr_hi(flags, name)         { (flags) &= ~AuHi_##name; }
 
151
#ifndef CONFIG_AUFS_HINOTIFY
 
152
#undef AuHi_NOTIFY
 
153
#define AuHi_NOTIFY     0
 
154
#endif
136
155
 
137
 
void set_h_iptr(struct inode *inode, aufs_bindex_t bindex,
138
 
                struct inode *h_inode, unsigned int flags);
 
156
void au_set_h_iptr(struct inode *inode, aufs_bindex_t bindex,
 
157
                   struct inode *h_inode, unsigned int flags);
139
158
 
140
159
void au_update_iigen(struct inode *inode);
141
160
void au_update_brange(struct inode *inode, int do_put_zero);
145
164
 
146
165
/* plink.c */
147
166
#ifdef CONFIG_AUFS_DEBUG
148
 
void au_list_plink(struct super_block *sb);
 
167
void au_plink_list(struct super_block *sb);
149
168
#else
150
 
static inline void au_list_plink(struct super_block *sb)
 
169
static inline void au_plink_list(struct super_block *sb)
151
170
{
152
171
        /* nothing */
153
172
}
154
173
#endif
155
 
int au_test_plink(struct super_block *sb, struct inode *inode);
156
 
struct dentry *au_lkup_plink(struct super_block *sb, aufs_bindex_t bindex,
 
174
int au_plink_test(struct super_block *sb, struct inode *inode);
 
175
struct dentry *au_plink_lkup(struct super_block *sb, aufs_bindex_t bindex,
157
176
                             struct inode *inode);
158
 
void au_append_plink(struct super_block *sb, struct inode *inode,
 
177
void au_plink_append(struct super_block *sb, struct inode *inode,
159
178
                     struct dentry *h_dentry, aufs_bindex_t bindex);
160
 
void au_put_plink(struct super_block *sb);
161
 
void au_half_refresh_plink(struct super_block *sb, aufs_bindex_t br_id);
162
 
 
163
 
/* ---------------------------------------------------------------------- */
164
 
 
165
 
/* tiny test for inode number */
166
 
/* tmpfs generation is too rough */
167
 
static inline int au_test_higen(struct inode *inode, struct inode *h_inode)
168
 
{
169
 
        //IiMustAnyLock(inode);
170
 
        return !(itoii(inode)->ii_hsb1 == h_inode->i_sb
171
 
                 && inode->i_generation == h_inode->i_generation);
172
 
}
173
 
 
174
 
static inline au_gen_t au_iigen(struct inode *inode)
175
 
{
176
 
        return atomic_read(&itoii(inode)->ii_generation);
177
 
}
178
 
 
179
 
#ifdef CONFIG_AUFS_HINOTIFY
180
 
static inline au_gen_t au_iigen_dec(struct inode *inode)
181
 
{
182
 
        //AuDbg("i%lu\n", inode->i_ino);
183
 
        return atomic_dec_return(&itoii(inode)->ii_generation);
184
 
}
185
 
#endif
 
179
void au_plink_put(struct super_block *sb);
 
180
void au_plink_half_refresh(struct super_block *sb, aufs_bindex_t br_id);
186
181
 
187
182
/* ---------------------------------------------------------------------- */
188
183
 
208
203
 * ii_read_lock_parent4, ii_write_lock_parent4,
209
204
 * ii_read_lock_new, ii_write_lock_new
210
205
 */
211
 
#define ReadLockFunc(name, lsc) \
 
206
#define AuReadLockFunc(name, lsc) \
212
207
static inline void ii_read_lock_##name(struct inode *i) \
213
 
{ rw_read_lock_nested(&itoii(i)->ii_rwsem, AuLsc_II_##lsc); }
 
208
{ au_rw_read_lock_nested(&au_ii(i)->ii_rwsem, AuLsc_II_##lsc); }
214
209
 
215
 
#define WriteLockFunc(name, lsc) \
 
210
#define AuWriteLockFunc(name, lsc) \
216
211
static inline void ii_write_lock_##name(struct inode *i) \
217
 
{ rw_write_lock_nested(&itoii(i)->ii_rwsem, AuLsc_II_##lsc); }
218
 
 
219
 
#define RWLockFuncs(name, lsc) \
220
 
        ReadLockFunc(name, lsc) \
221
 
        WriteLockFunc(name, lsc)
222
 
 
223
 
RWLockFuncs(child, CHILD);
224
 
RWLockFuncs(child2, CHILD2);
225
 
RWLockFuncs(child3, CHILD3);
226
 
RWLockFuncs(parent, PARENT);
227
 
RWLockFuncs(parent2, PARENT2);
228
 
RWLockFuncs(parent3, PARENT3);
229
 
RWLockFuncs(parent4, PARENT4);
230
 
RWLockFuncs(new, NEW);
231
 
 
232
 
#undef ReadLockFunc
233
 
#undef WriteLockFunc
234
 
#undef RWLockFunc
 
212
{ au_rw_write_lock_nested(&au_ii(i)->ii_rwsem, AuLsc_II_##lsc); }
 
213
 
 
214
#define AuRWLockFuncs(name, lsc) \
 
215
        AuReadLockFunc(name, lsc) \
 
216
        AuWriteLockFunc(name, lsc)
 
217
 
 
218
AuRWLockFuncs(child, CHILD);
 
219
AuRWLockFuncs(child2, CHILD2);
 
220
AuRWLockFuncs(child3, CHILD3);
 
221
AuRWLockFuncs(parent, PARENT);
 
222
AuRWLockFuncs(parent2, PARENT2);
 
223
AuRWLockFuncs(parent3, PARENT3);
 
224
AuRWLockFuncs(parent4, PARENT4);
 
225
AuRWLockFuncs(new, NEW);
 
226
 
 
227
#undef AuReadLockFunc
 
228
#undef AuWriteLockFunc
 
229
#undef AuRWLockFuncs
235
230
 
236
231
/*
237
232
 * ii_read_unlock, ii_write_unlock, ii_downgrade_lock
238
233
 */
239
 
SimpleUnlockRwsemFuncs(ii, struct inode *i, itoii(i)->ii_rwsem);
 
234
AuSimpleUnlockRwsemFuncs(ii, struct inode *i, au_ii(i)->ii_rwsem);
240
235
 
241
236
/* to debug easier, do not make them inlined functions */
242
237
#define IiMustReadLock(i) do { \
243
238
        SiMustAnyLock((i)->i_sb); \
244
 
        RwMustReadLock(&itoii(i)->ii_rwsem); \
 
239
        AuRwMustReadLock(&au_ii(i)->ii_rwsem); \
245
240
} while (0)
246
241
 
247
242
#define IiMustWriteLock(i) do { \
248
243
        SiMustAnyLock((i)->i_sb); \
249
 
        RwMustWriteLock(&itoii(i)->ii_rwsem); \
 
244
        AuRwMustWriteLock(&au_ii(i)->ii_rwsem); \
250
245
} while (0)
251
246
 
252
247
#define IiMustAnyLock(i) do { \
253
248
        SiMustAnyLock((i)->i_sb); \
254
 
        RwMustAnyLock(&itoii(i)->ii_rwsem); \
 
249
        AuRwMustAnyLock(&au_ii(i)->ii_rwsem); \
255
250
} while (0)
256
251
 
257
 
#define IiMustNoWaiters(i)      RwMustNoWaiters(&itoii(i)->ii_rwsem)
 
252
#define IiMustNoWaiters(i)      AuRwMustNoWaiters(&au_ii(i)->ii_rwsem)
 
253
 
 
254
/* ---------------------------------------------------------------------- */
 
255
 
 
256
static inline aufs_bindex_t au_ibstart(struct inode *inode)
 
257
{
 
258
        IiMustAnyLock(inode);
 
259
        return au_ii(inode)->ii_bstart;
 
260
}
 
261
 
 
262
static inline aufs_bindex_t au_ibend(struct inode *inode)
 
263
{
 
264
        IiMustAnyLock(inode);
 
265
        return au_ii(inode)->ii_bend;
 
266
}
 
267
 
 
268
static inline struct au_vdir *au_ivdir(struct inode *inode)
 
269
{
 
270
        IiMustAnyLock(inode);
 
271
        AuDebugOn(!S_ISDIR(inode->i_mode));
 
272
        return au_ii(inode)->ii_vdir;
 
273
}
 
274
 
 
275
static inline struct dentry *au_hi_wh(struct inode *inode, aufs_bindex_t bindex)
 
276
{
 
277
        struct au_hinode *hinode;
 
278
        IiMustAnyLock(inode);
 
279
        hinode = au_ii(inode)->ii_hinode + bindex;
 
280
        return hinode->hi_whdentry;
 
281
}
 
282
 
 
283
static inline struct inode *au_h_iptr(struct inode *inode)
 
284
{
 
285
        return au_h_iptr_i(inode, au_ibstart(inode));
 
286
}
 
287
 
 
288
static inline void au_set_ibend(struct inode *inode, aufs_bindex_t bindex)
 
289
{
 
290
        IiMustWriteLock(inode);
 
291
        AuDebugOn(au_sbend(inode->i_sb) < bindex || bindex < au_ibstart(inode));
 
292
        au_ii(inode)->ii_bend = bindex;
 
293
}
 
294
 
 
295
static inline void au_set_ivdir(struct inode *inode, struct au_vdir *vdir)
 
296
{
 
297
        IiMustWriteLock(inode);
 
298
        AuDebugOn(!S_ISDIR(inode->i_mode) || (au_ii(inode)->ii_vdir && vdir));
 
299
        au_ii(inode)->ii_vdir = vdir;
 
300
}
 
301
 
 
302
static inline void au_hiput(struct au_hinode *hinode)
 
303
{
 
304
        au_hin_free(hinode);
 
305
        dput(hinode->hi_whdentry);
 
306
        iput(hinode->hi_inode);
 
307
}
 
308
 
 
309
static inline struct au_hinode *au_hi(struct inode *inode, aufs_bindex_t bindex)
 
310
{
 
311
        //todo: this lock check causes some unnecessary locks in callers.
 
312
        IiMustAnyLock(inode);
 
313
        return au_ii(inode)->ii_hinode + bindex;
 
314
}
 
315
 
 
316
/* tiny test for inode number */
 
317
/* tmpfs generation is too rough */
 
318
static inline int au_test_higen(struct inode *inode, struct inode *h_inode)
 
319
{
 
320
        //IiMustAnyLock(inode);
 
321
        return !(au_ii(inode)->ii_hsb1 == h_inode->i_sb
 
322
                 && inode->i_generation == h_inode->i_generation);
 
323
}
 
324
 
 
325
static inline au_gen_t au_iigen(struct inode *inode)
 
326
{
 
327
        return atomic_read(&au_ii(inode)->ii_generation);
 
328
}
 
329
 
 
330
#ifdef CONFIG_AUFS_HINOTIFY
 
331
static inline au_gen_t au_iigen_dec(struct inode *inode)
 
332
{
 
333
        //AuDbg("i%lu\n", inode->i_ino);
 
334
        return atomic_dec_return(&au_ii(inode)->ii_generation);
 
335
}
 
336
#endif
258
337
 
259
338
#endif /* __KERNEL__ */
260
339
#endif /* __AUFS_INODE_H__ */