drm/linux: Add pci_map_rom() and pci_unmap_rom()
[dragonfly.git] / sys / sys / namecache.h
CommitLineData
7ea21ed1 1/*
bf3f67a7 2 * Copyright (c) 2003,2004-2017 The DragonFly Project. All rights reserved.
8c10bfcf
MD
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
7ea21ed1
MD
34 * Copyright (c) 1989, 1993
35 * The Regents of the University of California. All rights reserved.
7ea21ed1
MD
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
2c64e990 45 * 3. Neither the name of the University nor the names of its contributors
7ea21ed1
MD
46 * may be used to endorse or promote products derived from this software
47 * without specific prior written permission.
48 *
49 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE.
60 *
5312fa43 61 * $DragonFly: src/sys/sys/namecache.h,v 1.31 2008/05/09 17:52:18 dillon Exp $
7ea21ed1
MD
62 */
63
64#ifndef _SYS_NAMECACHE_H_
65#define _SYS_NAMECACHE_H_
66
1bd40720
MD
67#ifndef _SYS_TYPES_H_
68#include <sys/types.h>
69#endif
70#ifndef _SYS_QUEUE_H_
71#include <sys/queue.h>
72#endif
f63911bf
MD
73#ifndef _SYS_SPINLOCK_H_
74#include <sys/spinlock.h>
75#endif
76#ifndef _SYS_THREAD_H_
77#include <sys/thread.h>
78#endif
1bd40720 79
7ea21ed1 80struct vnode;
1bd40720
MD
81struct ucred;
82struct proc;
7ea21ed1
MD
83
84TAILQ_HEAD(namecache_list, namecache);
85
86/*
87 * The namecache structure is used to manage the filesystem namespace. Most
88 * vnodes cached by the system will reference one or more associated namecache
89 * structures.
90 *
2247fe02
MD
91 * The DragonFly namecache maintains elements from active nodes to the root
92 * in all but the NFS server case and the removed file/directory case.
93 * NFS servers use fhtovp() and may have to regenerate the topology to
94 * the leaf on the fly.
3446c007
MD
95 *
96 * Because the namecache structure maintains the path through mount points,
97 * null, and union mounts, and other VFS overlays, several namecache
98 * structures may pass through the same vnode. Also note that namespaces
99 * relating to non-existant (i.e. not-yet-created) files/directories may be
100 * locked. Lock coherency is achieved by requiring that the particular
101 * namecache record whos parent represents the physical directory in which
102 * the namespace operation is to occur be the one that is locked. In
103 * overlay cases, the (union, nullfs) VFS, or in namei when crossing a mount
104 * point, may have to obtain multiple namespace record locks to avoid
105 * confusion, but only the one representing the physical directory is passed
106 * into lower layer VOP calls.
fad57d0e 107 *
79fd1696 108 * ncp locking is done using atomic ops on nc_lockstatus, including a request
2247fe02
MD
109 * flag for waiters. nc_locktd is set after locking or cleared before
110 * the last unlock. ncp locks are reentrant.
111 *
fad57d0e 112 * Many new API VOP operations do not pass vnodes. In these cases the
6ddb7618 113 * operations vector is typically obtained via nc_mount->mnt_vn_use_ops.
7ea21ed1
MD
114 */
115struct namecache {
e83d5c12 116 TAILQ_ENTRY(namecache) nc_hash; /* hash chain (nc_parent,name) */
7ea21ed1
MD
117 TAILQ_ENTRY(namecache) nc_entry; /* scan via nc_parent->nc_list */
118 TAILQ_ENTRY(namecache) nc_vnode; /* scan via vnode->v_namecache */
119 struct namecache_list nc_list; /* list of children */
f63911bf
MD
120 struct nchash_head *nc_head;
121 struct namecache *nc_parent; /* namecache entry for parent */
122 struct vnode *nc_vp; /* vnode representing name or NULL */
123 int nc_refs; /* ref count prevents deletion */
124 u_short nc_flag;
125 u_char nc_nlen; /* The length of the name, 255 max */
2247fe02 126 u_char nc_unused;
f63911bf
MD
127 char *nc_name; /* Separately allocated seg name */
128 int nc_error;
129 int nc_timeout; /* compared against ticks, or 0 */
79fd1696 130 u_int nc_lockstatus; /* namespace locking */
bf3f67a7 131 int nc_negcpu; /* which ncneg list are we on? */
f63911bf 132 struct thread *nc_locktd; /* namespace locking */
75e479cf
MD
133 u_int nc_namecache_gen; /* mount generation (autoclear) */
134 u_int nc_generation; /* rename/unlink generation */
7ea21ed1
MD
135};
136
28623bf9
MD
137/*
138 * Namecache handles include a mount reference allowing topologies
139 * to be replicated with mount overlays (nullfs mounts).
140 */
141struct nchandle {
142 struct namecache *ncp; /* ncp in underlying filesystem */
143 struct mount *mount; /* mount pt (possible overlay) */
144};
7ea21ed1
MD
145
146/*
8edfbc5e 147 * Flags in namecache.nc_flag (u_short)
7ea21ed1 148 */
f63911bf 149#define NCF_UNUSED01 0x0001
3446c007
MD
150#define NCF_WHITEOUT 0x0002 /* negative entry corresponds to whiteout */
151#define NCF_UNRESOLVED 0x0004 /* invalid or unresolved entry */
28623bf9 152#define NCF_ISMOUNTPT 0x0008 /* someone may have mounted on us here */
e9b56058
MD
153#define NCF_SF_NOCACHE 0x0010 /* track swapcache chflags from attr */
154#define NCF_UF_CACHE 0x0020
155#define NCF_SF_PNOCACHE 0x0040 /* track from parent */
156#define NCF_UF_PCACHE 0x0080
690a3127
MD
157#define NCF_ISSYMLINK 0x0100 /* represents a symlink */
158#define NCF_ISDIR 0x0200 /* represents a directory */
e09206ba 159#define NCF_DESTROYED 0x0400 /* name association is considered destroyed */
65870584 160#define NCF_DEFEREDZAP 0x0800 /* zap defered due to lock unavailability */
8edfbc5e 161#define NCF_WXOK 0x1000 /* world-searchable (nlookup shortcut) */
5eeee54a 162#define NCF_DUMMY 0x2000 /* dummy ncp, iterations ignore it */
7ea21ed1 163
79fd1696
MD
164#define NC_EXLOCK_REQ 0x80000000 /* nc_lockstatus state flag */
165#define NC_SHLOCK_REQ 0x40000000 /* nc_lockstatus state flag */
166#define NC_SHLOCK_FLAG 0x20000000 /* nc_lockstatus state flag */
167#define NC_SHLOCK_VHOLD 0x10000000 /* nc_lockstatus state flag */
2247fe02 168
8e005a45
MD
169/*
170 * cache_inval[_vp]() flags
171 */
e09206ba
MD
172#define CINV_DESTROY 0x0001 /* flag so cache_nlookup ignores the ncp */
173#define CINV_UNUSED02 0x0002
174#define CINV_CHILDREN 0x0004 /* recursively set children to unresolved */
7ea21ed1
MD
175
176#ifdef _KERNEL
177
7ea21ed1 178struct componentname;
690a3127 179struct nlcomponent;
7ea21ed1
MD
180struct mount;
181
3536c341 182void cache_clearmntcache(void);
28623bf9 183void cache_lock(struct nchandle *nch);
79fd1696 184void cache_lock_maybe_shared(struct nchandle *nch, int excl);
2247fe02
MD
185void cache_relock(struct nchandle *nch1, struct ucred *cred1,
186 struct nchandle *nch2, struct ucred *cred2);
28623bf9
MD
187int cache_lock_nonblock(struct nchandle *nch);
188void cache_unlock(struct nchandle *nch);
79fd1696 189int cache_lockstatus(struct nchandle *nch);
28623bf9
MD
190void cache_setvp(struct nchandle *nch, struct vnode *vp);
191void cache_settimeout(struct nchandle *nch, int nticks);
192void cache_setunresolved(struct nchandle *nch);
193void cache_clrmountpt(struct nchandle *nch);
194struct nchandle cache_nlookup(struct nchandle *nch, struct nlcomponent *nlc);
668b43c5
MD
195struct nchandle cache_nlookup_nonblock(struct nchandle *nch,
196 struct nlcomponent *nlc);
79fd1696
MD
197int cache_nlookup_maybe_shared(struct nchandle *nch,
198 struct nlcomponent *nlc, int excl,
199 struct nchandle *nchres);
28623bf9
MD
200void cache_allocroot(struct nchandle *nch, struct mount *mp, struct vnode *vp);
201struct mount *cache_findmount(struct nchandle *nch);
07baed26 202void cache_dropmount(struct mount *mp);
bd7598aa 203void cache_ismounting(struct mount *mp);
07baed26 204void cache_unmounting(struct mount *mp);
28623bf9 205int cache_inval(struct nchandle *nch, int flags);
6b008938 206int cache_inval_vp(struct vnode *vp, int flags);
5c6c3cac 207int cache_inval_vp_nonblock(struct vnode *vp);
8edfbc5e 208void cache_inval_wxok(struct vnode *vp);
28623bf9 209void vfs_cache_setroot(struct vnode *vp, struct nchandle *nch);
1d505369 210
28623bf9 211int cache_resolve(struct nchandle *nch, struct ucred *cred);
7ea21ed1
MD
212void cache_purge(struct vnode *vp);
213void cache_purgevfs (struct mount *mp);
6363f268 214void cache_hysteresis(int critpath);
28623bf9 215void cache_get(struct nchandle *nch, struct nchandle *target);
79fd1696
MD
216int cache_get_nonblock(struct nchandle *nch, struct nchandle *target);
217void cache_get_maybe_shared(struct nchandle *nch,
218 struct nchandle *target, int excl);
28623bf9
MD
219struct nchandle *cache_hold(struct nchandle *nch);
220void cache_copy(struct nchandle *nch, struct nchandle *target);
8edfbc5e 221void cache_copy_ncdir(struct proc *p, struct nchandle *target);
28623bf9
MD
222void cache_changemount(struct nchandle *nch, struct mount *mp);
223void cache_put(struct nchandle *nch);
224void cache_drop(struct nchandle *nch);
3536c341 225void cache_drop_and_cache(struct nchandle *nch);
8edfbc5e 226void cache_drop_ncdir(struct nchandle *nch);
28623bf9
MD
227void cache_zero(struct nchandle *nch);
228void cache_rename(struct nchandle *fnch, struct nchandle *tnch);
8d09ad3d 229void cache_unlink(struct nchandle *nch);
1ddc3e8f 230int cache_isopen(struct nchandle *nch);
28623bf9
MD
231int cache_vget(struct nchandle *, struct ucred *, int, struct vnode **);
232int cache_vref(struct nchandle *, struct ucred *, struct vnode **);
233int cache_fromdvp(struct vnode *, struct ucred *, int, struct nchandle *);
08a7d6d8
MD
234int cache_fullpath(struct proc *, struct nchandle *, struct nchandle *,
235 char **, char **, int);
bf3f67a7 236void vfscache_rollup_cpu(struct globaldata *gd);
7ea21ed1
MD
237
238#endif
239
240#endif