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

« back to all changes in this revision

Viewing changes to fs/aufs/branch.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:
17
17
 */
18
18
 
19
19
/*
20
 
 * branch filesystems and xino for them.
 
20
 * branch filesystems and xino for them
21
21
 *
22
 
 * $Id: branch.h,v 1.51 2008/03/31 07:41:17 sfjro Exp $
 
22
 * $Id: branch.h,v 1.53 2008/04/13 23:37:54 sfjro Exp $
23
23
 */
24
24
 
25
25
#ifndef __AUFS_BRANCH_H__
36
36
/* ---------------------------------------------------------------------- */
37
37
 
38
38
/* an entry in a xino file */
39
 
struct xino_entry {
 
39
struct au_xino_entry {
40
40
        ino_t ino;
41
41
        //__u32 h_gen;
42
42
} __packed;
44
44
//#define AuXino_INVALID_HGEN   (-1)
45
45
 
46
46
/* a xino file */
47
 
struct xino_file {
 
47
struct au_xino_file {
48
48
        //struct file           **xi_file;
49
49
        struct file             *xi_file;
50
50
 
61
61
 
62
62
/* protected by superblock rwsem */
63
63
struct sysaufs_br;
64
 
struct aufs_branch {
 
64
struct au_branch {
65
65
        struct file             *br_xino;
66
 
        //struct xino_file              *br_xino;
 
66
        //struct au_xino_file           *br_xino;
67
67
 
68
68
        aufs_bindex_t           br_id;
69
69
 
72
72
        atomic_t                br_count;
73
73
 
74
74
        /* whiteout base */
75
 
        struct aufs_rwsem       br_wh_rwsem;
 
75
        struct au_rwsem         br_wh_rwsem;
76
76
        struct dentry           *br_wh;
77
77
        atomic_t                br_wh_running;
78
78
 
110
110
        AuBr_Last
111
111
};
112
112
 
113
 
static inline int br_writable(int brperm)
 
113
static inline int au_br_writable(int brperm)
114
114
{
115
 
        return (brperm == AuBr_RW
116
 
                || brperm == AuBr_RWNoLinkWH);
 
115
        return (brperm == AuBr_RW || brperm == AuBr_RWNoLinkWH);
117
116
}
118
117
 
119
 
static inline int br_whable(int brperm)
 
118
static inline int au_br_whable(int brperm)
120
119
{
121
120
        return (brperm == AuBr_RW
122
121
                || brperm == AuBr_ROWH
123
122
                || brperm == AuBr_RRWH);
124
123
}
125
124
 
126
 
static inline int br_linkable_wh(int brperm)
 
125
#if 0 // rfu
 
126
static inline int au_br_linkable_wh(int brperm)
127
127
{
128
128
        return (brperm == AuBr_RW);
129
129
}
 
130
#endif
130
131
 
131
 
static inline int br_hinotifyable(int brperm)
 
132
static inline int au_br_hinotifyable(int brperm)
132
133
{
133
134
#ifdef CONFIG_AUFS_HINOTIFY
134
 
        return (brperm != AuBr_RR
135
 
                && brperm != AuBr_RRWH);
 
135
        return (brperm != AuBr_RR && brperm != AuBr_RRWH);
136
136
#else
137
137
        return 0;
138
138
#endif
141
141
/* ---------------------------------------------------------------------- */
142
142
 
143
143
/* branch.c */
144
 
struct aufs_sbinfo;
145
 
void free_branches(struct aufs_sbinfo *sinfo);
146
 
int br_rdonly(struct aufs_branch *br);
 
144
struct au_sbinfo;
 
145
void au_br_free(struct au_sbinfo *sinfo);
147
146
int au_test_def_rr(struct super_block *h_sb);
148
 
int find_brindex(struct super_block *sb, aufs_bindex_t br_id);
 
147
int au_br_index(struct super_block *sb, aufs_bindex_t br_id);
149
148
struct au_opt_add;
150
 
int br_add(struct super_block *sb, struct au_opt_add *add, int remount);
 
149
int au_br_add(struct super_block *sb, struct au_opt_add *add, int remount);
151
150
struct au_opt_del;
152
 
int br_del(struct super_block *sb, struct au_opt_del *del, int remount);
 
151
int au_br_del(struct super_block *sb, struct au_opt_del *del, int remount);
153
152
struct au_opt_mod;
154
 
int br_mod(struct super_block *sb, struct au_opt_mod *mod, int remount,
155
 
           int *do_update);
 
153
int au_br_mod(struct super_block *sb, struct au_opt_mod *mod, int remount,
 
154
              int *do_update);
156
155
 
157
156
/* xino.c */
158
 
int xib_trunc(struct super_block *sb);
 
157
int au_xib_trunc(struct super_block *sb);
159
158
 
160
 
struct file *xino_create(struct super_block *sb, char *fname, int silent,
161
 
                         struct dentry *parent);
162
 
ino_t xino_new_ino(struct super_block *sb);
163
 
int xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
164
 
                ino_t ino);
165
 
int xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
166
 
