master
  1/*	$NetBSD: lfs_extern.h,v 1.118 2020/02/23 08:49:46 riastradh Exp $	*/
  2
  3/*-
  4 * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
  5 * All rights reserved.
  6 *
  7 * This code is derived from software contributed to The NetBSD Foundation
  8 * by Konrad E. Schroder <perseant@hhhh.org>.
  9 *
 10 * Redistribution and use in source and binary forms, with or without
 11 * modification, are permitted provided that the following conditions
 12 * are met:
 13 * 1. Redistributions of source code must retain the above copyright
 14 *    notice, this list of conditions and the following disclaimer.
 15 * 2. Redistributions in binary form must reproduce the above copyright
 16 *    notice, this list of conditions and the following disclaimer in the
 17 *    documentation and/or other materials provided with the distribution.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 29 * POSSIBILITY OF SUCH DAMAGE.
 30 */
 31/*-
 32 * Copyright (c) 1991, 1993, 1994
 33 *	The Regents of the University of California.  All rights reserved.
 34 *
 35 * Redistribution and use in source and binary forms, with or without
 36 * modification, are permitted provided that the following conditions
 37 * are met:
 38 * 1. Redistributions of source code must retain the above copyright
 39 *    notice, this list of conditions and the following disclaimer.
 40 * 2. Redistributions in binary form must reproduce the above copyright
 41 *    notice, this list of conditions and the following disclaimer in the
 42 *    documentation and/or other materials provided with the distribution.
 43 * 3. Neither the name of the University nor the names of its contributors
 44 *    may be used to endorse or promote products derived from this software
 45 *    without specific prior written permission.
 46 *
 47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 50 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 57 * SUCH DAMAGE.
 58 *
 59 *	@(#)lfs_extern.h	8.6 (Berkeley) 5/8/95
 60 */
 61
 62#ifndef _UFS_LFS_LFS_EXTERN_H_
 63#define _UFS_LFS_LFS_EXTERN_H_
 64
 65#ifdef _KERNEL
 66#include <sys/mallocvar.h>
 67
 68MALLOC_DECLARE(M_SEGMENT);
 69#endif
 70
 71/* Copied from ext2fs for ITIMES.  XXX This is a bogus use of v_tag. */
 72#define IS_LFS_VNODE(vp)   (vp->v_tag == VT_LFS)
 73
 74/*
 75 * Sysctl values for LFS.
 76 */
 77#define LFS_WRITEINDIR	 1 /* flush indirect blocks on non-checkpoint writes */
 78#define LFS_CLEAN_VNHEAD 2 /* put prev unrefed cleaned vnodes on head of free list */
 79#define LFS_DOSTATS	 3
 80#define LFS_MAXPAGES	 4
 81#define LFS_FS_PAGETRIP	 5
 82#define LFS_STATS	 6
 83#define LFS_DO_RFW	 7
 84#define LFS_DEBUGLOG	 8
 85#define LFS_IGNORE_LAZY_SYNC	9
 86
 87/* not ours */
 88struct fid;
 89struct mount;
 90struct nameidata;
 91struct proc;
 92struct statvfs;
 93struct timeval;
 94struct uio;
 95struct mbuf;
 96struct buf;
 97struct vnode;
 98
 99/* ours */
