]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/aufs/dcsub.h
UBUNTU: [Config] Update annotations following config review
[mirror_ubuntu-bionic-kernel.git] / fs / aufs / dcsub.h
CommitLineData
eea4740f
SF
1/*
2 * Copyright (C) 2005-2017 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, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * sub-routines for dentry cache
20 */
21
22#ifndef __AUFS_DCSUB_H__
23#define __AUFS_DCSUB_H__
24
25#ifdef __KERNEL__
26
27#include <linux/dcache.h>
28#include <linux/fs.h>
29
30struct au_dpage {
31 int ndentry;
32 struct dentry **dentries;
33};
34
35struct au_dcsub_pages {
36 int ndpage;
37 struct au_dpage *dpages;
38};
39
40/* ---------------------------------------------------------------------- */
41
42/* dcsub.c */
43int au_dpages_init(struct au_dcsub_pages *dpages, gfp_t gfp);
44void au_dpages_free(struct au_dcsub_pages *dpages);
45typedef int (*au_dpages_test)(struct dentry *dentry, void *arg);
46int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
47 au_dpages_test test, void *arg);
48int au_dcsub_pages_rev(struct au_dcsub_pages *dpages, struct dentry *dentry,
49 int do_include, au_dpages_test test, void *arg);
50int au_dcsub_pages_rev_aufs(struct au_dcsub_pages *dpages,
51 struct dentry *dentry, int do_include);
52int au_test_subdir(struct dentry *d1, struct dentry *d2);
53
54/* ---------------------------------------------------------------------- */
55
56/*
57 * todo: in linux-3.13, several similar (but faster) helpers are added to
58 * include/linux/dcache.h. Try them (in the future).
59 */
60
61static inline int au_d_hashed_positive(struct dentry *d)
62{
63 int err;
64 struct inode *inode = d_inode(d);
65
66 err = 0;
67 if (unlikely(d_unhashed(d)
68 || d_is_negative(d)
69 || !inode->i_nlink))
70 err = -ENOENT;
71 return err;
72}
73
74static inline int au_d_linkable(struct dentry *d)
75{
76 int err;
77 struct inode *inode = d_inode(d);
78
79 err = au_d_hashed_positive(d);
80 if (err
81 && d_is_positive(d)
82 && (inode->i_state & I_LINKABLE))
83 err = 0;
84 return err;
85}
86
87static inline int au_d_alive(struct dentry *d)
88{
89 int err;
90 struct inode *inode;
91
92 err = 0;
93 if (!IS_ROOT(d))
94 err = au_d_hashed_positive(d);
95 else {
96 inode = d_inode(d);
97 if (unlikely(d_unlinked(d)
98 || d_is_negative(d)
99 || !inode->i_nlink))
100 err = -ENOENT;
101 }
102 return err;
103}
104
105static inline int au_alive_dir(struct dentry *d)
106{
107 int err;
108
109 err = au_d_alive(d);
110 if (unlikely(err || IS_DEADDIR(d_inode(d))))
111 err = -ENOENT;
112 return err;
113}
114
115static inline int au_qstreq(struct qstr *a, struct qstr *b)
116{
117 return a->len == b->len
118 && !memcmp(a->name, b->name, a->len);
119}
120
121/*
122 * by the commit
123 * 360f547 2015-01-25 dcache: let the dentry count go down to zero without
124 * taking d_lock
125 * the type of d_lockref.count became int, but the inlined function d_count()
126 * still returns unsigned int.
127 * I don't know why. Maybe it is for every d_count() users?
128 * Anyway au_dcount() lives on.
129 */
130static inline int au_dcount(struct dentry *d)
131{
132 return (int)d_count(d);
133}
134
135#endif /* __KERNEL__ */
136#endif /* __AUFS_DCSUB_H__ */