               struct xino_entry *xinoe);
167
 
int xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
168
 
              struct xino_entry *xinoe);
169
 
int xino_br(struct super_block *sb, aufs_bindex_t bindex,
170
 
            struct file *base_file, int do_test);
171
 
int xino_trunc(struct super_block *sb, aufs_bindex_t bindex);
 
159
struct file *au_xino_create(struct super_block *sb, char *fname, int silent,
 
160
                            struct dentry *parent);
 
161
ino_t au_xino_new_ino(struct super_block *sb);
 
162
int au_xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
 
163
                   ino_t ino);
 
164
int au_xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
 
165
                  struct au_xino_entry *xinoe);
 
166
int au_xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
 
167
                 struct au_xino_entry *xinoe);
 
168
int au_xino_br(struct super_block *sb, aufs_bindex_t bindex,
 
169
               struct file *base_file, int do_test);
 
170
int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex);
172
171
 
173
172
struct au_opt_xino;
174
 
int xino_set(struct super_block *sb, struct au_opt_xino *xino, int remount);
175
 
void xino_clr(struct super_block *sb);
176
 
struct file *xino_def(struct super_block *sb);
 
173
int au_xino_set(struct super_block *sb, struct au_opt_xino *xino, int remount);
 
174
void au_xino_clr(struct super_block *sb);
 
175
struct file *au_xino_def(struct super_block *sb);
177
176
 
178
177
/* ---------------------------------------------------------------------- */
179
178
 
180
 
static inline int br_count(struct aufs_branch *br)
 
179
static inline int au_br_count(struct au_branch *br)
181
180
{
182
181
        return atomic_read(&br->br_count);
183
182
}
184
183
 
185
 
static inline int br_get(struct aufs_branch *br)
 
184
static inline int au_br_get(struct au_branch *br)
186
185
{
187
186
        return atomic_inc_return(&br->br_count);
188
187
}
189
188
 
190
 
static inline int br_put(struct aufs_branch *br)
 
189
static inline int au_br_put(struct au_branch *br)
191
190
{
192
191
        return atomic_dec_return(&br->br_count);
193
192
}
194
193
 
195
 
static inline au_gen_t au_br_gen(struct aufs_branch *br)
 
194
static inline au_gen_t au_br_gen(struct au_branch *br)
196
195
{
197
196
        return br->br_generation;
198
197
}
199
198
 
 
199
/*
 
200
 * test if the @br is readonly or not.
 
201
 */
 
202
static inline int au_br_rdonly(struct au_branch *br)
 
203
{
 
204
        return ((br->br_mnt->mnt_sb->s_flags & MS_RDONLY)
 
205
                || !au_br_writable(br->br_perm))
 
206
                ? -EROFS : 0;
 
207
}
 
208
 
200
209
/* ---------------------------------------------------------------------- */
201
210
 
202
211
/* Superblock to branch */
203
 
static inline aufs_bindex_t sbr_id(struct super_block *sb, aufs_bindex_t bindex)
204
 
{
205
 
        return stobr(sb, bindex)->br_id;
206
 
}
207
 
 
208
 
static inline
209
 
struct vfsmount *sbr_mnt(struct super_block *sb, aufs_bindex_t bindex)
210
 
{
211
 
        return stobr(sb, bindex)->br_mnt;
212
 
}
213
 
 
214
 
static inline
215
 
struct super_block *sbr_sb(struct super_block *sb, aufs_bindex_t bindex)
216
 
