root / lab4 / .minix-src / include / ufs / lfs / lfs_inode.h @ 14
History | View | Annotate | Download (10.7 KB)
1 |
/* $NetBSD: lfs_inode.h,v 1.11 2015/09/01 06:08:37 dholland Exp $ */
|
---|---|
2 |
/* from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp */
|
3 |
/* from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp */
|
4 |
|
5 |
/*
|
6 |
* Copyright (c) 1982, 1989, 1993
|
7 |
* The Regents of the University of California. All rights reserved.
|
8 |
* (c) UNIX System Laboratories, Inc.
|
9 |
* All or some portions of this file are derived from material licensed
|
10 |
* to the University of California by American Telephone and Telegraph
|
11 |
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
12 |
* the permission of UNIX System Laboratories, Inc.
|
13 |
*
|
14 |
* Redistribution and use in source and binary forms, with or without
|
15 |
* modification, are permitted provided that the following conditions
|
16 |
* are met:
|
17 |
* 1. Redistributions of source code must retain the above copyright
|
18 |
* notice, this list of conditions and the following disclaimer.
|
19 |
* 2. Redistributions in binary form must reproduce the above copyright
|
20 |
* notice, this list of conditions and the following disclaimer in the
|
21 |
* documentation and/or other materials provided with the distribution.
|
22 |
* 3. Neither the name of the University nor the names of its contributors
|
23 |
* may be used to endorse or promote products derived from this software
|
24 |
* without specific prior written permission.
|
25 |
*
|
26 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
27 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
28 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
29 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
30 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
31 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
32 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
33 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
34 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
35 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
36 |
* SUCH DAMAGE.
|
37 |
*
|
38 |
* @(#)inode.h 8.9 (Berkeley) 5/14/95
|
39 |
*/
|
40 |
|
41 |
#ifndef _UFS_LFS_LFS_INODE_H_
|
42 |
#define _UFS_LFS_LFS_INODE_H_
|
43 |
|
44 |
/*
|
45 |
* Some of the userlevel code (fsck, newfs, lfs_cleanerd) wants to use
|
46 |
* the in-memory inode structure in a faked-up kernel environment.
|
47 |
* This header file provides a reasonably sanitized version of the
|
48 |
* structures and definitions needed for that purpose.
|
49 |
*/
|
50 |
|
51 |
#include <miscfs/genfs/genfs_node.h> |
52 |
#include <ufs/lfs/lfs.h> |
53 |
|
54 |
/*
|
55 |
* Adjustable filesystem parameters
|
56 |
*/
|
57 |
#define MIN_FREE_SEGS 20 |
58 |
#define MIN_RESV_SEGS 15 |
59 |
|
60 |
/*
|
61 |
* The following constants define the usage of the quota file array in the
|
62 |
* ulfsmount structure and dquot array in the inode structure. The semantics
|
63 |
* of the elements of these arrays are defined in the routine lfs_getinoquota;
|
64 |
* the remainder of the quota code treats them generically and need not be
|
65 |
* inspected when changing the size of the array.
|
66 |
*/
|
67 |
#define ULFS_MAXQUOTAS 2 |
68 |
#define ULFS_USRQUOTA 0 /* element used for user quotas */ |
69 |
#define ULFS_GRPQUOTA 1 /* element used for group quotas */ |
70 |
|
71 |
/*
|
72 |
* Lookup result state (other than the result inode). This is
|
73 |
* currently stashed in the vnode between VOP_LOOKUP and directory
|
74 |
* operation VOPs, which is gross.
|
75 |
*
|
76 |
* XXX ulr_diroff is a lookup hint from the previos call of VOP_LOOKUP.
|
77 |
* probably it should not be here.
|
78 |
*/
|
79 |
struct ulfs_lookup_results {
|
80 |
int32_t ulr_count; /* Size of free slot in directory. */
|
81 |
doff_t ulr_endoff; /* End of useful stuff in directory. */
|
82 |
doff_t ulr_diroff; /* Offset in dir, where we found last entry. */
|
83 |
doff_t ulr_offset; /* Offset of free space in directory. */
|
84 |
u_int32_t ulr_reclen; /* Size of found directory entry. */
|
85 |
}; |
86 |
|
87 |
/* notyet XXX */
|
88 |
#define ULFS_CHECK_CRAPCOUNTER(dp) ((void)(dp)->i_crapcounter) |
89 |
|
90 |
/*
|
91 |
* Per-filesystem inode extensions.
|
92 |
*/
|
93 |
struct lfs_inode_ext;
|
94 |
|
95 |
/*
|
96 |
* The inode is used to describe each active (or recently active) file in the
|
97 |
* ULFS filesystem. It is composed of two types of information. The first part
|
98 |
* is the information that is needed only while the file is active (such as
|
99 |
* the identity of the file and linkage to speed its lookup). The second part
|
100 |
* is the permanent meta-data associated with the file which is read in
|
101 |
* from the permanent dinode from long term storage when the file becomes
|
102 |
* active, and is put back when the file is no longer being used.
|
103 |
*/
|
104 |
struct inode {
|
105 |
struct genfs_node i_gnode;
|
106 |
LIST_ENTRY(inode) i_hash;/* Hash chain. */
|
107 |
TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */
|
108 |
struct vnode *i_vnode; /* Vnode associated with this inode. */ |
109 |
struct ulfsmount *i_ump; /* Mount point associated with this inode. */ |
110 |
struct vnode *i_devvp; /* Vnode for block I/O. */ |
111 |
u_int32_t i_flag; /* flags, see below */
|
112 |
dev_t i_dev; /* Device associated with the inode. */
|
113 |
ino_t i_number; /* The identity of the inode. */
|
114 |
|
115 |
struct lfs *i_lfs; /* The LFS volume we belong to. */ |
116 |
|
117 |
void *i_unused1; /* Unused. */ |
118 |
struct dquot *i_dquot[ULFS_MAXQUOTAS]; /* Dquot structures. */ |
119 |
u_quad_t i_modrev; /* Revision level for NFS lease. */
|
120 |
struct lockf *i_lockf;/* Head of byte-level lock list. */ |
121 |
|
122 |
/*
|
123 |
* Side effects; used during (and after) directory lookup.
|
124 |
* XXX should not be here.
|
125 |
*/
|
126 |
struct ulfs_lookup_results i_crap;
|
127 |
unsigned i_crapcounter; /* serial number for i_crap */ |
128 |
|
129 |
/*
|
130 |
* Inode extensions
|
131 |
*/
|
132 |
union {
|
133 |
/* Other extensions could go here... */
|
134 |
struct lfs_inode_ext *lfs;
|
135 |
} inode_ext; |
136 |
/*
|
137 |
* Copies from the on-disk dinode itself.
|
138 |
*
|
139 |
* These fields are currently only used by LFS.
|
140 |
*/
|
141 |
u_int16_t i_mode; /* IFMT, permissions; see below. */
|
142 |
int16_t i_nlink; /* File link count. */
|
143 |
u_int64_t i_size; /* File byte count. */
|
144 |
u_int32_t i_flags; /* Status flags (chflags). */
|
145 |
int32_t i_gen; /* Generation number. */
|
146 |
u_int32_t i_uid; /* File owner. */
|
147 |
u_int32_t i_gid; /* File group. */
|
148 |
u_int16_t i_omode; /* Old mode, for ulfs_reclaim. */
|
149 |
|
150 |
struct dirhash *i_dirhash; /* Hashing for large directories */ |
151 |
|
152 |
/*
|
153 |
* The on-disk dinode itself.
|
154 |
*/
|
155 |
union lfs_dinode *i_din;
|
156 |
}; |
157 |
|
158 |
/* These flags are kept in i_flag. */
|
159 |
#define IN_ACCESS 0x0001 /* Access time update request. */ |
160 |
#define IN_CHANGE 0x0002 /* Inode change time update request. */ |
161 |
#define IN_UPDATE 0x0004 /* Inode was written to; update mtime. */ |
162 |
#define IN_MODIFY 0x2000 /* Modification time update request. */ |
163 |
#define IN_MODIFIED 0x0008 /* Inode has been modified. */ |
164 |
#define IN_ACCESSED 0x0010 /* Inode has been accessed. */ |
165 |
/* unused 0x0020 */ /* was IN_RENAME */ |
166 |
#define IN_SHLOCK 0x0040 /* File has shared lock. */ |
167 |
#define IN_EXLOCK 0x0080 /* File has exclusive lock. */ |
168 |
#define IN_CLEANING 0x0100 /* LFS: file is being cleaned */ |
169 |
#define IN_ADIROP 0x0200 /* LFS: dirop in progress */ |
170 |
/* unused 0x0400 */ /* was FFS-only IN_SPACECOUNTED */ |
171 |
#define IN_PAGING 0x1000 /* LFS: file is on paging queue */ |
172 |
#define IN_CDIROP 0x4000 /* LFS: dirop completed pending i/o */ |
173 |
|
174 |
/*
|
175 |
* LFS inode extensions.
|
176 |
*/
|
177 |
struct lfs_inode_ext {
|
178 |
off_t lfs_osize; /* size of file on disk */
|
179 |
u_int64_t lfs_effnblocks; /* number of blocks when i/o completes */
|
180 |
size_t lfs_fragsize[ULFS_NDADDR]; /* size of on-disk direct blocks */
|
181 |
TAILQ_ENTRY(inode) lfs_dchain; /* Dirop chain. */
|
182 |
TAILQ_ENTRY(inode) lfs_pchain; /* Paging chain. */
|
183 |
#define LFSI_NO_GOP_WRITE 0x01 |
184 |
#define LFSI_DELETED 0x02 |
185 |
#define LFSI_WRAPBLOCK 0x04 |
186 |
#define LFSI_WRAPWAIT 0x08 |
187 |
#define LFSI_BMAP 0x10 |
188 |
u_int32_t lfs_iflags; /* Inode flags */
|
189 |
daddr_t lfs_hiblk; /* Highest lbn held by inode */
|
190 |
#ifdef _KERNEL
|
191 |
SPLAY_HEAD(lfs_splay, lbnentry) lfs_lbtree; /* Tree of balloc'd lbns */
|
192 |
int lfs_nbtree; /* Size of tree */ |
193 |
LIST_HEAD(, segdelta) lfs_segdhd; |
194 |
#endif
|
195 |
int16_t lfs_odnlink; /* on-disk nlink count for cleaner */
|
196 |
}; |
197 |
#define i_lfs_osize inode_ext.lfs->lfs_osize
|
198 |
#define i_lfs_effnblks inode_ext.lfs->lfs_effnblocks
|
199 |
#define i_lfs_fragsize inode_ext.lfs->lfs_fragsize
|
200 |
#define i_lfs_dchain inode_ext.lfs->lfs_dchain
|
201 |
#define i_lfs_pchain inode_ext.lfs->lfs_pchain
|
202 |
#define i_lfs_iflags inode_ext.lfs->lfs_iflags
|
203 |
#define i_lfs_hiblk inode_ext.lfs->lfs_hiblk
|
204 |
#define i_lfs_lbtree inode_ext.lfs->lfs_lbtree
|
205 |
#define i_lfs_nbtree inode_ext.lfs->lfs_nbtree
|
206 |
#define i_lfs_segdhd inode_ext.lfs->lfs_segdhd
|
207 |
#define i_lfs_odnlink inode_ext.lfs->lfs_odnlink
|
208 |
|
209 |
/*
|
210 |
* "struct buf" associated definitions
|
211 |
*/
|
212 |
|
213 |
#ifdef _KERNEL
|
214 |
|
215 |
# define LFS_IS_MALLOC_BUF(bp) ((bp)->b_iodone == lfs_callback)
|
216 |
|
217 |
# ifdef DEBUG
|
218 |
# define LFS_DEBUG_COUNTLOCKED(m) do { \ |
219 |
if (lfs_debug_log_subsys[DLOG_LLIST]) { \
|
220 |
lfs_countlocked(&locked_queue_count, &locked_queue_bytes, (m)); \ |
221 |
cv_broadcast(&locked_queue_cv); \ |
222 |
} \ |
223 |
} while (0) |
224 |
# else
|
225 |
# define LFS_DEBUG_COUNTLOCKED(m)
|
226 |
# endif
|
227 |
|
228 |
/* log for debugging writes to the Ifile */
|
229 |
# ifdef DEBUG
|
230 |
struct lfs_log_entry {
|
231 |
const char *op; |
232 |
const char *file; |
233 |
int pid;
|
234 |
int line;
|
235 |
daddr_t block; |
236 |
unsigned long flags; |
237 |
}; |
238 |
extern int lfs_lognum; |
239 |
extern struct lfs_log_entry lfs_log[LFS_LOGLENGTH]; |
240 |
# define LFS_BWRITE_LOG(bp) lfs_bwrite_log((bp), __FILE__, __LINE__)
|
241 |
# define LFS_ENTER_LOG(theop, thefile, theline, lbn, theflags, thepid) do {\ |
242 |
int _s; \
|
243 |
\ |
244 |
mutex_enter(&lfs_lock); \ |
245 |
_s = splbio(); \ |
246 |
lfs_log[lfs_lognum].op = theop; \ |
247 |
lfs_log[lfs_lognum].file = thefile; \ |
248 |
lfs_log[lfs_lognum].line = (theline); \ |
249 |
lfs_log[lfs_lognum].pid = (thepid); \ |
250 |
lfs_log[lfs_lognum].block = (lbn); \ |
251 |
lfs_log[lfs_lognum].flags = (theflags); \ |
252 |
lfs_lognum = (lfs_lognum + 1) % LFS_LOGLENGTH; \
|
253 |
splx(_s); \ |
254 |
mutex_exit(&lfs_lock); \ |
255 |
} while (0) |
256 |
|
257 |
# define LFS_BCLEAN_LOG(fs, bp) do { \ |
258 |
if ((bp)->b_vp == (fs)->lfs_ivnode) \
|
259 |
LFS_ENTER_LOG("clear", __FILE__, __LINE__, \
|
260 |
bp->b_lblkno, bp->b_flags, curproc->p_pid);\ |
261 |
} while (0) |
262 |
|
263 |
/* Must match list in lfs_vfsops.c ! */
|
264 |
# define DLOG_RF 0 /* roll forward */ |
265 |
# define DLOG_ALLOC 1 /* inode alloc */ |
266 |
# define DLOG_AVAIL 2 /* lfs_{,r,f}avail */ |
267 |
# define DLOG_FLUSH 3 /* flush */ |
268 |
# define DLOG_LLIST 4 /* locked list accounting */ |
269 |
# define DLOG_WVNODE 5 /* vflush/writevnodes verbose */ |
270 |
# define DLOG_VNODE 6 /* vflush/writevnodes */ |
271 |
# define DLOG_SEG 7 /* segwrite */ |
272 |
# define DLOG_SU 8 /* seguse accounting */ |
273 |
# define DLOG_CLEAN 9 /* cleaner routines */ |
274 |
# define DLOG_MOUNT 10 /* mount/unmount */ |
275 |
# define DLOG_PAGE 11 /* putpages/gop_write */ |
276 |
# define DLOG_DIROP 12 /* dirop accounting */ |
277 |
# define DLOG_MALLOC 13 /* lfs_malloc accounting */ |
278 |
# define DLOG_MAX 14 /* The terminator */ |
279 |
# define DLOG(a) lfs_debug_log a
|
280 |
# else /* ! DEBUG */ |
281 |
# define LFS_BCLEAN_LOG(fs, bp)
|
282 |
# define LFS_BWRITE_LOG(bp) VOP_BWRITE((bp)->b_vp, (bp))
|
283 |
# define DLOG(a)
|
284 |
# endif /* ! DEBUG */ |
285 |
#else /* ! _KERNEL */ |
286 |
# define LFS_BWRITE_LOG(bp) VOP_BWRITE((bp))
|
287 |
#endif /* _KERNEL */ |
288 |
|
289 |
|
290 |
#endif /* _UFS_LFS_LFS_INODE_H_ */ |