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