1139825Simp/*-
21541Srgrimes * Copyright (c) 1982, 1986, 1989, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
2922521Sdyson *	@(#)ufsmount.h	8.6 (Berkeley) 3/30/95
3050477Speter * $FreeBSD$
311541Srgrimes */
321541Srgrimes
332177Spaul#ifndef _UFS_UFS_UFSMOUNT_H_
34262779Spfg#define	_UFS_UFS_UFSMOUNT_H_
352177Spaul
36156203Sjeff#include <sys/buf.h>	/* XXX For struct workhead. */
37156203Sjeff
3822521Sdyson/*
3922521Sdyson * Arguments to mount UFS-based filesystems
4022521Sdyson */
4122521Sdysonstruct ufs_args {
4222521Sdyson	char	*fspec;			/* block special device to mount */
43213664Skib	struct	oexport_args export;	/* network export information */
4422521Sdyson};
4522521Sdyson
4655206Speter#ifdef _KERNEL
4730354Sphk
4830354Sphk#ifdef MALLOC_DECLARE
4930354SphkMALLOC_DECLARE(M_UFSMNT);
5030354Sphk#endif
5130354Sphk
521541Srgrimesstruct buf;
531541Srgrimesstruct inode;
541541Srgrimesstruct nameidata;
55297787Skibstruct taskqueue;
561541Srgrimesstruct timeval;
571541Srgrimesstruct ucred;
581541Srgrimesstruct uio;
591541Srgrimesstruct vnode;
6059241Srwatsonstruct ufs_extattr_per_mount;
61207141Sjeffstruct jblocks;
62207141Sjeffstruct inodedep;
631541Srgrimes
64207141SjeffTAILQ_HEAD(inodedeplst, inodedep);
65222958SjeffLIST_HEAD(bmsafemaphd, bmsafemap);
66207141Sjeff
671541Srgrimes/* This structure describes the UFS specific mount structure data. */
681541Srgrimesstruct ufsmount {
691541Srgrimes	struct	mount *um_mountp;		/* filesystem vfs structure */
70181329Sdes	struct	cdev *um_dev;			/* device mounted */
71181329Sdes	struct	g_consumer *um_cp;
72181329Sdes	struct	bufobj *um_bo;			/* Buffer cache object */
731541Srgrimes	struct	vnode *um_devvp;		/* block device mounted vnode */
7498542Smckusick	u_long	um_fstype;			/* type of filesystem */
7596873Siedowse	struct	fs *um_fs;			/* pointer to superblock */
7659241Srwatson	struct	ufs_extattr_per_mount um_extattr;	/* extended attrs */
771541Srgrimes	u_long	um_nindir;			/* indirect ptrs per block */
781541Srgrimes	u_long	um_bptrtodb;			/* indir ptr to disk block */
791541Srgrimes	u_long	um_seqinc;			/* inc between seq blocks */
80140700Sjeff	struct	mtx um_lock;			/* Protects ufsmount & fs */
81224061Smckusick	pid_t	um_fsckpid;			/* PID permitted fsck sysctls */
82260078Smckusick	struct	mount_softdeps *um_softdep;	/* softdep mgmt structure */
83140700Sjeff	struct	vnode *um_quotas[MAXQUOTAS];	/* pointer to quota files */
84140700Sjeff	struct	ucred *um_cred[MAXQUOTAS];	/* quota file access cred */
851541Srgrimes	time_t	um_btime[MAXQUOTAS];		/* block quota time limit */
861541Srgrimes	time_t	um_itime[MAXQUOTAS];		/* inode quota time limit */
871541Srgrimes	char	um_qflags[MAXQUOTAS];		/* quota specific flags */
8822521Sdyson	int64_t	um_savedmaxfilesize;		/* XXX - limit maxfilesize */
89216796Skib	int	um_candelete;			/* devvp supports TRIM */
90243245Strasz	int	um_writesuspended;		/* suspension in progress */
91297787Skib	u_int	um_trim_inflight;
92297787Skib	struct taskqueue *um_trim_tq;
93297786Skib	int	(*um_balloc)(struct vnode *, off_t, int, struct ucred *,
94297786Skib		    int, struct buf **);
9592728Salfred	int	(*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);
96234605Strasz	int	(*um_truncate)(struct vnode *, off_t, int, struct ucred *);
9792728Salfred	int	(*um_update)(struct vnode *, int);
98297786Skib	int	(*um_valloc)(struct vnode *, int, struct ucred *,
99297786Skib		    struct vnode **);
10092728Salfred	int	(*um_vfree)(struct vnode *, ino_t, int);
101108313Sphk	void	(*um_ifree)(struct ufsmount *, struct inode *);
102183070Skib	int	(*um_rdonly)(struct inode *);
103219804Skib	void	(*um_snapgone)(struct inode *);
1041541Srgrimes};
10522521Sdyson
106262779Spfg#define	UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
107262779Spfg#define	UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
108262779Spfg#define	UFS_TRUNCATE(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd)
109262779Spfg#define	UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
110262779Spfg#define	UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
111262779Spfg#define	UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
112262779Spfg#define	UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb))
113183070Skib#define	UFS_RDONLY(aa) ((aa)->i_ump->um_rdonly(aa))
114219804Skib#define	UFS_SNAPGONE(aa) ((aa)->i_ump->um_snapgone(aa))
11530474Sphk
116140700Sjeff#define	UFS_LOCK(aa)	mtx_lock(&(aa)->um_lock)
117140700Sjeff#define	UFS_UNLOCK(aa)	mtx_unlock(&(aa)->um_lock)
118140700Sjeff#define	UFS_MTX(aa)	(&(aa)->um_lock)
119140700Sjeff
1201541Srgrimes/*
12198542Smckusick * Filesystem types
12298542Smckusick */
123262779Spfg#define	UFS1	1
124262779Spfg#define	UFS2	2
12598542Smckusick
12698542Smckusick/*
1271541Srgrimes * Flags describing the state of quotas.
1281541Srgrimes */
1291541Srgrimes#define	QTF_OPENING	0x01			/* Q_QUOTAON in progress */
1301541Srgrimes#define	QTF_CLOSING	0x02			/* Q_QUOTAOFF in progress */
131262779Spfg#define	QTF_64BIT	0x04			/* 64-bit quota file */
1321541Srgrimes
1331541Srgrimes/* Convert mount ptr to ufsmount ptr. */
134262779Spfg#define	VFSTOUFS(mp)	((struct ufsmount *)((mp)->mnt_data))
135156203Sjeff#define	UFSTOVFS(ump)	(ump)->um_mountp
1361541Srgrimes
1371541Srgrimes/*
13896755Strhodes * Macros to access filesystem parameters in the ufsmount structure.
1391541Srgrimes * Used by ufs_bmap.
1401541Srgrimes */
141262779Spfg#define	MNINDIR(ump)			((ump)->um_nindir)
14222521Sdyson#define	blkptrtodb(ump, b)		((b) << (ump)->um_bptrtodb)
14322521Sdyson#define	is_sequential(ump, a, b)	((b) == (a) + ump->um_seqinc)
14455206Speter#endif /* _KERNEL */
1451541Srgrimes
1462177Spaul#endif
147