super.h 16.7 KB
Newer Older
J. R. Okajima's avatar
J. R. Okajima committed
1
2
/* SPDX-License-Identifier: GPL-2.0 */
/*
3
 * Copyright (C) 2005-2020 Junjiro R. Okajima
4
5
6
7
8
9
10
11
12
13
14
15
16
 *
 * This program, aufs is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
J. R. Okajima's avatar
J. R. Okajima committed
17
18
19
20
21
22
23
24
25
26
27
 */

/*
 * super_block operations
 */

#ifndef __AUFS_SUPER_H__
#define __AUFS_SUPER_H__

#ifdef __KERNEL__

J. R. Okajima's avatar
J. R. Okajima committed
28
29
#include <linux/fs.h>
#include <linux/kobject.h>
J. R. Okajima's avatar
J. R. Okajima committed
30
#include "hbl.h"
31
#include "lcnt.h"
J. R. Okajima's avatar
J. R. Okajima committed
32
#include "rwsem.h"
J. R. Okajima's avatar
J. R. Okajima committed
33
#include "wkq.h"
J. R. Okajima's avatar
J. R. Okajima committed
34

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* policies to select one among multiple writable branches */
struct au_wbr_copyup_operations {
	int (*copyup)(struct dentry *dentry);
};

#define AuWbr_DIR	1		/* target is a dir */
#define AuWbr_PARENT	(1 << 1)	/* always require a parent */

#define au_ftest_wbr(flags, name)	((flags) & AuWbr_##name)
#define au_fset_wbr(flags, name)	{ (flags) |= AuWbr_##name; }
#define au_fclr_wbr(flags, name)	{ (flags) &= ~AuWbr_##name; }

struct au_wbr_create_operations {
	int (*create)(struct dentry *dentry, unsigned int flags);
	int (*init)(struct super_block *sb);
	int (*fin)(struct super_block *sb);
};

53
54
55
56
57
58
59
60
61
62
struct au_wbr_mfs {
	struct mutex	mfs_lock; /* protect this structure */
	unsigned long	mfs_jiffy;
	unsigned long	mfs_expire;
	aufs_bindex_t	mfs_bindex;

	unsigned long long	mfsrr_bytes;
	unsigned long long	mfsrr_watermark;
};

63
64
65
66
67
68
#define AuPlink_NHASH 100
static inline int au_plink_hash(ino_t ino)
{
	return ino % AuPlink_NHASH;
}

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* File-based Hierarchical Storage Management */
struct au_fhsm {
#ifdef CONFIG_AUFS_FHSM
	/* allow only one process who can receive the notification */
	spinlock_t		fhsm_spin;
	pid_t			fhsm_pid;
	wait_queue_head_t	fhsm_wqh;
	atomic_t		fhsm_readable;

	/* these are protected by si_rwsem */
	unsigned long		fhsm_expire;
	aufs_bindex_t		fhsm_bottom;
#endif
};

J. R. Okajima's avatar
J. R. Okajima committed
84
85
struct au_branch;
struct au_sbinfo {
J. R. Okajima's avatar
J. R. Okajima committed
86
87
88
	/* nowait tasks in the system-wide workqueue */
	struct au_nowait_tasks	si_nowait;

J. R. Okajima's avatar
J. R. Okajima committed
89
90
91
92
93
94
	/*
	 * tried sb->s_umount, but failed due to the dependency between i_mutex.
	 * rwsem for au_sbinfo is necessary.
	 */
	struct au_rwsem		si_rwsem;

95
	/*
96
	 * dirty approach to protect sb->sb_inodes and ->s_files (gone) from
97
98
	 * remount.
	 */
99
	au_lcnt_t		si_ninodes, si_nfiles;
100

J. R. Okajima's avatar
J. R. Okajima committed
101
	/* branch management */
J. R. Okajima's avatar
J. R. Okajima committed
102
103
	unsigned int		si_generation;

104
105
106
	/* see AuSi_ flags */
	unsigned char		au_si_status;

J. R. Okajima's avatar
J. R. Okajima committed
107
	aufs_bindex_t		si_bbot;
108
109
110
111