100struct inode;
101union lfs_dinode;
102struct dlfs;
103struct lfs;
104struct segment;
105struct block_info;
106
107__BEGIN_DECLS
108
109#if defined(_KERNEL)
110
111extern kcondvar_t lfs_allclean_wakeup;
112extern struct pool lfs_inode_pool;		/* memory pool for inodes */
113extern struct pool lfs_dinode_pool;		/* memory pool for dinodes */
114extern struct pool lfs_inoext_pool;	/* memory pool for inode extension */
115extern struct pool lfs_lbnentry_pool;   /* memory pool for balloc accounting */
116
117extern int locked_queue_count;
118extern long locked_queue_bytes;
119extern int lfs_subsys_pages;
120extern int lfs_dirvcount;
121extern kmutex_t lfs_lock;
122extern int lfs_debug_log_subsys[];
123extern kcondvar_t lfs_writing_cv;
124extern kcondvar_t locked_queue_cv;
125
126/* lfs_alloc.c */
127int lfs_valloc(struct vnode *, int, kauth_cred_t, ino_t *, int *);
128int lfs_valloc_fixed(struct lfs *, ino_t, int);
129int lfs_vfree(struct vnode *, ino_t, int);
130void lfs_order_freelist(struct lfs *, ino_t **, size_t *);
131int lfs_extend_ifile(struct lfs *, kauth_cred_t);
132void lfs_orphan(struct lfs *, ino_t);
133void lfs_free_orphans(struct lfs *, ino_t *, size_t);
134
135/* lfs_balloc.c */
136int lfs_balloc(struct vnode *, off_t, int, kauth_cred_t, int, struct buf **);
137void lfs_register_block(struct vnode *, daddr_t);
138void lfs_deregister_block(struct vnode *, daddr_t);
139void lfs_deregister_all(struct vnode *);
140
141/* lfs_bio.c */
142int lfs_availwait(struct lfs *, int);
143int lfs_bwrite_ext(struct buf *, int);
144int lfs_fits(struct lfs *, int);
145void lfs_flush_fs(struct lfs *, int);
146void lfs_flush(struct lfs *, int, int);
147int lfs_check(struct vnode *, daddr_t, int);
148void lfs_freebuf(struct lfs *, struct buf *);
149struct buf *lfs_newbuf(struct lfs *, struct vnode *, daddr_t, size_t, int);
150void lfs_countlocked(int *, long *, const char *);
151int lfs_reserve(struct lfs *, struct vnode *, struct vnode *, int);
152int lfs_max_bufs(void);
153int lfs_wait_bufs(void);
154
155/* lfs_debug.c */
156#ifdef DEBUG
157int lfs_bwrite_log(struct buf *, const char *, int);
158void lfs_dumplog(void);
159void lfs_dump_super(struct lfs *);
160void lfs_dump_dinode(struct lfs *, union lfs_dinode *);
161void lfs_check_bpp(struct lfs *, struct segment *, char *, int);
162void lfs_check_segsum(struct lfs *, struct segment *, char *, int);
163void lfs_debug_log(int, const char *, ...);
164#endif /* DEBUG */
165
166/* lfs_inode.c */
167int lfs_update(struct vnode *, const struct timespec *, const struct timespec *,
168    int);
169int lfs_truncate(struct vnode *, off_t, int, kauth_cred_t);
170union lfs_dinode *lfs_ifind(struct lfs *, ino_t, struct buf *);
171void lfs_finalize_ino_seguse(struct lfs *, struct inode *);
172void lfs_finalize_fs_seguse(struct lfs *);
173
174/* lfs_rename.c */
175int lfs_rename(void *);
176
177/* lfs_rfw.c */
178int lfs_rf_valloc(struct lfs *, ino_t, int, struct lwp *, struct vnode **);
179void lfs_roll_forward(struct lfs *, struct mount *, struct lwp *);
180
181/* lfs_segment.c */
182void lfs_imtime(struct lfs *);
183int lfs_vflush(struct vnode *);
184int lfs_segwrite(struct mount *, int);
185int lfs_writefile(struct lfs *, struct segment *, struct vnode *);
186int lfs_writeinode(struct lfs *, struct segment *, struct inode *);
187int lfs_gatherblock(struct segment *, struct buf *, kmutex_t *);
188int lfs_gather(struct lfs *, struct segment *, struct vnode *, int (*match )(struct lfs *, struct buf *));
189void lfs_update_single(struct lfs *, struct segment *, struct vnode *,
190    daddr_t, daddr_t, int);
191void lfs_updatemeta(struct segment *);
192int lfs_rewind(struct lfs *, int);
193void lfs_unset_inval_all(struct lfs *);
194int lfs_initseg(struct lfs *);
195int lfs_writeseg(struct lfs *, struct segment *);
196void lfs_writesuper(struct lfs *, daddr_t);
197int lfs_match_data(struct lfs *, struct buf *);
198int lfs_match_indir(struct lfs *, struct buf *);
199int lfs_match_dindir(struct lfs *, struct buf *);
200int lfs_match_tindir(struct lfs *, struct buf *);
201void lfs_free_aiodone(struct buf *);
202void lfs_acquire_finfo(struct lfs *fs, ino_t, int);
203void lfs_release_finfo(struct lfs *fs);
204
205/* lfs_subr.c */
206void lfs_setup_resblks(struct lfs *);
207void lfs_pad_check(unsigned char *, int, char *, int);
208void lfs_free_resblks(struct lfs *);
209void *lfs_malloc(struct lfs *, size_t, int);
210void lfs_free(struct lfs *, void *, int);
211int lfs_seglock(struct lfs *, unsigned long);
212void lfs_segunlock(struct lfs *);
213void lfs_segunlock_relock(struct lfs *);
214void lfs_writer_enter(struct lfs *, const char *);
215int lfs_writer_tryenter(struct lfs *);
216void lfs_writer_leave(struct lfs *);
217void lfs_wakeup_cleaner(struct lfs *);
218
219/* lfs_syscalls.c */
220int lfs_do_segclean(struct lfs *, unsigned long);
221int lfs_segwait(fsid_t *, struct timeval *);
222int lfs_bmapv(struct lwp *, fsid_t *, struct block_info *, int);
223int lfs_markv(struct lwp *, fsid_t *, struct block_info *, int);
224
225/* lfs_vfsops.c */
226VFS_PROTOS(lfs);
227void lfs_vinit(struct mount *, struct vnode **);
228int lfs_resize_fs(struct lfs *, int);
229
230/* lfs_vnops.c */
231void lfs_mark_vnode(struct vnode *);
232void lfs_unmark_vnode(struct vnode *);
233int lfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
234void lfs_gop_size(struct vnode *, off_t, off_t *, int);
235int lfs_putpages_ext(void *, int);
236int lfs_gatherpages(struct vnode *);
237int lfs_flush_dirops(struct lfs *);
238int lfs_flush_pchain(struct lfs *);
239
240int lfs_bwrite	 (void *);
241int lfs_fsync	 (void *);
242int lfs_symlink	 (void *);
243int lfs_mknod	 (void *);
244int lfs_create	 (void *);
245int lfs_mkdir	 (void *);
246int lfs_read	 (void *);
247int lfs_remove	 (void *);
248int lfs_rmdir	 (void *);
249int lfs_link	 (void *);
250int lfs_mmap	 (void *);
251int lfs_rename	 (void *);
252int lfs_getattr	 (void *);
253int lfs_setattr	 (void *);
254int lfs_close	 (void *);
255int lfsspec_close(void *);
256int lfsfifo_close(void *);
257int lfs_fcntl	 (void *);
258int lfs_inactive (void *);
259int lfs_reclaim	 (void *);
260int lfs_strategy (void *);
261int lfs_write	 (void *);
262int lfs_getpages (void *);
263int lfs_putpages (void *);
264
265int lfs_bufrd(struct vnode *, struct uio *, int, kauth_cred_t);
266int lfs_bufwr(struct vnode *, struct uio *, int, kauth_cred_t);
267
268extern int lfs_mount_type;
269extern int (**lfs_vnodeop_p)(void *);
270extern int (**lfs_specop_p)(void *);
271extern int (**lfs_fifoop_p)(void *);
272extern const struct genfs_ops lfs_genfsops;
273
274#endif /* defined(_KERNEL) */
275
276/* lfs_cksum.c */
277uint32_t cksum(void *, size_t);
278uint32_t lfs_cksum_part(void *, size_t, uint32_t);
279#define lfs_cksum_fold(sum)	(sum)
280uint32_t lfs_sb_cksum(struct lfs *);
281
282__END_DECLS
283
284#endif /* !_UFS_LFS_LFS_EXTERN_H_ */