168
169
(sbinfo)->si_wbr_create_ops->create(args)
170
171
/* flags for si_read_lock()/aufs_read_lock()/di_read_lock() */
172
#define AuLock_IR (1 << 1)
173
#define AuLock_IW (1 << 2)
174
#define AuLock_FLUSH (1 << 3)
175
#define AuLock_DIR (1 << 4)
172
#define AuLock_DW 1 /* write-lock dentry */
173
#define AuLock_IR (1 << 1) /* read-lock inode */
174
#define AuLock_IW (1 << 2) /* write-lock inode */
175
#define AuLock_FLUSH (1 << 3) /* wait for 'nowait' tasks */
176
#define AuLock_DIR (1 << 4) /* target is a dir */
176
177
#define au_ftest_lock(flags, name) ((flags) & AuLock_##name)
177
178
#define au_fset_lock(flags, name) { (flags) |= AuLock_##name; }
178
179
#define au_fclr_lock(flags, name) { (flags) &= ~AuLock_##name; }
180
181
/* ---------------------------------------------------------------------- */
184
int au_show_brs(struct seq_file *seq, struct super_block *sb);
185
184
extern struct file_system_type aufs_fs_type;
188
struct aufs_sbinfo *stosi(struct super_block *sb);
189
aufs_bindex_t sbend(struct super_block *sb);
190
struct aufs_branch *stobr(struct super_block *sb, aufs_bindex_t bindex);
191
au_gen_t au_sigen(struct super_block *sb);
187
struct au_branch *au_sbr(struct super_block *sb, aufs_bindex_t bindex);
192
188
au_gen_t au_sigen_inc(struct super_block *sb);
193
int find_bindex(struct super_block *sb, struct aufs_branch *br);
189
int au_find_bindex(struct super_block *sb, struct au_branch *br);
195
191
void aufs_read_lock(struct dentry *dentry, int flags);
196
192
void aufs_read_unlock(struct dentry *dentry, int flags);
217
218
static inline int au_test_aufs(struct super_block *sb)
219
#ifdef AUFS_SUPER_MAGIC
220
220
return (sb->s_magic == AUFS_SUPER_MAGIC);
223
static inline int au_test_nfs(struct super_block *sb)
225
#ifdef CONFIG_AUFS_BR_NFS
226
return (sb->s_magic == NFS_SUPER_MAGIC);
222
return !strcmp(au_sbtype(sb), AUFS_FSTYPE);
226
232
static inline int au_test_fuse(struct super_block *sb)
229
234
#ifdef CONFIG_AUFS_WORKAROUND_FUSE
230
235
#ifdef FUSE_SUPER_MAGIC
231
236
BUILD_BUG_ON(FUSE_SUPER_MAGIC != 0x65735546);
232
ret = (sb->s_magic == FUSE_SUPER_MAGIC);
237
return (sb->s_magic == FUSE_SUPER_MAGIC);
234
ret = !strcmp(au_sbtype(sb), "fuse");
239
return !strcmp(au_sbtype(sb), "fuse");
240
245
static inline int au_test_xfs(struct super_block *sb)
243
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) \
244
&& (defined(CONFIG_XFS_FS) || defined(CONFIG_XFS_FS_MODULE))
247
#ifdef CONFIG_AUFS_BR_XFS
245
248
#ifdef XFS_SB_MAGIC
246
249
BUILD_BUG_ON(XFS_SB_MAGIC != 0x58465342);
247
ret = (sb->s_magic == XFS_SB_MAGIC);
249
ret = !strcmp(au_sbtype(sb), "xfs");
255
static inline int au_test_nfs(struct super_block *sb)
257
#if defined(CONFIG_NFS_FS) || defined(CONFIG_NFS_FS_MODULE)
258
return (sb->s_magic == NFS_SUPER_MAGIC);
250
return (sb->s_magic == XFS_SB_MAGIC);
252
return !strcmp(au_sbtype(sb), "xfs");
264
258
static inline int au_test_tmpfs(struct super_block *sb)
267
260
#ifdef CONFIG_TMPFS
268
261
#ifdef TMPFS_MAGIC
269
262
BUILD_BUG_ON(TMPFS_MAGIC != 0x01021994);
270
ret = (sb->s_magic == TMPFS_MAGIC);
263
return (sb->s_magic == TMPFS_MAGIC);
272
ret = !strcmp(au_sbtype(sb), "tmpfs");
278
static inline int au_test_trunc_xino(struct super_block *sb)
280
return au_test_tmpfs(sb);
283
/* temporary support for i#1 in cramfs */
284
static inline int au_test_unique_ino(struct dentry *h_dentry, ino_t h_ino)
286
#if defined(CONFIG_CRAMFS) || defined(CONFIG_CRAMFS_MODULE)
287
if (unlikely(h_dentry->d_sb->s_magic == CRAMFS_MAGIC))
265
return !strcmp(au_sbtype(sb), "tmpfs");
271
/* ---------------------------------------------------------------------- */
293
273
#ifdef CONFIG_AUFS_EXPORT
294
274
extern struct export_operations aufs_export_op;
363
339
/* ---------------------------------------------------------------------- */
365
/* limited support before 2.6.18 */
366
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
367
static inline void au_mntget(struct super_block *sb)
369
mntget(stosi(sb)->si_mnt);
372
static inline void au_mntput(struct super_block *sb)
374
mntput(stosi(sb)->si_mnt);
377
static inline void au_sbilist_del(struct aufs_sbinfo *sbinfo)
379
list_del(&sbinfo->si_list);
382
static inline void au_mntget(struct super_block *sb)
387
static inline void au_mntput(struct super_block *sb)
392
static inline void au_sbilist_del(struct aufs_sbinfo *sbinfo)
396
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) */
398
/* ---------------------------------------------------------------------- */
400
static inline unsigned int au_flag_test_shwh(struct super_block *sb)
402
#ifdef CONFIG_AUFS_SHWH
403
return (AuFlag(stosi(sb), f_shwh));
409
/* ---------------------------------------------------------------------- */
411
static inline unsigned int au_flag_test_udba_inotify(struct super_block *sb)
413
#ifdef CONFIG_AUFS_HINOTIFY
414
return (AuFlag(stosi(sb), f_udba) == AuUdba_INOTIFY);
420
#ifdef CONFIG_AUFS_DLGT
421
static inline int au_need_dlgt(struct super_block *sb)
423
return (AuFlag(stosi(sb), f_dlgt) && !au_test_wkq(current));
426
static inline int au_need_dirperm1(struct super_block *sb)
428
return (AuFlag(stosi(sb), f_dirperm1) && !au_test_wkq(current));
431
static inline int au_need_dlgt(struct super_block *sb)
436
static inline int au_need_dirperm1(struct super_block *sb)
442
/* ---------------------------------------------------------------------- */
444
341
/* lock superblock. mainly for entry point functions */
446
343
* si_noflush_read_lock, si_noflush_write_lock,
447
344
* si_read_unlock, si_write_unlock, si_downgrade_lock
449
SimpleLockRwsemFuncs(si_noflush, struct super_block *sb, stosi(sb)->si_rwsem);
450
SimpleUnlockRwsemFuncs(si, struct super_block *sb, stosi(sb)->si_rwsem);
346
AuSimpleLockRwsemFuncs(si_noflush, struct super_block *sb,
347
au_sbi(sb)->si_rwsem);
348
AuSimpleUnlockRwsemFuncs(si, struct super_block *sb, au_sbi(sb)->si_rwsem);
452
350
static inline void si_read_lock(struct super_block *sb, int flags)
454
352
if (au_ftest_lock(flags, FLUSH))
455
au_nwt_flush(&stosi(sb)->si_nowait);
353
au_nwt_flush(&au_sbi(sb)->si_nowait);
456
354
si_noflush_read_lock(sb);
459
357
static inline void si_write_lock(struct super_block *sb)
461
au_nwt_flush(&stosi(sb)->si_nowait);
359
au_nwt_flush(&au_sbi(sb)->si_nowait);
462
360
si_noflush_write_lock(sb);
465
363
static inline int si_read_trylock(struct super_block *sb, int flags)
467
365
if (au_ftest_lock(flags, FLUSH))
468
au_nwt_flush(&stosi(sb)->si_nowait);
366
au_nwt_flush(&au_sbi(sb)->si_nowait);
469
367
return si_noflush_read_trylock(sb);
472
370
static inline int si_write_trylock(struct super_block *sb, int flags)
474
372
if (au_ftest_lock(flags, FLUSH))
475
au_nwt_flush(&stosi(sb)->si_nowait);
373
au_nwt_flush(&au_sbi(sb)->si_nowait);
476
374
return si_noflush_write_trylock(sb);
479
377
/* to debug easier, do not make them inlined functions */
480
#define SiMustReadLock(sb) RwMustReadLock(&stosi(sb)->si_rwsem)
481
#define SiMustWriteLock(sb) RwMustWriteLock(&stosi(sb)->si_rwsem)
482
#define SiMustAnyLock(sb) RwMustAnyLock(&stosi(sb)->si_rwsem)
378
#define SiMustReadLock(sb) AuRwMustReadLock(&au_sbi(sb)->si_rwsem)
379
#define SiMustWriteLock(sb) AuRwMustWriteLock(&au_sbi(sb)->si_rwsem)
380
#define SiMustAnyLock(sb) AuRwMustAnyLock(&au_sbi(sb)->si_rwsem)
382
/* ---------------------------------------------------------------------- */
384
static inline aufs_bindex_t au_sbend(struct super_block *sb)
387
return au_sbi(sb)->si_bend;
390
static inline unsigned int au_mntflags(struct super_block *sb)
393
return au_sbi(sb)->si_mntflags;
396
static inline au_gen_t au_sigen(struct super_block *sb)
399
return au_sbi(sb)->si_generation;
402
/* ---------------------------------------------------------------------- */
404
/* limited support before 2.6.18 */
405
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
406
static inline void au_mntget(struct super_block *sb)
408
mntget(au_sbi(sb)->si_mnt);
411
static inline void au_mntput(struct super_block *sb)
413
mntput(au_sbi(sb)->si_mnt);
416
static inline void au_mntget(struct super_block *sb)
421
static inline void au_mntput(struct super_block *sb)
425
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) */
484
427
#endif /* __KERNEL__ */
485
428
#endif /* __AUFS_SUPER_H__ */