	/* dirty trick to keep br_id plus */
	unsigned int		si_last_br_id :
				sizeof(aufs_bindex_t) * BITS_PER_BYTE - 1;
J. R. Okajima's avatar
J. R. Okajima committed
112
113
	struct au_branch	**si_branch;

114
115
116
117
118
119
	/* policy to select a writable branch */
	unsigned char		si_wbr_copyup;
	unsigned char		si_wbr_create;
	struct au_wbr_copyup_operations *si_wbr_copyup_ops;
	struct au_wbr_create_operations *si_wbr_create_ops;

120
121
122
123
124
125
	/* round robin */
	atomic_t		si_wbr_rr_next;

	/* most free space */
	struct au_wbr_mfs	si_wbr_mfs;

126
127
128
	/* File-based Hierarchical Storage Management */
	struct au_fhsm		si_fhsm;

129
130
131
132
	/* mount flags */
	/* include/asm-ia64/siginfo.h defines a macro named si_flags */
	unsigned int		si_mntflags;

J. R. Okajima's avatar
J. R. Okajima committed
133
134
135
136
137
138
139
140
141
142
143
	/* external inode number (bitmap and translation table) */
	vfs_readf_t		si_xread;
	vfs_writef_t		si_xwrite;
	loff_t			si_ximaxent;	/* max entries in a xino */

	struct file		*si_xib;
	struct mutex		si_xib_mtx; /* protect xib members */
	unsigned long		*si_xib_buf;
	unsigned long		si_xib_last_pindex;
	int			si_xib_next_bit;

J. R. Okajima's avatar
J. R. Okajima committed
144
145
	unsigned long		si_xino_jiffy;
	unsigned long		si_xino_expire;
J. R. Okajima's avatar
J. R. Okajima committed
146
147
148
	/* reserved for future use */
	/* unsigned long long	si_xib_limit; */	/* Max xib file size */

J. R. Okajima's avatar
J. R. Okajima committed
149
150
151
152
153
154
155
#ifdef CONFIG_AUFS_EXPORT
	/* i_generation */
	/* todo: make xigen file an array to support many inode numbers */
	struct file		*si_xigen;
	atomic_t		si_xigen_next;
#endif

156
157
158
	/* dirty trick to support atomic_open */
	struct hlist_bl_head	si_aopen;

159
160
161
162
163
	/* vdir parameters */
	unsigned long		si_rdcache;	/* max cache time in jiffies */
	unsigned int		si_rdblk;	/* deblk size */
	unsigned int		si_rdhash;	/* hash size */

J. R. Okajima's avatar
J. R. Okajima committed
164
165
166
167
168
169
170
171
	/*
	 * If the number of whiteouts are larger than si_dirwh, leave all of
	 * them after au_whtmp_ren to reduce the cost of rmdir(2).
	 * future fsck.aufs or kernel thread will remove them later.
	 * Otherwise, remove all whiteouts and the dir in rmdir(2).
	 */
	unsigned int		si_dirwh;

172
173
174
175
176
177
	/* pseudo_link list */
	struct hlist_bl_head	si_plink[AuPlink_NHASH];
	wait_queue_head_t	si_plink_wq;
	spinlock_t		si_plink_maint_lock;
	pid_t			si_plink_maint_pid;

178
179
180
	/* file list */
	struct hlist_bl_head	si_files;

181
	/* with/without getattr, brother of sb->s_d_op */
182
	const struct inode_operations *si_iop_array;
183

J. R. Okajima's avatar
J. R. Okajima committed
184
185
186
187
188
189
190
	/*
	 * sysfs and lifetime management.
	 * this is not a small structure and it may be a waste of memory in case
	 * of sysfs is disabled, particularly when many aufs-es are mounted.
	 * but using sysfs is majority.
	 */
	struct kobject		si_kobj;
J. R. Okajima's avatar
J. R. Okajima committed
191
192
193
194
195
196
197
198
#ifdef CONFIG_DEBUG_FS
	struct dentry		 *si_dbgaufs;
	struct dentry		 *si_dbgaufs_plink;
	struct dentry		 *si_dbgaufs_xib;
#ifdef CONFIG_AUFS_EXPORT
	struct dentry		 *si_dbgaufs_xigen;
#endif
#endif
J. R. Okajima's avatar
J. R. Okajima committed
199

J. R. Okajima's avatar
J. R. Okajima committed
200
201
202
203
#ifdef CONFIG_AUFS_SBILIST
	struct hlist_bl_node	si_list;
#endif

J. R. Okajima's avatar
J. R. Okajima committed
204
205
	/* dirty, necessary for unmounting, sysfs and sysrq */
	struct super_block	*si_sb;
J. R. Okajima's avatar
J. R. Okajima committed
206
207
};

