117680Spst/*-
239300Sfenner * Copyright (c) 1991, 1993, 1994
317680Spst *	The Regents of the University of California.  All rights reserved.
417680Spst *
517680Spst * Redistribution and use in source and binary forms, with or without
617680Spst * modification, are permitted provided that the following conditions
717680Spst * are met:
817680Spst * 1. Redistributions of source code must retain the above copyright
917680Spst *    notice, this list of conditions and the following disclaimer.
1017680Spst * 2. Redistributions in binary form must reproduce the above copyright
1117680Spst *    notice, this list of conditions and the following disclaimer in the
1217680Spst *    documentation and/or other materials provided with the distribution.
1317680Spst * 4. Neither the name of the University nor the names of its contributors
1417680Spst *    may be used to endorse or promote products derived from this software
1517680Spst *    without specific prior written permission.
1617680Spst *
1717680Spst * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1817680Spst * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1917680Spst * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2017680Spst * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2117680Spst * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2256896Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2356896Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2417680Spst * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2526183Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2617680Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27127675Sbms * SUCH DAMAGE.
28127675Sbms *
2917680Spst *	@(#)ffs_extern.h	8.6 (Berkeley) 3/30/95
3017680Spst * $FreeBSD: releng/10.3/sys/ufs/ffs/ffs_extern.h 262779 2014-03-05 04:23:19Z pfg $
3156896Sfenner */
3256896Sfenner
3356896Sfenner#ifndef _UFS_FFS_EXTERN_H
3456896Sfenner#define	_UFS_FFS_EXTERN_H
35127675Sbms
3617680Spst#ifndef _KERNEL
3717680Spst#error "No user-serving parts inside"
3817680Spst#else
3917680Spst
4098527Sfennerstruct buf;
4117680Spststruct cg;
4217680Spststruct fid;
4317680Spststruct fs;
4417680Spststruct inode;
4517680Spststruct malloc_type;
4617680Spststruct mount;
4717680Spststruct thread;
4817680Spststruct sockaddr;
4917680Spststruct statfs;
5017680Spststruct ucred;
5117680Spststruct vnode;
5217680Spststruct vop_fsync_args;
5317680Spststruct vop_reallocblks_args;
5417680Spststruct workhead;
5517680Spst
5617680Spstint	ffs_alloc(struct inode *, ufs2_daddr_t, ufs2_daddr_t, int, int,
5717680Spst	    struct ucred *, ufs2_daddr_t *);
5817680Spstint	ffs_balloc_ufs1(struct vnode *a_vp, off_t a_startoffset, int a_size,
5975118Sfenner            struct ucred *a_cred, int a_flags, struct buf **a_bpp);
6075118Sfennerint	ffs_balloc_ufs2(struct vnode *a_vp, off_t a_startoffset, int a_size,
6175118Sfenner            struct ucred *a_cred, int a_flags, struct buf **a_bpp);
6275118Sfennerint	ffs_blkatoff(struct vnode *, off_t, char **, struct buf **);
6375118Sfennervoid	ffs_blkfree(struct ufsmount *, struct fs *, struct vnode *,
6475118Sfenner	    ufs2_daddr_t, long, ino_t, enum vtype, struct workhead *);
6575118Sfennerufs2_daddr_t ffs_blkpref_ufs1(struct inode *, ufs_lbn_t, int, ufs1_daddr_t *);
6617680Spstufs2_daddr_t ffs_blkpref_ufs2(struct inode *, ufs_lbn_t, int, ufs2_daddr_t *);
6717680Spstint	ffs_checkfreefile(struct fs *, struct vnode *, ino_t);
6817680Spstvoid	ffs_clrblock(struct fs *, u_char *, ufs1_daddr_t);
6917680Spstvoid	ffs_clusteracct(struct fs *, struct cg *, ufs1_daddr_t, int);
7017680Spstvoid	ffs_bdflush(struct bufobj *, struct buf *);
7117680Spstint	ffs_copyonwrite(struct vnode *, struct buf *);
7217680Spstint	ffs_flushfiles(struct mount *, int, struct thread *);
7317680Spstvoid	ffs_fragacct(struct fs *, int, int32_t [], int);
7417680Spstint	ffs_freefile(struct ufsmount *, struct fs *, struct vnode *, ino_t,
7517680Spst	    int, struct workhead *);
7617680Spstvoid	ffs_fserr(struct fs *, ino_t, char *);
7717680Spstint	ffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
7817680Spstint	ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
7917680Spstvoid	ffs_load_inode(struct buf *, struct inode *, struct fs *, ino_t);
8017680Spstint	ffs_mountroot(void);
8117680Spstvoid	ffs_oldfscompat_write(struct fs *, struct ufsmount *);
8217680Spstint	ffs_own_mount(const struct mount *mp);
8317680Spstint	ffs_reallocblks(struct vop_reallocblks_args *);
8498527Sfennerint	ffs_realloccg(struct inode *, ufs2_daddr_t, ufs2_daddr_t,
8598527Sfenner	    ufs2_daddr_t, int, int, int, struct ucred *, struct buf **);
86127675Sbmsint	ffs_reload(struct mount *, struct thread *, int);
87127675Sbmsint	ffs_sbupdate(struct ufsmount *, int, int);
8898527Sfennervoid	ffs_setblock(struct fs *, u_char *, ufs1_daddr_t);
89127675Sbmsint	ffs_snapblkfree(struct fs *, struct vnode *, ufs2_daddr_t, long, ino_t,
9098527Sfenner	    enum vtype, struct workhead *);
9198527Sfennervoid	ffs_snapremove(struct vnode *vp);
9298527Sfennerint	ffs_snapshot(struct mount *mp, char *snapfile);
9375118Sfennervoid	ffs_snapshot_mount(struct mount *mp);
9417680Spstvoid	ffs_snapshot_unmount(struct mount *mp);
95127675Sbmsvoid	process_deferred_inactive(struct mount *mp);
9675118Sfennervoid	ffs_sync_snap(struct mount *, int);
9717680Spstint	ffs_syncvnode(struct vnode *vp, int waitfor, int flags);
9817680Spstint	ffs_truncate(struct vnode *, off_t, int, struct ucred *);
9917680Spstint	ffs_update(struct vnode *, int);
10017680Spstint	ffs_valloc(struct vnode *, int, struct ucred *, struct vnode **);
10117680Spst
102127675Sbmsint	ffs_vfree(struct vnode *, ino_t, int);
10317680Spstvfs_vget_t ffs_vget;
10417690Spstint	ffs_vgetf(struct mount *, ino_t, int, struct vnode **, int);
105111729Sfennervoid	ffs_susp_initialize(void);
106111729Sfennervoid	ffs_susp_uninitialize(void);
107111729Sfenner
108111729Sfenner#define	FFSV_FORCEINSMQ	0x0001
109111729Sfenner
110111729Sfennerextern struct vop_vector ffs_vnodeops1;
111111729Sfennerextern struct vop_vector ffs_fifoops1;
112111729Sfennerextern struct vop_vector ffs_vnodeops2;
11398527Sfennerextern struct vop_vector ffs_fifoops2;
11417680Spst
11517680Spst/*
11617690Spst * Soft update function prototypes.
11717690Spst */
11817690Spst
11917690Spstint	softdep_check_suspend(struct mount *, struct vnode *,
12017690Spst	  int, int, int, int);
12117690Spstvoid	softdep_get_depcounts(struct mount *, int *, int *);
122127675Sbmsvoid	softdep_initialize(void);
12317680Spstvoid	softdep_uninitialize(void);
12417680Spstint	softdep_mount(struct vnode *, struct mount *, struct fs *,
12517680Spst	    struct ucred *);
12617680Spstvoid	softdep_unmount(struct mount *);
12717680Spstint	softdep_move_dependencies(struct buf *, struct buf *);
128127675Sbmsint	softdep_flushworklist(struct mount *, int *, struct thread *);
12917680Spstint	softdep_flushfiles(struct mount *, int, struct thread *);
13017680Spstvoid	softdep_update_inodeblock(struct inode *, struct buf *, int);
13117680Spstvoid	softdep_load_inodeblock(struct inode *);
13217680Spstvoid	softdep_freefile(struct vnode *, ino_t, int);
13317680Spstint	softdep_request_cleanup(struct fs *, struct vnode *,
13417680Spst	    struct ucred *, int);
13517680Spstvoid	softdep_setup_freeblocks(struct inode *, off_t, int);
13617680Spstvoid	softdep_setup_inomapdep(struct buf *, struct inode *, ino_t, int);
137127675Sbmsvoid	softdep_setup_blkmapdep(struct buf *, struct mount *, ufs2_daddr_t,
13817680Spst	    int, int);
13917680Spstvoid	softdep_setup_allocdirect(struct inode *, ufs_lbn_t, ufs2_daddr_t,
14017680Spst	    ufs2_daddr_t, long, long, struct buf *);
14117680Spstvoid	softdep_setup_allocext(struct inode *, ufs_lbn_t, ufs2_daddr_t,
14217680Spst	    ufs2_daddr_t, long, long, struct buf *);
14317680Spstvoid	softdep_setup_allocindir_meta(struct buf *, struct inode *,
144127675Sbms	    struct buf *, int, ufs2_daddr_t);
14517680Spstvoid	softdep_setup_allocindir_page(struct inode *, ufs_lbn_t,
14617680Spst	    struct buf *, int, ufs2_daddr_t, ufs2_daddr_t, struct buf *);
14717680Spstvoid	softdep_setup_blkfree(struct mount *, struct buf *, ufs2_daddr_t, int,
14817680Spst	    struct workhead *);
14917680Spstvoid	softdep_setup_inofree(struct mount *, struct buf *, ino_t,
15017680Spst	    struct workhead *);
15117680Spstvoid	softdep_setup_sbupdate(struct ufsmount *, struct fs *, struct buf *);
15217680Spstvoid	softdep_fsync_mountdev(struct vnode *);
15317680Spstint	softdep_sync_metadata(struct vnode *);
15417680Spstint	softdep_sync_buf(struct vnode *, struct buf *, int);
155127675Sbmsint     softdep_fsync(struct vnode *);
15617680Spstint	softdep_prealloc(struct vnode *, int);
15717680Spstint	softdep_journal_lookup(struct mount *, struct vnode **);
15817680Spstvoid	softdep_journal_freeblocks(struct inode *, struct ucred *, off_t, int);
15917680Spstvoid	softdep_journal_fsync(struct inode *);
16017680Spstvoid	softdep_buf_append(struct buf *, struct workhead *);
16117680Spstvoid	softdep_inode_append(struct inode *, struct ucred *, struct workhead *);
16217680Spstvoid	softdep_freework(struct workhead *);
16317680Spst
16417680Spst
16517680Spst/*
16617680Spst * Things to request flushing in softdep_request_cleanup()
16717680Spst */
16817680Spst#define	FLUSH_INODES		1
16917680Spst#define	FLUSH_INODES_WAIT	2
170127675Sbms#define	FLUSH_BLOCKS		3
17117680Spst#define	FLUSH_BLOCKS_WAIT	4
17217680Spst/*
17375118Sfenner * Flag to ffs_syncvnode() to request flushing of data only,
17475118Sfenner * but skip the ffs_update() on the inode itself. Used to avoid
17575118Sfenner * deadlock when flushing snapshot inodes while holding snaplk.
17675118Sfenner */
17775118Sfenner#define	NO_INO_UPDT		0x00000001
17875118Sfenner
17975118Sfennerint	ffs_rdonly(struct inode *);
18075118Sfenner
18175118SfennerTAILQ_HEAD(snaphead, inode);
18275118Sfenner
18375118Sfennerstruct snapdata {
18475118Sfenner	LIST_ENTRY(snapdata) sn_link;
18598527Sfenner	struct snaphead sn_head;
18698527Sfenner	daddr_t sn_listsize;
18775118Sfenner	daddr_t *sn_blklist;
18875118Sfenner	struct lock sn_lock;
18975118Sfenner};
19075118Sfenner
19175118Sfenner#endif /* _KERNEL */
19275118Sfenner
19375118Sfenner#endif /* !_UFS_FFS_EXTERN_H */
19475118Sfenner