Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / fs / aufs / whout.h
1 /*
2  * Copyright (C) 2005-2013 Junjiro R. Okajima
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 /*
20  * whiteout for logical deletion and opaque directory
21  */
22
23 #ifndef __AUFS_WHOUT_H__
24 #define __AUFS_WHOUT_H__
25
26 #ifdef __KERNEL__
27
28 #include "dir.h"
29
30 /* whout.c */
31 int au_wh_name_alloc(struct qstr *wh, const struct qstr *name);
32 struct au_branch;
33 int au_wh_test(struct dentry *h_parent, struct qstr *wh_name,
34                struct au_branch *br, int try_sio);
35 int au_diropq_test(struct dentry *h_dentry, struct au_branch *br);
36 struct dentry *au_whtmp_lkup(struct dentry *h_parent, struct au_branch *br,
37                              struct qstr *prefix);
38 int au_whtmp_ren(struct dentry *h_dentry, struct au_branch *br);
39 int au_wh_unlink_dentry(struct inode *h_dir, struct path *h_path,
40                         struct dentry *dentry);
41 int au_wh_init(struct au_branch *br, struct super_block *sb);
42
43 /* diropq flags */
44 #define AuDiropq_CREATE 1
45 #define au_ftest_diropq(flags, name)    ((flags) & AuDiropq_##name)
46 #define au_fset_diropq(flags, name) \
47         do { (flags) |= AuDiropq_##name; } while (0)
48 #define au_fclr_diropq(flags, name) \
49         do { (flags) &= ~AuDiropq_##name; } while (0)
50
51 struct dentry *au_diropq_sio(struct dentry *dentry, aufs_bindex_t bindex,
52                              unsigned int flags);
53 struct dentry *au_wh_lkup(struct dentry *h_parent, struct qstr *base_name,
54                           struct au_branch *br);
55 struct dentry *au_wh_create(struct dentry *dentry, aufs_bindex_t bindex,
56                             struct dentry *h_parent);
57
58 /* real rmdir for the whiteout-ed dir */
59 struct au_whtmp_rmdir {
60         struct inode *dir;
61         struct au_branch *br;
62         struct dentry *wh_dentry;
63         struct au_nhash whlist;
64 };
65
66 struct au_whtmp_rmdir *au_whtmp_rmdir_alloc(struct super_block *sb, gfp_t gfp);
67 void au_whtmp_rmdir_free(struct au_whtmp_rmdir *whtmp);
68 int au_whtmp_rmdir(struct inode *dir, aufs_bindex_t bindex,
69                    struct dentry *wh_dentry, struct au_nhash *whlist);
70 void au_whtmp_kick_rmdir(struct inode *dir, aufs_bindex_t bindex,
71                          struct dentry *wh_dentry, struct au_whtmp_rmdir *args);
72
73 /* ---------------------------------------------------------------------- */
74
75 static inline struct dentry *au_diropq_create(struct dentry *dentry,
76                                               aufs_bindex_t bindex)
77 {
78         return au_diropq_sio(dentry, bindex, AuDiropq_CREATE);
79 }
80
81 static inline int au_diropq_remove(struct dentry *dentry, aufs_bindex_t bindex)
82 {
83         return PTR_ERR(au_diropq_sio(dentry, bindex, !AuDiropq_CREATE));
84 }
85
86 #endif /* __KERNEL__ */
87 #endif /* __AUFS_WHOUT_H__ */