208
209
210
211
212
213
214
/* sbinfo status flags */
/*
 * set true when refresh_dirs() failed at remount time.
 * then try refreshing dirs at access time again.
 * if it is false, refreshing dirs at access time is unnecessary
 */
#define AuSi_FAILED_REFRESH_DIR	1
215
#define AuSi_FHSM		(1 << 1)	/* fhsm is active now */
216
#define AuSi_NO_DREVAL		(1 << 2)	/* disable all d_revalidate */
217

218
219
220
221
222
#ifndef CONFIG_AUFS_FHSM
#undef AuSi_FHSM
#define AuSi_FHSM		0
#endif

223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
static inline unsigned char au_do_ftest_si(struct au_sbinfo *sbi,
					   unsigned int flag)
{
	AuRwMustAnyLock(&sbi->si_rwsem);
	return sbi->au_si_status & flag;
}
#define au_ftest_si(sbinfo, name)	au_do_ftest_si(sbinfo, AuSi_##name)
#define au_fset_si(sbinfo, name) do { \
	AuRwMustWriteLock(&(sbinfo)->si_rwsem); \
	(sbinfo)->au_si_status |= AuSi_##name; \
} while (0)
#define au_fclr_si(sbinfo, name) do { \
	AuRwMustWriteLock(&(sbinfo)->si_rwsem); \
	(sbinfo)->au_si_status &= ~AuSi_##name; \
} while (0)

J. R. Okajima's avatar
J. R. Okajima committed
239
240
/* ---------------------------------------------------------------------- */

241
242
243
244
245
246
/* policy to select one among writable branches */
#define AuWbrCopyup(sbinfo, ...) \
	((sbinfo)->si_wbr_copyup_ops->copyup(__VA_ARGS__))
#define AuWbrCreate(sbinfo, ...) \
	((sbinfo)->si_wbr_create_ops->create(__VA_ARGS__))

J. R. Okajima's avatar
J. R. Okajima committed
247
/* flags for si_read_lock()/aufs_read_lock()/di_read_lock() */
J. R. Okajima's avatar
J. R. Okajima committed
248
249
250
#define AuLock_DW		1		/* write-lock dentry */
#define AuLock_IR		(1 << 1)	/* read-lock inode */
#define AuLock_IW		(1 << 2)	/* write-lock inode */
J. R. Okajima's avatar
J. R. Okajima committed
251
#define AuLock_FLUSH		(1 << 3)	/* wait for 'nowait' tasks */
252
253
#define AuLock_DIRS		(1 << 4)	/* target is a pair of dirs */
						/* except RENAME_EXCHANGE */
