1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1982, 1986, 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 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. 18 * 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 29 * SUCH DAMAGE. 30 * 31 * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 32 */ 33 34 #ifndef _UFS_UFS_UFSMOUNT_H_ 35 #define _UFS_UFS_UFSMOUNT_H_ 36 37 /* 38 * Arguments to mount UFS-based filesystems 39 */ 40 struct ufs_args { 41 char *fspec; /* block special device to mount */ 42 struct oexport_args export; /* network export information */ 43 }; 44 45 #ifdef _KERNEL 46 47 #include <sys/_lock.h> 48 #include <sys/_mutex.h> 49 #include <sys/_sx.h> 50 #include <sys/_task.h> 51 52 #ifdef MALLOC_DECLARE 53 MALLOC_DECLARE(M_UFSMNT); 54 MALLOC_DECLARE(M_TRIM); 55 #endif 56 57 struct buf; 58 struct inode; 59 struct nameidata; 60 struct taskqueue; 61 struct timeval; 62 struct ucred; 63 struct uio; 64 struct vnode; 65 struct ufs_extattr_per_mount; 66 struct jblocks; 67 struct inodedep; 68 69 TAILQ_HEAD(inodedeplst, inodedep); 70 LIST_HEAD(bmsafemaphd, bmsafemap); 71 LIST_HEAD(trimlist_hashhead, ffs_blkfree_trim_params); 72 struct fsfail_task { 73 struct task task; 74 fsid_t fsid; 75 }; 76 77 /* 78 * This structure describes the UFS specific mount structure data. 79 * The function operators are used to support different versions of 80 * UFS (UFS1, UFS2, etc). 81 * 82 * Lock reference: 83 * c - set at allocation then constant until freed 84 * i - ufsmount interlock (UFS_LOCK / UFS_UNLOCK) 85 * q - associated quota file is locked 86 * r - ref to parent mount structure is held (vfs_busy / vfs_unbusy) 87 */ 88 struct ufsmount { 89 struct mount *um_mountp; /* (r) filesystem vfs struct */ 90 struct cdev *um_dev; /* (r) device mounted */ 91 struct g_consumer *um_cp; /* (r) GEOM access point */ 92 struct bufobj *um_bo; /* (r) Buffer cache object */ 93 struct vnode *um_odevvp; /* (r) devfs dev vnode */ 94 struct vnode *um_devvp; /* (r) mntfs private vnode */ 95 uint64_t um_fstype; /* (c) type of filesystem */ 96 struct fs *um_fs; /* (r) pointer to superblock */ 97 struct ufs_extattr_per_mount um_extattr; /* (c) extended attrs */ 98 uint64_t um_nindir; /* (c) indirect ptrs per blk */ 99 uint64_t um_bptrtodb; /* (c) indir disk block ptr */ 100 uint64_t um_seqinc; /* (c) inc between seq blocks */ 101 uint64_t um_maxsymlinklen; /* (c) max size of short 102 symlink */ 103 struct mtx um_lock; /* (c) Protects ufsmount & fs */ 104 struct sx um_checkpath_lock; /* (c) Protects ufs_checkpath() 105 result */ 106 struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */ 107 struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */ 108 struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */ 109 time_t um_btime[MAXQUOTAS]; /* (q) block quota time limit */ 110 time_t um_itime[MAXQUOTAS]; /* (q) inode quota time limit */ 111 char um_qflags[MAXQUOTAS]; /* (i) quota specific flags */ 112 int64_t um_savedmaxfilesize; /* (c) track maxfilesize */ 113 uint64_t um_flags; /* (i) filesystem flags */ 114 struct timeval um_last_fullmsg; /* (i) last full msg time */ 115 int um_secs_fullmsg; /* (i) seconds since full msg */ 116 struct timeval um_last_integritymsg; /* (i) last integrity msg */ 117 int um_secs_integritymsg; /* (i) secs since integ msg */ 118 uint64_t um_trim_inflight; /* (i) outstanding trim count */ 119 uint64_t um_trim_inflight_blks; /* (i) outstanding trim blks */ 120 uint64_t um_trim_total; /* (i) total trim count */ 121 uint64_t um_trim_total_blks; /* (i) total trim block count */ 122 struct taskqueue *um_trim_tq; /* (c) trim request queue */ 123 struct trimlist_hashhead *um_trimhash; /* (i) trimlist hash table */ 124 u_long um_trimlisthashsize; /* (i) trim hash table size-1 */ 125 struct fsfail_task *um_fsfail_task; /* (i) task for fsfail cleanup*/ 126 /* (c) - below function ptrs */ 127 int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, 128 int, struct buf **); 129 int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **); 130 int (*um_truncate)(struct vnode *, off_t, int, struct ucred *); 131 int (*um_update)(struct vnode *, int); 132 int (*um_valloc)(struct vnode *, int, struct ucred *, 133 struct vnode **); 134 int (*um_vfree)(struct vnode *, ino_t, int); 135 void (*um_ifree)(struct ufsmount *, struct inode *); 136 int (*um_rdonly)(struct inode *); 137 void (*um_snapgone)(struct inode *); 138 int (*um_check_blkno)(struct mount *, ino_t, daddr_t, int); 139 }; 140 141 /* 142 * filesystem flags 143 */ 144 #define UM_CANDELETE 0x00000001 /* devvp supports TRIM */ 145 #define UM_WRITESUSPENDED 0x00000002 /* suspension in progress */ 146 #define UM_CANSPEEDUP 0x00000004 /* devvp supports SPEEDUP */ 147 #define UM_FSFAIL_CLEANUP 0x00000008 /* need cleanup after 148 unrecoverable error */ 149 /* 150 * function prototypes 151 */ 152 #define UFS_BALLOC(aa, bb, cc, dd, ee, ff) \ 153 VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff) 154 #define UFS_BLKATOFF(aa, bb, cc, dd) \ 155 VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd) 156 #define UFS_TRUNCATE(aa, bb, cc, dd) \ 157 VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd) 158 #define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb) 159 #define UFS_VALLOC(aa, bb, cc, dd) \ 160 VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd) 161 #define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc) 162 #define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb)) 163 #define UFS_RDONLY(aa) (ITOUMP(aa)->um_rdonly(aa)) 164 #define UFS_SNAPGONE(aa) (ITOUMP(aa)->um_snapgone(aa)) 165 #define UFS_CHECK_BLKNO(aa, bb, cc, dd) \ 166 (VFSTOUFS(aa)->um_check_blkno == NULL ? 0 : \ 167 VFSTOUFS(aa)->um_check_blkno(aa, bb, cc, dd)) 168 169 #define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock) 170 #define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock) 171 #define UFS_MTX(aa) (&(aa)->um_lock) 172 173 /* 174 * Filesystem types 175 */ 176 #define UFS1 1 177 #define UFS2 2 178 179 /* 180 * Flags describing the state of quotas. 181 */ 182 #define QTF_OPENING 0x01 /* Q_QUOTAON in progress */ 183 #define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */ 184 #define QTF_64BIT 0x04 /* 64-bit quota file */ 185 186 /* Convert mount ptr to ufsmount ptr. */ 187 #define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data)) 188 #define UFSTOVFS(ump) (ump)->um_mountp 189 190 /* 191 * Macros to access filesystem parameters in the ufsmount structure. 192 * Used by ufs_bmap. 193 */ 194 #define MNINDIR(ump) ((ump)->um_nindir) 195 #define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) 196 #define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) 197 #endif /* _KERNEL */ 198 199 /* true if old FS format...*/ 200 #define OFSFMT(vp) (VFSTOUFS((vp)->v_mount)->um_maxsymlinklen <= 0) 201 202 #endif 203