{
217
 
        return sbr_mnt(sb, bindex)->mnt_sb;
 
212
static inline
 
213
aufs_bindex_t au_sbr_id(struct super_block *sb, aufs_bindex_t bindex)
 
214
{
 
215
        return au_sbr(sb, bindex)->br_id;
 
216
}
 
217
 
 
218
static inline
 
219
struct vfsmount *au_sbr_mnt(struct super_block *sb, aufs_bindex_t bindex)
 
220
{
 
221
        return au_sbr(sb, bindex)->br_mnt;
 
222
}
 
223
 
 
224
static inline
 
225
struct super_block *au_sbr_sb(struct super_block *sb, aufs_bindex_t bindex)
 
226
{
 
227
        return au_sbr_mnt(sb, bindex)->mnt_sb;
218
228
}
219
229
 
220
230
#if 0 // rfu
221
 
static inline int sbr_count(struct super_block *sb, aufs_bindex_t bindex)
222
 
{
223
 
        return br_count(stobr(sb, bindex));
224
 
}
225
 
 
226
 
static inline void sbr_get(struct super_block *sb, aufs_bindex_t bindex)
227
 
{
228
 
        br_get(stobr(sb, bindex));
229
 
}
230
 
#endif
231
 
 
232
 
static inline void sbr_put(struct super_block *sb, aufs_bindex_t bindex)
233
 
{
234
 
        br_put(stobr(sb, bindex));
235
 
}
236
 
 
237
 
static inline int sbr_perm(struct super_block *sb, aufs_bindex_t bindex)
238
 
{
239
 
        return stobr(sb, bindex)->br_perm;
240
 
}
241
 
 
242
 
static inline int sbr_whable(struct super_block *sb, aufs_bindex_t bindex)
243
 
{
244
 
        return br_whable(sbr_perm(sb, bindex));
245
 
}
246
 
 
247
 
/* ---------------------------------------------------------------------- */
248
 
 
249
 
#ifndef AuNoNfsBranch
 
231
static inline int au_sbr_count(struct super_block *sb, aufs_bindex_t bindex)
 
232
{
 
233
        return au_br_count(au_sbr(sb, bindex));
 
234
}
 
235
 
 
236
static inline void au_sbr_get(struct super_block *sb, aufs_bindex_t bindex)
 
237
{
 
238
        au_br_get(au_sbr(sb, bindex));
 
239
}
 
240
#endif
 
241
 
 
242
static inline void au_sbr_put(struct super_block *sb, aufs_bindex_t bindex)
 
243
{
 
244
        au_br_put(au_sbr(sb, bindex));
 
245
}
 
246
 
 
247
static inline int au_sbr_perm(struct super_block *sb, aufs_bindex_t bindex)
 
248
{
 
249
        return au_sbr(sb, bindex)->br_perm;
 
250
}
 
251
 
 
252
static inline int au_sbr_whable(struct super_block *sb, aufs_bindex_t bindex)
 
253
{
 
254
        return au_br_whable(au_sbr_perm(sb, bindex));
 
255
}
 
256
 
 
257
static inline int au_test_trunc_xino(struct super_block *sb)
 
258
{
 
259
        return au_test_tmpfs(sb);
 
260
}
 
261
 
 
262
/* temporary support for i#1 in cramfs */
 
263
static inline int au_test_unique_ino(struct dentry *h_dentry, ino_t h_ino)
 
264
{
 
265
#if defined(CONFIG_CRAMFS) || defined(CONFIG_CRAMFS_MODULE)
 
266
        if (unlikely(h_dentry->d_sb->s_magic == CRAMFS_MAGIC))
 
267
                return (h_ino != 1);
 
268
#endif
 
269
        return 1;
 
270
}
 
271
 
 
272
#ifdef CONFIG_AUFS_BR_NFS
250
273
static inline int au_test_unsupported_nfs(struct super_block *h_sb)
251
274
{
252
275
        return 0;
263
286
static inline
264
287
struct vfsmount *au_nfsmnt(struct super_block *sb, aufs_bindex_t bindex)
265
288
{
266
 
        return au_do_nfsmnt(sbr_mnt(sb, bindex));
 
289
        return au_do_nfsmnt(au_sbr_mnt(sb, bindex));
267
290
}
 
291
 
 
292
#define AuNoNfsBranchMsg "dummy"
 
293
 
268
294
#else
269
295
static inline int au_test_unsupported_nfs(struct super_block *h_sb)
270
296
{
281
307
{
282
308
        return NULL;
283
309
}
284
 
#endif /* AuNoNfsBranch */
 
310
 
 
311
#define _AuNoNfsBranchMsg "NFS branch is not supported"
 
312
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
 
313
#define AuNoNfsBranchMsg _AuNoNfsBranchMsg "."
 
314
#else //if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
 
315
#define AuNoNfsBranchMsg _AuNoNfsBranchMsg \
 
316
        ", try some configurations and patches included in aufs source CVS."
 
317
#endif
 
318
 
 
319
#endif /* CONFIG_AUFS_BR_NFS */
285
320
 
286
321
/* ---------------------------------------------------------------------- */
287
322
 
289
324
 * br_wh_read_lock, br_wh_write_lock
290
325
 * br_wh_read_unlock, br_wh_write_unlock, br_wh_downgrade_lock
291
326
 */
292
 
SimpleRwsemFuncs(br_wh, struct aufs_branch *br, br->br_wh_rwsem);
 
327
AuSimpleRwsemFuncs(br_wh, struct au_branch *br, br->br_wh_rwsem);
293
328
 
294
329
/* to debug easier, do not make them inlined functions */
295
330
#define BrWhMustReadLock(br) do { \
296
331
        /* SiMustAnyLock(sb); */ \
297
 
        RwMustReadLock(&(br)->br_wh_rwsem); \
 
332
        AuRwMustReadLock(&(br)->br_wh_rwsem); \
298
333
} while (0)
299
334
 
300
335
#define BrWhMustWriteLock(br) do { \
301
336
        /* SiMustAnyLock(sb); */ \
302
 
        RwMustWriteLock(&(br)->br_wh_rwsem); \
 
337
        AuRwMustWriteLock(&(br)->br_wh_rwsem); \
303
338
} while (0)
304
339
 
305
340
#define BrWhMustAnyLock(br) do { \
306
341
        /* SiMustAnyLock(sb); */ \
307
 
        RwMustAnyLock(&(br)->br_wh_rwsem); \
 
342
        AuRwMustAnyLock(&(br)->br_wh_rwsem); \
308
343
} while (0)
309
344
 
310
345
#endif /* __KERNEL__ */