2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95
35 #ifndef _UFS_UFS_UFSMOUNT_H_
36 #define _UFS_UFS_UFSMOUNT_H_
39 * Arguments to mount UFS-based filesystems
42 char *fspec; /* block special device to mount */
43 struct oexport_args export; /* network export information */
49 MALLOC_DECLARE(M_UFSMNT);
50 MALLOC_DECLARE(M_TRIM);
61 struct ufs_extattr_per_mount;
65 TAILQ_HEAD(inodedeplst, inodedep);
66 LIST_HEAD(bmsafemaphd, bmsafemap);
67 LIST_HEAD(trimlist_hashhead, ffs_blkfree_trim_params);
70 * This structure describes the UFS specific mount structure data.
71 * The function operators are used to support different versions of
72 * UFS (UFS1, UFS2, etc).
75 * c - set at allocation then constant until freed
76 * i - ufsmount interlock (UFS_LOCK / UFS_UNLOCK)
77 * q - associated quota file is locked
78 * r - ref to parent mount structure is held (vfs_busy / vfs_unbusy)
79 * u - managed by user process fsck_ufs
82 struct mount *um_mountp; /* (r) filesystem vfs struct */
83 struct cdev *um_dev; /* (r) device mounted */
84 struct g_consumer *um_cp; /* (r) GEOM access point */
85 struct bufobj *um_bo; /* (r) Buffer cache object */
86 struct vnode *um_devvp; /* (r) blk dev mounted vnode */
87 u_long um_fstype; /* (c) type of filesystem */
88 struct fs *um_fs; /* (r) pointer to superblock */
89 struct ufs_extattr_per_mount um_extattr; /* (c) extended attrs */
90 u_long um_nindir; /* (c) indirect ptrs per blk */
91 u_long um_bptrtodb; /* (c) indir disk block ptr */
92 u_long um_seqinc; /* (c) inc between seq blocks */
93 struct mtx um_lock; /* (c) Protects ufsmount & fs */
94 pid_t um_fsckpid; /* (u) PID can do fsck sysctl */
95 struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */
96 struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */
97 struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */
98 time_t um_btime[MAXQUOTAS]; /* (q) block quota time limit */
99 time_t um_itime[MAXQUOTAS]; /* (q) inode quota time limit */
100 char um_qflags[MAXQUOTAS]; /* (i) quota specific flags */
101 int64_t um_savedmaxfilesize; /* (c) track maxfilesize */
102 u_int um_flags; /* (i) filesystem flags */
103 u_int um_trim_inflight; /* (i) outstanding trim count */
104 u_int um_trim_inflight_blks; /* (i) outstanding trim blks */
105 u_long um_trim_total; /* (i) total trim count */
106 u_long um_trim_total_blks; /* (i) total trim block count */
107 struct taskqueue *um_trim_tq; /* (c) trim request queue */
108 struct trimlist_hashhead *um_trimhash; /* (i) trimlist hash table */
109 u_long um_trimlisthashsize; /* (i) trim hash table size-1 */
110 /* (c) - below function ptrs */
111 int (*um_balloc)(struct vnode *, off_t, int, struct ucred *,
113 int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);
114 int (*um_truncate)(struct vnode *, off_t, int, struct ucred *);
115 int (*um_update)(struct vnode *, int);
116 int (*um_valloc)(struct vnode *, int, struct ucred *,
118 int (*um_vfree)(struct vnode *, ino_t, int);
119 void (*um_ifree)(struct ufsmount *, struct inode *);
120 int (*um_rdonly)(struct inode *);
121 void (*um_snapgone)(struct inode *);
127 #define UM_CANDELETE 0x00000001 /* devvp supports TRIM */
128 #define UM_WRITESUSPENDED 0x00000002 /* suspension in progress */
131 * function prototypes
133 #define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
134 #define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
135 #define UFS_TRUNCATE(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd)
136 #define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
137 #define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
138 #define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
139 #define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb))
140 #define UFS_RDONLY(aa) (ITOUMP(aa)->um_rdonly(aa))
141 #define UFS_SNAPGONE(aa) (ITOUMP(aa)->um_snapgone(aa))
143 #define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock)
144 #define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock)
145 #define UFS_MTX(aa) (&(aa)->um_lock)
154 * Flags describing the state of quotas.
156 #define QTF_OPENING 0x01 /* Q_QUOTAON in progress */
157 #define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */
158 #define QTF_64BIT 0x04 /* 64-bit quota file */
160 /* Convert mount ptr to ufsmount ptr. */
161 #define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
162 #define UFSTOVFS(ump) (ump)->um_mountp
165 * Macros to access filesystem parameters in the ufsmount structure.
168 #define MNINDIR(ump) ((ump)->um_nindir)
169 #define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb)
170 #define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc)