ffs_extern.h revision 223020
1161651Skan/*-
290075Sobrien * Copyright (c) 1991, 1993, 1994
390075Sobrien *	The Regents of the University of California.  All rights reserved.
490075Sobrien *
5169689Skan * Redistribution and use in source and binary forms, with or without
6169689Skan * modification, are permitted provided that the following conditions
7169689Skan * are met:
8169689Skan * 1. Redistributions of source code must retain the above copyright
9169689Skan *    notice, this list of conditions and the following disclaimer.
1090075Sobrien * 2. Redistributions in binary form must reproduce the above copyright
11169689Skan *    notice, this list of conditions and the following disclaimer in the
1290075Sobrien *    documentation and/or other materials provided with the distribution.
1390075Sobrien * 4. Neither the name of the University nor the names of its contributors
1490075Sobrien *    may be used to endorse or promote products derived from this software
1590075Sobrien *    without specific prior written permission.
1690075Sobrien *
1790075Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1890075Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1990075Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2090075Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2190075Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2290075Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2390075Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2490075Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2590075Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2690075Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2790075Sobrien * SUCH DAMAGE.
2890075Sobrien *
2990075Sobrien *	@(#)ffs_extern.h	8.6 (Berkeley) 3/30/95
3090075Sobrien * $FreeBSD: head/sys/ufs/ffs/ffs_extern.h 223020 2011-06-12 19:27:05Z mckusick $
3190075Sobrien */
3290075Sobrien
3390075Sobrien#ifndef _UFS_FFS_EXTERN_H
34132718Skan#define	_UFS_FFS_EXTERN_H
35132718Skan
3690075Sobrienstruct buf;
3790075Sobrienstruct cg;
3890075Sobrienstruct fid;
3990075Sobrienstruct fs;
40132718Skanstruct inode;
41132718Skanstruct malloc_type;
42132718Skanstruct mount;
43132718Skanstruct thread;
44132718Skanstruct sockaddr;
45132718Skanstruct statfs;
46132718Skanstruct ucred;
47132718Skanstruct vnode;
48132718Skanstruct vop_fsync_args;
49132718Skanstruct vop_reallocblks_args;
50132718Skanstruct workhead;
51132718Skan
52132718Skanint	ffs_alloc(struct inode *, ufs2_daddr_t, ufs2_daddr_t, int, int,
5390075Sobrien	    struct ucred *, ufs2_daddr_t *);
54169689Skanint	ffs_balloc_ufs1(struct vnode *a_vp, off_t a_startoffset, int a_size,
55169689Skan            struct ucred *a_cred, int a_flags, struct buf **a_bpp);
56169689Skanint	ffs_balloc_ufs2(struct vnode *a_vp, off_t a_startoffset, int a_size,
57169689Skan            struct ucred *a_cred, int a_flags, struct buf **a_bpp);
58169689Skanint	ffs_blkatoff(struct vnode *, off_t, char **, struct buf **);
59169689Skanvoid	ffs_blkfree(struct ufsmount *, struct fs *, struct vnode *,
60169689Skan	    ufs2_daddr_t, long, ino_t, struct workhead *);
61169689Skanufs2_daddr_t ffs_blkpref_ufs1(struct inode *, ufs_lbn_t, int, ufs1_daddr_t *);
62169689Skanufs2_daddr_t ffs_blkpref_ufs2(struct inode *, ufs_lbn_t, int, ufs2_daddr_t *);
63169689Skanint	ffs_checkfreefile(struct fs *, struct vnode *, ino_t);
64169689Skanvoid	ffs_clrblock(struct fs *, u_char *, ufs1_daddr_t);
65169689Skanvoid	ffs_clusteracct(struct fs *, struct cg *, ufs1_daddr_t, int);
66169689Skanvoid	ffs_bdflush(struct bufobj *, struct buf *);
67169689Skanint	ffs_copyonwrite(struct vnode *, struct buf *);
68169689Skanint	ffs_flushfiles(struct mount *, int, struct thread *);
69169689Skanvoid	ffs_fragacct(struct fs *, int, int32_t [], int);
70int	ffs_freefile(struct ufsmount *, struct fs *, struct vnode *, ino_t,
71	    int, struct workhead *);
72int	ffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
73int	ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
74void	ffs_load_inode(struct buf *, struct inode *, struct fs *, ino_t);
75int	ffs_mountroot(void);
76void	ffs_oldfscompat_write(struct fs *, struct ufsmount *);
77void	ffs_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end);
78int	ffs_reallocblks(struct vop_reallocblks_args *);
79int	ffs_realloccg(struct inode *, ufs2_daddr_t, ufs2_daddr_t,
80	    ufs2_daddr_t, int, int, int, struct ucred *, struct buf **);
81int	ffs_sbupdate(struct ufsmount *, int, int);
82void	ffs_setblock(struct fs *, u_char *, ufs1_daddr_t);
83int	ffs_snapblkfree(struct fs *, struct vnode *, ufs2_daddr_t, long, ino_t,
84	    struct workhead *);
85void	ffs_snapremove(struct vnode *vp);
86int	ffs_snapshot(struct mount *mp, char *snapfile);
87void	ffs_snapshot_mount(struct mount *mp);
88void	ffs_snapshot_unmount(struct mount *mp);
89void	process_deferred_inactive(struct mount *mp);
90void	ffs_sync_snap(struct mount *, int);
91int	ffs_syncvnode(struct vnode *vp, int waitfor);
92int	ffs_truncate(struct vnode *, off_t, int, struct ucred *, struct thread *);
93int	ffs_update(struct vnode *, int);
94int	ffs_valloc(struct vnode *, int, struct ucred *, struct vnode **);
95
96int	ffs_vfree(struct vnode *, ino_t, int);
97vfs_vget_t ffs_vget;
98int	ffs_vgetf(struct mount *, ino_t, int, struct vnode **, int);
99
100#define	FFSV_FORCEINSMQ	0x0001
101
102extern struct vop_vector ffs_vnodeops1;
103extern struct vop_vector ffs_fifoops1;
104extern struct vop_vector ffs_vnodeops2;
105extern struct vop_vector ffs_fifoops2;
106
107/*
108 * Soft update function prototypes.
109 */
110
111int	softdep_check_suspend(struct mount *, struct vnode *,
112	  int, int, int, int);
113void	softdep_get_depcounts(struct mount *, int *, int *);
114void	softdep_initialize(void);
115void	softdep_uninitialize(void);
116int	softdep_mount(struct vnode *, struct mount *, struct fs *,
117	    struct ucred *);
118void	softdep_unmount(struct mount *);
119int	softdep_move_dependencies(struct buf *, struct buf *);
120int	softdep_flushworklist(struct mount *, int *, struct thread *);
121int	softdep_flushfiles(struct mount *, int, struct thread *);
122void	softdep_update_inodeblock(struct inode *, struct buf *, int);
123void	softdep_load_inodeblock(struct inode *);
124void	softdep_freefile(struct vnode *, ino_t, int);
125int	softdep_request_cleanup(struct fs *, struct vnode *,
126	    struct ucred *, int);
127void	softdep_setup_freeblocks(struct inode *, off_t, int);
128void	softdep_setup_inomapdep(struct buf *, struct inode *, ino_t);
129void	softdep_setup_blkmapdep(struct buf *, struct mount *, ufs2_daddr_t,
130	    int, int);
131void	softdep_setup_allocdirect(struct inode *, ufs_lbn_t, ufs2_daddr_t,
132	    ufs2_daddr_t, long, long, struct buf *);
133void	softdep_setup_allocext(struct inode *, ufs_lbn_t, ufs2_daddr_t,
134	    ufs2_daddr_t, long, long, struct buf *);
135void	softdep_setup_allocindir_meta(struct buf *, struct inode *,
136	    struct buf *, int, ufs2_daddr_t);
137void	softdep_setup_allocindir_page(struct inode *, ufs_lbn_t,
138	    struct buf *, int, ufs2_daddr_t, ufs2_daddr_t, struct buf *);
139void	softdep_setup_blkfree(struct mount *, struct buf *, ufs2_daddr_t, int,
140	    struct workhead *);
141void	softdep_setup_inofree(struct mount *, struct buf *, ino_t,
142	    struct workhead *);
143void	softdep_setup_sbupdate(struct ufsmount *, struct fs *, struct buf *);
144void	softdep_fsync_mountdev(struct vnode *);
145int	softdep_sync_metadata(struct vnode *);
146int	softdep_sync_buf(struct vnode *, struct buf *, int);
147int     softdep_process_worklist(struct mount *, int);
148int     softdep_fsync(struct vnode *);
149int	softdep_waitidle(struct mount *);
150int	softdep_prealloc(struct vnode *, int);
151int	softdep_journal_lookup(struct mount *, struct vnode **);
152void	softdep_journal_freeblocks(struct inode *, struct ucred *, off_t, int);
153void	softdep_journal_fsync(struct inode *);
154void	softdep_buf_append(struct buf *, struct workhead *);
155void	softdep_inode_append(struct inode *, struct ucred *, struct workhead *);
156void	softdep_freework(struct workhead *);
157
158
159/*
160 * Things to request flushing in softdep_request_cleanup()
161 */
162#define FLUSH_INODES		1
163#define FLUSH_INODES_WAIT	2
164#define FLUSH_BLOCKS		3
165#define FLUSH_BLOCKS_WAIT	4
166
167int	ffs_rdonly(struct inode *);
168
169TAILQ_HEAD(snaphead, inode);
170
171struct snapdata {
172	LIST_ENTRY(snapdata) sn_link;
173	struct snaphead sn_head;
174	daddr_t sn_listsize;
175	daddr_t *sn_blklist;
176	struct lock sn_lock;
177};
178
179#endif /* !_UFS_FFS_EXTERN_H */
180