]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - fs/aufs/branch.h
e9591cfa2568651c8b97e1a785ff3e5f1b4f94af
2 * Copyright (C) 2005-2017 Junjiro R. Okajima
4 * This program, aufs is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * branch filesystems and xino for them
22 #ifndef __AUFS_BRANCH_H__
23 #define __AUFS_BRANCH_H__
27 #include <linux/mount.h>
32 /* ---------------------------------------------------------------------- */
41 /* reserved for future use */
42 /* unsigned long *bitmap; */
43 wait_queue_head_t wqh
;
46 /* todo: make xino files an array to support huge inode number */
48 #ifdef CONFIG_DEBUG_FS
49 struct dentry
*xi_dbgaufs
;
53 /* File-based Hierarchical Storage Management */
55 #ifdef CONFIG_AUFS_FHSM
57 unsigned long bf_jiffy
;
58 struct aufs_stfs bf_stfs
;
63 /* members for writable branch only */
64 enum {AuBrWh_BASE
, AuBrWh_PLINK
, AuBrWh_ORPH
, AuBrWh_Last
};
66 struct au_rwsem wbr_wh_rwsem
;
67 struct dentry
*wbr_wh
[AuBrWh_Last
];
68 atomic_t wbr_wh_running
;
69 #define wbr_whbase wbr_wh[AuBrWh_BASE] /* whiteout base */
70 #define wbr_plink wbr_wh[AuBrWh_PLINK] /* pseudo-link dir */
71 #define wbr_orph wbr_wh[AuBrWh_ORPH] /* dir for orphans */
74 unsigned long long wbr_bytes
;
77 /* ext2 has 3 types of operations at least, ext3 has 4 */
78 #define AuBrDynOp (AuDyLast * 4)
80 #ifdef CONFIG_AUFS_HFSNOTIFY
81 /* support for asynchronous destruction */
82 struct au_br_hfsnotify
{
83 struct fsnotify_group
*hfsn_group
;
90 struct attribute attr
;
99 /* protected by superblock rwsem */
101 struct au_xino_file br_xino
;
107 spinlock_t br_dykey_lock
;
108 struct au_dykey
*br_dykey
[AuBrDynOp
];
109 struct percpu_counter br_count
;
111 struct au_wbr
*br_wbr
;
112 struct au_br_fhsm
*br_fhsm
;
114 /* xino truncation */
115 atomic_t br_xino_running
;
117 #ifdef CONFIG_AUFS_HFSNOTIFY
118 struct au_br_hfsnotify
*br_hfsn
;
122 /* entries under sysfs per mount-point */
123 struct au_brsysfs br_sysfs
[AuBrSysfs_Last
];
127 /* ---------------------------------------------------------------------- */
129 static inline struct vfsmount
*au_br_mnt(struct au_branch
*br
)
131 return br
->br_path
.mnt
;
134 static inline struct dentry
*au_br_dentry(struct au_branch
*br
)
136 return br
->br_path
.dentry
;
139 static inline struct super_block
*au_br_sb(struct au_branch
*br
)
141 return au_br_mnt(br
)->mnt_sb
;
144 static inline void au_br_get(struct au_branch
*br
)
146 percpu_counter_inc(&br
->br_count
);
149 static inline void au_br_put(struct au_branch
*br
)
151 percpu_counter_dec(&br
->br_count
);
154 static inline s64
au_br_count(struct au_branch
*br
)
156 return percpu_counter_sum(&br
->br_count
);
159 static inline void au_br_count_init(struct au_branch
*br
)
161 percpu_counter_init(&br
->br_count
, 0, GFP_NOFS
);
164 static inline void au_br_count_fin(struct au_branch
*br
)
166 percpu_counter_destroy(&br
->br_count
);
169 static inline int au_br_rdonly(struct au_branch
*br
)
171 return ((au_br_sb(br
)->s_flags
& MS_RDONLY
)
172 || !au_br_writable(br
->br_perm
))
176 static inline int au_br_hnotifyable(int brperm __maybe_unused
)
178 #ifdef CONFIG_AUFS_HNOTIFY
179 return !(brperm
& AuBrPerm_RR
);
185 static inline int au_br_test_oflag(int oflag
, struct au_branch
*br
)
190 exec_flag
= oflag
& __FMODE_EXEC
;
191 if (unlikely(exec_flag
&& path_noexec(&br
->br_path
)))
197 /* ---------------------------------------------------------------------- */
201 void au_br_free(struct au_sbinfo
*sinfo
);
202 int au_br_index(struct super_block
*sb
, aufs_bindex_t br_id
);
204 int au_br_add(struct super_block
*sb
, struct au_opt_add
*add
, int remount
);
206 int au_br_del(struct super_block
*sb
, struct au_opt_del
*del
, int remount
);
207 long au_ibusy_ioctl(struct file
*file
, unsigned long arg
);
209 long au_ibusy_compat_ioctl(struct file
*file
, unsigned long arg
);
212 int au_br_mod(struct super_block
*sb
, struct au_opt_mod
*mod
, int remount
,
215 int au_br_stfs(struct au_branch
*br
, struct aufs_stfs
*stfs
);
218 static const loff_t au_loff_max
= LLONG_MAX
;
220 int au_xib_trunc(struct super_block
*sb
);
221 ssize_t
xino_fread(vfs_readf_t func
, struct file
*file
, void *buf
, size_t size
,
223 ssize_t
xino_fwrite(vfs_writef_t func
, struct file
*file
, void *buf
,
224 size_t size
, loff_t
*pos
);
225 struct file
*au_xino_create2(struct file
*base_file
, struct file
*copy_src
);
226 struct file
*au_xino_create(struct super_block
*sb
, char *fname
, int silent
);
227 ino_t
au_xino_new_ino(struct super_block
*sb
);
228 void au_xino_delete_inode(struct inode
*inode
, const int unlinked
);
229 int au_xino_write(struct super_block
*sb
, aufs_bindex_t bindex
, ino_t h_ino
,
231 int au_xino_read(struct super_block
*sb
, aufs_bindex_t bindex
, ino_t h_ino
,
233 int au_xino_br(struct super_block
*sb
, struct au_branch
*br
, ino_t hino
,
234 struct file
*base_file
, int do_test
);
235 int au_xino_trunc(struct super_block
*sb
, aufs_bindex_t bindex
);
238 int au_xino_set(struct super_block
*sb
, struct au_opt_xino
*xino
, int remount
);
239 void au_xino_clr(struct super_block
*sb
);
240 struct file
*au_xino_def(struct super_block
*sb
);
241 int au_xino_path(struct seq_file
*seq
, struct file
*file
);
243 void au_xinondir_leave(struct super_block
*sb
, aufs_bindex_t bindex
,
244 ino_t h_ino
, int idx
);
245 int au_xinondir_enter(struct super_block
*sb
, aufs_bindex_t bindex
, ino_t h_ino
,
248 /* ---------------------------------------------------------------------- */
250 /* Superblock to branch */
252 aufs_bindex_t
au_sbr_id(struct super_block
*sb
, aufs_bindex_t bindex
)
254 return au_sbr(sb
, bindex
)->br_id
;
258 struct vfsmount
*au_sbr_mnt(struct super_block
*sb
, aufs_bindex_t bindex
)
260 return au_br_mnt(au_sbr(sb
, bindex
));
264 struct super_block
*au_sbr_sb(struct super_block
*sb
, aufs_bindex_t bindex
)
266 return au_br_sb(au_sbr(sb
, bindex
));
269 static inline void au_sbr_get(struct super_block
*sb
, aufs_bindex_t bindex
)
271 au_br_get(au_sbr(sb
, bindex
));
274 static inline void au_sbr_put(struct super_block
*sb
, aufs_bindex_t bindex
)
276 au_br_put(au_sbr(sb
, bindex
));
279 static inline int au_sbr_perm(struct super_block
*sb
, aufs_bindex_t bindex
)
281 return au_sbr(sb
, bindex
)->br_perm
;
284 static inline int au_sbr_whable(struct super_block
*sb
, aufs_bindex_t bindex
)
286 return au_br_whable(au_sbr_perm(sb
, bindex
));
289 /* ---------------------------------------------------------------------- */
292 * wbr_wh_read_lock, wbr_wh_write_lock
293 * wbr_wh_read_unlock, wbr_wh_write_unlock, wbr_wh_downgrade_lock
295 AuSimpleRwsemFuncs(wbr_wh
, struct au_wbr
*wbr
, &wbr
->wbr_wh_rwsem
);
297 #define WbrWhMustNoWaiters(wbr) AuRwMustNoWaiters(&wbr->wbr_wh_rwsem)
298 #define WbrWhMustAnyLock(wbr) AuRwMustAnyLock(&wbr->wbr_wh_rwsem)
299 #define WbrWhMustWriteLock(wbr) AuRwMustWriteLock(&wbr->wbr_wh_rwsem)
301 /* ---------------------------------------------------------------------- */
303 #ifdef CONFIG_AUFS_FHSM
304 static inline void au_br_fhsm_init(struct au_br_fhsm
*brfhsm
)
306 mutex_init(&brfhsm
->bf_lock
);
307 brfhsm
->bf_jiffy
= 0;
308 brfhsm
->bf_readable
= 0;
311 static inline void au_br_fhsm_fin(struct au_br_fhsm
*brfhsm
)
313 mutex_destroy(&brfhsm
->bf_lock
);
316 AuStubVoid(au_br_fhsm_init
, struct au_br_fhsm
*brfhsm
)
317 AuStubVoid(au_br_fhsm_fin
, struct au_br_fhsm
*brfhsm
)
320 #endif /* __KERNEL__ */
321 #endif /* __AUFS_BRANCH_H__ */