254
255
#define AuLock_NOPLM		(1 << 5)	/* return err in plm mode */
#define AuLock_NOPLMW		(1 << 6)	/* wait for plm mode ends */
J. R. Okajima's avatar
J. R. Okajima committed
256
#define AuLock_GEN		(1 << 7)	/* test digen/iigen */
J. R. Okajima's avatar
J. R. Okajima committed
257
258
259
260
261
262
263
264
#define au_ftest_lock(flags, name)	((flags) & AuLock_##name)
#define au_fset_lock(flags, name) \
	do { (flags) |= AuLock_##name; } while (0)
#define au_fclr_lock(flags, name) \
	do { (flags) &= ~AuLock_##name; } while (0)

/* ---------------------------------------------------------------------- */

J. R. Okajima's avatar
J. R. Okajima committed
265
/* super.c */
J. R. Okajima's avatar
J. R. Okajima committed
266
extern struct file_system_type aufs_fs_type;
J. R. Okajima's avatar
J. R. Okajima committed
267
struct inode *au_iget_locked(struct super_block *sb, ino_t ino);
268
269
270
271
272
273
typedef unsigned long long (*au_arraycb_t)(struct super_block *sb, void *array,
					   unsigned long long max, void *arg);
void *au_array_alloc(unsigned long long *hint, au_arraycb_t cb,
		     struct super_block *sb, void *arg);
struct inode **au_iarray_alloc(struct super_block *sb, unsigned long long *max);
void au_iarray_free(struct inode **a, unsigned long long max);
J. R. Okajima's avatar
J. R. Okajima committed
274

J. R. Okajima's avatar
J. R. Okajima committed
275
276
277
/* sbinfo.c */
void au_si_free(struct kobject *kobj);
int au_si_alloc(struct super_block *sb);
278
int au_sbr_realloc(struct au_sbinfo *sbinfo, int nbr, int may_shrink);
J. R. Okajima's avatar
J. R. Okajima committed
279

J. R. Okajima's avatar
J. R. Okajima committed
280
unsigned int au_sigen_inc(struct super_block *sb);
281
aufs_bindex_t au_new_br_id(struct super_block *sb);
J. R. Okajima's avatar
J. R. Okajima committed
282

J. R. Okajima's avatar
J. R. Okajima committed
283
284
int si_read_lock(struct super_block *sb, int flags);
int si_write_lock(struct super_block *sb, int flags);
J. R. Okajima's avatar
J. R. Okajima committed
285
286
287
288
int aufs_read_lock(struct dentry *dentry, int flags);
void aufs_read_unlock(struct dentry *dentry, int flags);
void aufs_write_lock(struct dentry *dentry);
void aufs_write_unlock(struct dentry *dentry);
289
290
int aufs_read_and_write_lock2(struct dentry *d1, struct dentry *d2, int flags);
void aufs_read_and_write_unlock2(struct dentry *d1, struct dentry *d2);
J. R. Okajima's avatar
J. R. Okajima committed
291

292
293
294
295
296
297
298
/* wbr_policy.c */
extern struct au_wbr_copyup_operations au_wbr_copyup_ops[];
extern struct au_wbr_create_operations au_wbr_create_ops[];
int au_cpdown_dirs(struct dentry *dentry, aufs_bindex_t bdst);
int au_wbr_nonopq(struct dentry *dentry, aufs_bindex_t bindex);
int au_wbr_do_copyup_bu(struct dentry *dentry, aufs_bindex_t btop);

J. R. Okajima's avatar
J. R. Okajima committed
299
300
301
/* mvdown.c */
int au_mvdown(struct dentry *dentry, struct aufs_mvdown __user *arg);

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#ifdef CONFIG_AUFS_FHSM
/* fhsm.c */

static inline pid_t au_fhsm_pid(struct au_fhsm *fhsm)
{
	pid_t pid;

	spin_lock(&fhsm->fhsm_spin);
	pid = fhsm->fhsm_pid;
	spin_unlock(&fhsm->fhsm_spin);

	return pid;
}

void au_fhsm_wrote(struct super_block *sb, aufs_bindex_t bindex, int force);
void au_fhsm_wrote_all(struct super_block *sb, int force);
int au_fhsm_fd(struct super_block *sb, int oflags);
int au_fhsm_br_alloc(struct au_branch *br);
void au_fhsm_set_bottom(struct super_block *sb, aufs_bindex_t bindex);
void au_fhsm_fin(struct super_block *sb);
void au_fhsm_init(struct au_sbinfo *sbinfo);
void au_fhsm_set(struct au_sbinfo *sbinfo, unsigned int sec);
void au_fhsm_show(struct seq_file *seq, struct au_sbinfo *sbinfo);
#else
AuStubVoid(au_fhsm_wrote, struct super_block *sb, aufs_bindex_t bindex,
	   int force)
AuStubVoid(au_fhsm_wrote_all, struct super_block *sb, int force)
AuStub(int, au_fhsm_fd, return -EOPNOTSUPP, struct super_block *sb, int oflags)
AuStub(pid_t, au_fhsm_pid, return 0, struct au_fhsm *fhsm)
AuStubInt0(au_fhsm_br_alloc, struct au_branch *br)
AuStubVoid(au_fhsm_set_bottom, struct super_block *sb, aufs_bindex_t bindex)
AuStubVoid(au_fhsm_fin, struct super_block *sb)
AuStubVoid(au_fhsm_init, struct au_sbinfo *sbinfo)
AuStubVoid(au_fhsm_set, struct au_sbinfo *sbinfo, unsigned int sec)
AuStubVoid(au_fhsm_show, struct seq_file *seq, struct au_sbinfo *sbinfo)
#endif

J. R. Okajima's avatar
J. R. Okajima committed
339
340
341
342
343
344
345
346
347
/* ---------------------------------------------------------------------- */

static inline struct au_sbinfo *au_sbi(struct super_block *sb)
{
	return sb->s_fs_info;
}

/* ---------------------------------------------------------------------- */

J. R. Okajima's avatar
J. R. Okajima committed
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#ifdef CONFIG_AUFS_EXPORT
int au_test_nfsd(void);
void au_export_init(struct super_block *sb);
void au_xigen_inc(struct inode *inode);
int au_xigen_new(struct inode *inode);
int au_xigen_set(struct super_block *sb, struct path *path);
void au_xigen_clr(struct super_block *sb);

static inline int au_busy_or_stale(void)
{
	if (!au_test_nfsd())
		return -EBUSY;
	return -ESTALE;
}
#else
AuStubInt0(au_test_nfsd, void)
AuStubVoid(au_export_init, struct super_block *sb)
AuStubVoid(au_xigen_inc, struct inode *inode)
AuStubInt0(au_xigen_new, struct inode *inode)
AuStubInt0(au_xigen_set, struct super_block *sb, struct path *path)
AuStubVoid(au_xigen_clr, struct super_block *sb)
AuStub(int, au_busy_or_stale, return -EBUSY, void)
#endif /* CONFIG_AUFS_EXPORT */

/* ---------------------------------------------------------------------- */

J. R. Okajima's avatar
J. R. Okajima committed
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
#ifdef CONFIG_AUFS_SBILIST
/* module.c */
extern struct hlist_bl_head au_sbilist;

static inline void au_sbilist_init(void)
{
	INIT_HLIST_BL_HEAD(&au_sbilist);
}

static inline void au_sbilist_add(struct super_block *sb)
{
	au_hbl_add(&au_sbi(sb)->si_list, &au_sbilist);
}

static inline void au_sbilist_del(struct super_block *sb)
{
	au_hbl_del(&au_sbi(sb)->si_list, &au_sbilist);
}

393
394
395
396
397
398
399
400
401
402
403
404
405
406
#ifdef CONFIG_AUFS_MAGIC_SYSRQ
static inline void au_sbilist_lock(void)
{
	hlist_bl_lock(&au_sbilist);
}

static inline void au_sbilist_unlock(void)
{
	hlist_bl_unlock(&au_sbilist);
}
#define AuGFP_SBILIST	GFP_ATOMIC
#else
AuStubVoid(au_sbilist_lock, void)
AuStubVoid(au_sbilist_unlock, void)
J. R. Okajima's avatar
J. R. Okajima committed
407
#define AuGFP_SBILIST	GFP_NOFS
408
#endif /* CONFIG_AUFS_MAGIC_SYSRQ */
J. R. Okajima's avatar
J. R. Okajima committed
409
410
411
412
#else
AuStubVoid(au_sbilist_init, void)
AuStubVoid(au_sbilist_add, struct super_block *sb)
AuStubVoid(au_sbilist_del, struct super_block *sb)
413
414
AuStubVoid(au_sbilist_lock, void)
AuStubVoid(au_sbilist_unlock, void)
J. R. Okajima's avatar
J. R. Okajima committed
415
416
417
418
419
#define AuGFP_SBILIST	GFP_NOFS
#endif

/* ---------------------------------------------------------------------- */

J. R. Okajima's avatar
J. R. Okajima committed
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
static inline void dbgaufs_si_null(struct au_sbinfo *sbinfo)
{
	/*
	 * This function is a dynamic '__init' function actually,
	 * so the tiny check for si_rwsem is unnecessary.
	 */
	/* AuRwMustWriteLock(&sbinfo->si_rwsem); */
#ifdef CONFIG_DEBUG_FS
	sbinfo->si_dbgaufs = NULL;
	sbinfo->si_dbgaufs_plink = NULL;
	sbinfo->si_dbgaufs_xib = NULL;
#ifdef CONFIG_AUFS_EXPORT
	sbinfo->si_dbgaufs_xigen = NULL;
#endif
#endif
}

/* ---------------------------------------------------------------------- */

439
440
/* current->atomic_flags */
/* this value should never corrupt the ones defined in linux/sched.h */
441
#define PFA_AUFS	0x10
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465

TASK_PFA_TEST(AUFS, test_aufs)	/* task_test_aufs */
TASK_PFA_SET(AUFS, aufs)	/* task_set_aufs */
TASK_PFA_CLEAR(AUFS, aufs)	/* task_clear_aufs */

static inline int si_pid_test(struct super_block *sb)
{
	return !!task_test_aufs(current);
}

static inline void si_pid_clr(struct super_block *sb)
{
	AuDebugOn(!task_test_aufs(current));
	task_clear_aufs(current);
}

static inline void si_pid_set(struct super_block *sb)
{
	AuDebugOn(task_test_aufs(current));
	task_set_aufs(current);
}

/* ---------------------------------------------------------------------- */

J. R. Okajima's avatar
J. R. Okajima committed
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/* lock superblock. mainly for entry point functions */
#define __si_read_lock(sb)	au_rw_read_lock(&au_sbi(sb)->si_rwsem)
#define __si_write_lock(sb)	au_rw_write_lock(&au_sbi(sb)->si_rwsem)
#define __si_read_trylock(sb)	au_rw_read_trylock(&au_sbi(sb)->si_rwsem)
#define __si_write_trylock(sb)	au_rw_write_trylock(&au_sbi(sb)->si_rwsem)
/*
#define __si_read_trylock_nested(sb) \
	au_rw_read_trylock_nested(&au_sbi(sb)->si_rwsem)
#define __si_write_trylock_nested(sb) \
	au_rw_write_trylock_nested(&au_sbi(sb)->si_rwsem)
*/

#define __si_read_unlock(sb)	au_rw_read_unlock(&au_sbi(sb)->si_rwsem)
#define __si_write_unlock(sb)	au_rw_write_unlock(&au_sbi(sb)->si_rwsem)
#define __si_downgrade_lock(sb)	au_rw_dgrade_lock(&au_sbi(sb)->si_rwsem)

#define SiMustNoWaiters(sb)	AuRwMustNoWaiters(&au_sbi(sb)->si_rwsem)
#define SiMustAnyLock(sb)	AuRwMustAnyLock(&au_sbi(sb)->si_rwsem)
#define SiMustWriteLock(sb)	AuRwMustWriteLock(&au_sbi(sb)->si_rwsem)

J. R. Okajima's avatar
J. R. Okajima committed
486
487
488
static inline void si_noflush_read_lock(struct super_block *sb)
{
	__si_read_lock(sb);
489
	si_pid_set(sb);
J. R. Okajima's avatar
J. R. Okajima committed
490
491
492
493
}

static inline int si_noflush_read_trylock(struct super_block *sb)
{
494
495
496
497
498
499
	int locked;

	locked = __si_read_trylock(sb);
	if (locked)
		si_pid_set(sb);
	return locked;
J. R. Okajima's avatar
J. R. Okajima committed
500
501
502
503
504
}

static inline void si_noflush_write_lock(struct super_block *sb)
{
	__si_write_lock(sb);
505
	si_pid_set(sb);
J. R. Okajima's avatar
J. R. Okajima committed
506
507
508
509
}

static inline int si_noflush_write_trylock(struct super_block *sb)
{
510
511
512
513
514
515
	int locked;

	locked = __si_write_trylock(sb);
	if (locked)
		si_pid_set(sb);
	return locked;
J. R. Okajima's avatar
J. R. Okajima committed
516
517
518
519
520
521
522
523
524
525
526
527
528
}

#if 0 /* reserved */
static inline int si_read_trylock(struct super_block *sb, int flags)
{
	if (au_ftest_lock(flags, FLUSH))
		au_nwt_flush(&au_sbi(sb)->si_nowait);
	return si_noflush_read_trylock(sb);
}
#endif

static inline void si_read_unlock(struct super_block *sb)
{
529
	si_pid_clr(sb);
J. R. Okajima's avatar
J. R. Okajima committed
530
531
532
533
534
535
536
537
538
539
540
541
542
543
	__si_read_unlock(sb);
}

#if 0 /* reserved */
static inline int si_write_trylock(struct super_block *sb, int flags)
{
	if (au_ftest_lock(flags, FLUSH))
		au_nwt_flush(&au_sbi(sb)->si_nowait);
	return si_noflush_write_trylock(sb);
}
#endif

static inline void si_write_unlock(struct super_block *sb)
{
544
	si_pid_clr(sb);
J. R. Okajima's avatar
J. R. Okajima committed
545
546
547
548
549
550
551
552
553
554
	__si_write_unlock(sb);
}

#if 0 /* reserved */
static inline void si_downgrade_lock(struct super_block *sb)
{
	__si_downgrade_lock(sb);
}
#endif

J. R. Okajima's avatar
J. R. Okajima committed
555
556
557
558
559
560
561
562
/* ---------------------------------------------------------------------- */

static inline aufs_bindex_t au_sbbot(struct super_block *sb)
{
	SiMustAnyLock(sb);
	return au_sbi(sb)->si_bbot;
}

563
564
565
566
567
568
static inline unsigned int au_mntflags(struct super_block *sb)
{
	SiMustAnyLock(sb);
	return au_sbi(sb)->si_mntflags;
}

J. R. Okajima's avatar
J. R. Okajima committed
569
570
571
572
573
574
static inline unsigned int au_sigen(struct super_block *sb)
{
	SiMustAnyLock(sb);
	return au_sbi(sb)->si_generation;
}

575
576
577
578
579
580
581
static inline struct au_branch *au_sbr(struct super_block *sb,
				       aufs_bindex_t bindex)
{
	SiMustAnyLock(sb);
	return au_sbi(sb)->si_branch[0 + bindex];
}

J. R. Okajima's avatar
J. R. Okajima committed
582
583
584
585
586
587
static inline loff_t au_xi_maxent(struct super_block *sb)
{
	SiMustAnyLock(sb);
	return au_sbi(sb)->si_ximaxent;
}

J. R. Okajima's avatar
J. R. Okajima committed
588
589
#endif /* __KERNEL__ */
#endif /* __AUFS_SUPER_H__ */