ffs_alloc.c (202125) | ffs_alloc.c (203763) |
---|---|
1/*- 2 * Copyright (c) 2002 Networks Associates Technology, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by Marshall 6 * Kirk McKusick and Network Associates Laboratories, the Security 7 * Research Division of Network Associates, Inc. under DARPA/SPAWAR 8 * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS --- 46 unchanged lines hidden (view full) --- 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * SUCH DAMAGE. 58 * 59 * @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95 60 */ 61 62#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002 Networks Associates Technology, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by Marshall 6 * Kirk McKusick and Network Associates Laboratories, the Security 7 * Research Division of Network Associates, Inc. under DARPA/SPAWAR 8 * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS --- 46 unchanged lines hidden (view full) --- 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * SUCH DAMAGE. 58 * 59 * @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95 60 */ 61 62#include <sys/cdefs.h> |
63__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_alloc.c 202125 2010-01-11 22:42:06Z mckusick $"); | 63__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_alloc.c 203763 2010-02-10 20:10:35Z mckusick $"); |
64 65#include "opt_quota.h" 66 67#include <sys/param.h> 68#include <sys/systm.h> 69#include <sys/bio.h> 70#include <sys/buf.h> 71#include <sys/conf.h> --- 16 unchanged lines hidden (view full) --- 88#include <ufs/ufs/quota.h> 89#include <ufs/ufs/inode.h> 90#include <ufs/ufs/ufs_extern.h> 91#include <ufs/ufs/ufsmount.h> 92 93#include <ufs/ffs/fs.h> 94#include <ufs/ffs/ffs_extern.h> 95 | 64 65#include "opt_quota.h" 66 67#include <sys/param.h> 68#include <sys/systm.h> 69#include <sys/bio.h> 70#include <sys/buf.h> 71#include <sys/conf.h> --- 16 unchanged lines hidden (view full) --- 88#include <ufs/ufs/quota.h> 89#include <ufs/ufs/inode.h> 90#include <ufs/ufs/ufs_extern.h> 91#include <ufs/ufs/ufsmount.h> 92 93#include <ufs/ffs/fs.h> 94#include <ufs/ffs/ffs_extern.h> 95 |
96typedef ufs2_daddr_t allocfcn_t(struct inode *ip, int cg, ufs2_daddr_t bpref, | 96typedef ufs2_daddr_t allocfcn_t(struct inode *ip, u_int cg, ufs2_daddr_t bpref, |
97 int size); 98 | 97 int size); 98 |
99static ufs2_daddr_t ffs_alloccg(struct inode *, int, ufs2_daddr_t, int); | 99static ufs2_daddr_t ffs_alloccg(struct inode *, u_int, ufs2_daddr_t, int); |
100static ufs2_daddr_t 101 ffs_alloccgblk(struct inode *, struct buf *, ufs2_daddr_t); 102#ifdef INVARIANTS 103static int ffs_checkblk(struct inode *, ufs2_daddr_t, long); 104#endif | 100static ufs2_daddr_t 101 ffs_alloccgblk(struct inode *, struct buf *, ufs2_daddr_t); 102#ifdef INVARIANTS 103static int ffs_checkblk(struct inode *, ufs2_daddr_t, long); 104#endif |
105static ufs2_daddr_t ffs_clusteralloc(struct inode *, int, ufs2_daddr_t, int); | 105static ufs2_daddr_t ffs_clusteralloc(struct inode *, u_int, ufs2_daddr_t, int); |
106static void ffs_clusteracct(struct ufsmount *, struct fs *, struct cg *, 107 ufs1_daddr_t, int); 108static ino_t ffs_dirpref(struct inode *); | 106static void ffs_clusteracct(struct ufsmount *, struct fs *, struct cg *, 107 ufs1_daddr_t, int); 108static ino_t ffs_dirpref(struct inode *); |
109static ufs2_daddr_t ffs_fragextend(struct inode *, int, ufs2_daddr_t, int, int); | 109static ufs2_daddr_t ffs_fragextend(struct inode *, u_int, ufs2_daddr_t, 110 int, int); |
110static void ffs_fserr(struct fs *, ino_t, char *); 111static ufs2_daddr_t ffs_hashalloc | 111static void ffs_fserr(struct fs *, ino_t, char *); 112static ufs2_daddr_t ffs_hashalloc |
112 (struct inode *, int, ufs2_daddr_t, int, allocfcn_t *); 113static ufs2_daddr_t ffs_nodealloccg(struct inode *, int, ufs2_daddr_t, int); | 113 (struct inode *, u_int, ufs2_daddr_t, int, allocfcn_t *); 114static ufs2_daddr_t ffs_nodealloccg(struct inode *, u_int, ufs2_daddr_t, int); |
114static ufs1_daddr_t ffs_mapsearch(struct fs *, struct cg *, ufs2_daddr_t, int); 115static int ffs_reallocblks_ufs1(struct vop_reallocblks_args *); 116static int ffs_reallocblks_ufs2(struct vop_reallocblks_args *); 117 118/* 119 * Allocate a block in the filesystem. 120 * 121 * The size of the requested block is given, which must be some --- 18 unchanged lines hidden (view full) --- 140 ufs2_daddr_t lbn, bpref; 141 int size, flags; 142 struct ucred *cred; 143 ufs2_daddr_t *bnp; 144{ 145 struct fs *fs; 146 struct ufsmount *ump; 147 ufs2_daddr_t bno; | 115static ufs1_daddr_t ffs_mapsearch(struct fs *, struct cg *, ufs2_daddr_t, int); 116static int ffs_reallocblks_ufs1(struct vop_reallocblks_args *); 117static int ffs_reallocblks_ufs2(struct vop_reallocblks_args *); 118 119/* 120 * Allocate a block in the filesystem. 121 * 122 * The size of the requested block is given, which must be some --- 18 unchanged lines hidden (view full) --- 141 ufs2_daddr_t lbn, bpref; 142 int size, flags; 143 struct ucred *cred; 144 ufs2_daddr_t *bnp; 145{ 146 struct fs *fs; 147 struct ufsmount *ump; 148 ufs2_daddr_t bno; |
148 int cg, reclaimed; | 149 u_int cg, reclaimed; |
149 static struct timeval lastfail; 150 static int curfail; 151 int64_t delta; 152#ifdef QUOTA 153 int error; 154#endif 155 156 *bnp = 0; --- 86 unchanged lines hidden (view full) --- 243 int osize, nsize, flags; 244 struct ucred *cred; 245 struct buf **bpp; 246{ 247 struct vnode *vp; 248 struct fs *fs; 249 struct buf *bp; 250 struct ufsmount *ump; | 150 static struct timeval lastfail; 151 static int curfail; 152 int64_t delta; 153#ifdef QUOTA 154 int error; 155#endif 156 157 *bnp = 0; --- 86 unchanged lines hidden (view full) --- 244 int osize, nsize, flags; 245 struct ucred *cred; 246 struct buf **bpp; 247{ 248 struct vnode *vp; 249 struct fs *fs; 250 struct buf *bp; 251 struct ufsmount *ump; |
251 int cg, request, error, reclaimed; | 252 u_int cg, request, reclaimed; 253 int error; |
252 ufs2_daddr_t bno; 253 static struct timeval lastfail; 254 static int curfail; 255 int64_t delta; 256 257 *bpp = 0; 258 vp = ITOV(ip); 259 fs = ip->i_fs; --- 668 unchanged lines hidden (view full) --- 928 struct vnode **vpp; 929{ 930 struct inode *pip; 931 struct fs *fs; 932 struct inode *ip; 933 struct timespec ts; 934 struct ufsmount *ump; 935 ino_t ino, ipref; | 254 ufs2_daddr_t bno; 255 static struct timeval lastfail; 256 static int curfail; 257 int64_t delta; 258 259 *bpp = 0; 260 vp = ITOV(ip); 261 fs = ip->i_fs; --- 668 unchanged lines hidden (view full) --- 930 struct vnode **vpp; 931{ 932 struct inode *pip; 933 struct fs *fs; 934 struct inode *ip; 935 struct timespec ts; 936 struct ufsmount *ump; 937 ino_t ino, ipref; |
936 int cg, error, error1; | 938 u_int cg; 939 int error, error1; |
937 static struct timeval lastfail; 938 static int curfail; 939 940 *vpp = NULL; 941 pip = VTOI(pvp); 942 fs = pip->i_fs; 943 ump = pip->i_ump; 944 --- 93 unchanged lines hidden (view full) --- 1038 * If we allocate a first level directory then force allocation 1039 * in another cylinder group. 1040 */ 1041static ino_t 1042ffs_dirpref(pip) 1043 struct inode *pip; 1044{ 1045 struct fs *fs; | 940 static struct timeval lastfail; 941 static int curfail; 942 943 *vpp = NULL; 944 pip = VTOI(pvp); 945 fs = pip->i_fs; 946 ump = pip->i_ump; 947 --- 93 unchanged lines hidden (view full) --- 1041 * If we allocate a first level directory then force allocation 1042 * in another cylinder group. 1043 */ 1044static ino_t 1045ffs_dirpref(pip) 1046 struct inode *pip; 1047{ 1048 struct fs *fs; |
1046 int cg, prefcg, dirsize, cgsize; 1047 int avgifree, avgbfree, avgndir, curdirsize; 1048 int minifree, minbfree, maxndir; 1049 int mincg, minndir; 1050 int maxcontigdirs; | 1049 u_int cg, prefcg, dirsize, cgsize; 1050 u_int avgifree, avgbfree, avgndir, curdirsize; 1051 u_int minifree, minbfree, maxndir; 1052 u_int mincg, minndir; 1053 u_int maxcontigdirs; |
1051 1052 mtx_assert(UFS_MTX(pip->i_ump), MA_OWNED); 1053 fs = pip->i_fs; 1054 1055 avgifree = fs->fs_cstotal.cs_nifree / fs->fs_ncg; 1056 avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; 1057 avgndir = fs->fs_cstotal.cs_ndir / fs->fs_ncg; 1058 --- 107 unchanged lines hidden (view full) --- 1166ufs2_daddr_t 1167ffs_blkpref_ufs1(ip, lbn, indx, bap) 1168 struct inode *ip; 1169 ufs_lbn_t lbn; 1170 int indx; 1171 ufs1_daddr_t *bap; 1172{ 1173 struct fs *fs; | 1054 1055 mtx_assert(UFS_MTX(pip->i_ump), MA_OWNED); 1056 fs = pip->i_fs; 1057 1058 avgifree = fs->fs_cstotal.cs_nifree / fs->fs_ncg; 1059 avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; 1060 avgndir = fs->fs_cstotal.cs_ndir / fs->fs_ncg; 1061 --- 107 unchanged lines hidden (view full) --- 1169ufs2_daddr_t 1170ffs_blkpref_ufs1(ip, lbn, indx, bap) 1171 struct inode *ip; 1172 ufs_lbn_t lbn; 1173 int indx; 1174 ufs1_daddr_t *bap; 1175{ 1176 struct fs *fs; |
1174 int cg; 1175 int avgbfree, startcg; | 1177 u_int cg; 1178 u_int avgbfree, startcg; |
1176 1177 mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); 1178 fs = ip->i_fs; 1179 if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { 1180 if (lbn < NDADDR + NINDIR(fs)) { 1181 cg = ino_to_cg(fs, ip->i_number); 1182 return (cgbase(fs, cg) + fs->fs_frag); 1183 } --- 32 unchanged lines hidden (view full) --- 1216ufs2_daddr_t 1217ffs_blkpref_ufs2(ip, lbn, indx, bap) 1218 struct inode *ip; 1219 ufs_lbn_t lbn; 1220 int indx; 1221 ufs2_daddr_t *bap; 1222{ 1223 struct fs *fs; | 1179 1180 mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); 1181 fs = ip->i_fs; 1182 if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { 1183 if (lbn < NDADDR + NINDIR(fs)) { 1184 cg = ino_to_cg(fs, ip->i_number); 1185 return (cgbase(fs, cg) + fs->fs_frag); 1186 } --- 32 unchanged lines hidden (view full) --- 1219ufs2_daddr_t 1220ffs_blkpref_ufs2(ip, lbn, indx, bap) 1221 struct inode *ip; 1222 ufs_lbn_t lbn; 1223 int indx; 1224 ufs2_daddr_t *bap; 1225{ 1226 struct fs *fs; |
1224 int cg; 1225 int avgbfree, startcg; | 1227 u_int cg; 1228 u_int avgbfree, startcg; |
1226 1227 mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); 1228 fs = ip->i_fs; 1229 if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { 1230 if (lbn < NDADDR + NINDIR(fs)) { 1231 cg = ino_to_cg(fs, ip->i_number); 1232 return (cgbase(fs, cg) + fs->fs_frag); 1233 } --- 36 unchanged lines hidden (view full) --- 1270 * 1271 * Must be called with the UFS lock held. Will release the lock on success 1272 * and return with it held on failure. 1273 */ 1274/*VARARGS5*/ 1275static ufs2_daddr_t 1276ffs_hashalloc(ip, cg, pref, size, allocator) 1277 struct inode *ip; | 1229 1230 mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); 1231 fs = ip->i_fs; 1232 if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { 1233 if (lbn < NDADDR + NINDIR(fs)) { 1234 cg = ino_to_cg(fs, ip->i_number); 1235 return (cgbase(fs, cg) + fs->fs_frag); 1236 } --- 36 unchanged lines hidden (view full) --- 1273 * 1274 * Must be called with the UFS lock held. Will release the lock on success 1275 * and return with it held on failure. 1276 */ 1277/*VARARGS5*/ 1278static ufs2_daddr_t 1279ffs_hashalloc(ip, cg, pref, size, allocator) 1280 struct inode *ip; |
1278 int cg; | 1281 u_int cg; |
1279 ufs2_daddr_t pref; 1280 int size; /* size for data blocks, mode for inodes */ 1281 allocfcn_t *allocator; 1282{ 1283 struct fs *fs; 1284 ufs2_daddr_t result; | 1282 ufs2_daddr_t pref; 1283 int size; /* size for data blocks, mode for inodes */ 1284 allocfcn_t *allocator; 1285{ 1286 struct fs *fs; 1287 ufs2_daddr_t result; |
1285 int i, icg = cg; | 1288 u_int i, icg = cg; |
1286 1287 mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); 1288#ifdef INVARIANTS 1289 if (ITOV(ip)->v_mount->mnt_kern_flag & MNTK_SUSPENDED) 1290 panic("ffs_hashalloc: allocation on suspended filesystem"); 1291#endif 1292 fs = ip->i_fs; 1293 /* --- 34 unchanged lines hidden (view full) --- 1328 * Determine whether a fragment can be extended. 1329 * 1330 * Check to see if the necessary fragments are available, and 1331 * if they are, allocate them. 1332 */ 1333static ufs2_daddr_t 1334ffs_fragextend(ip, cg, bprev, osize, nsize) 1335 struct inode *ip; | 1289 1290 mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); 1291#ifdef INVARIANTS 1292 if (ITOV(ip)->v_mount->mnt_kern_flag & MNTK_SUSPENDED) 1293 panic("ffs_hashalloc: allocation on suspended filesystem"); 1294#endif 1295 fs = ip->i_fs; 1296 /* --- 34 unchanged lines hidden (view full) --- 1331 * Determine whether a fragment can be extended. 1332 * 1333 * Check to see if the necessary fragments are available, and 1334 * if they are, allocate them. 1335 */ 1336static ufs2_daddr_t 1337ffs_fragextend(ip, cg, bprev, osize, nsize) 1338 struct inode *ip; |
1336 int cg; | 1339 u_int cg; |
1337 ufs2_daddr_t bprev; 1338 int osize, nsize; 1339{ 1340 struct fs *fs; 1341 struct cg *cgp; 1342 struct buf *bp; 1343 struct ufsmount *ump; 1344 int nffree; --- 66 unchanged lines hidden (view full) --- 1411 * Determine whether a block can be allocated. 1412 * 1413 * Check to see if a block of the appropriate size is available, 1414 * and if it is, allocate it. 1415 */ 1416static ufs2_daddr_t 1417ffs_alloccg(ip, cg, bpref, size) 1418 struct inode *ip; | 1340 ufs2_daddr_t bprev; 1341 int osize, nsize; 1342{ 1343 struct fs *fs; 1344 struct cg *cgp; 1345 struct buf *bp; 1346 struct ufsmount *ump; 1347 int nffree; --- 66 unchanged lines hidden (view full) --- 1414 * Determine whether a block can be allocated. 1415 * 1416 * Check to see if a block of the appropriate size is available, 1417 * and if it is, allocate it. 1418 */ 1419static ufs2_daddr_t 1420ffs_alloccg(ip, cg, bpref, size) 1421 struct inode *ip; |
1419 int cg; | 1422 u_int cg; |
1420 ufs2_daddr_t bpref; 1421 int size; 1422{ 1423 struct fs *fs; 1424 struct cg *cgp; 1425 struct buf *bp; 1426 struct ufsmount *ump; 1427 ufs1_daddr_t bno; --- 153 unchanged lines hidden (view full) --- 1581 * 1582 * We do not currently check for optimal rotational layout if there 1583 * are multiple choices in the same cylinder group. Instead we just 1584 * take the first one that we find following bpref. 1585 */ 1586static ufs2_daddr_t 1587ffs_clusteralloc(ip, cg, bpref, len) 1588 struct inode *ip; | 1423 ufs2_daddr_t bpref; 1424 int size; 1425{ 1426 struct fs *fs; 1427 struct cg *cgp; 1428 struct buf *bp; 1429 struct ufsmount *ump; 1430 ufs1_daddr_t bno; --- 153 unchanged lines hidden (view full) --- 1584 * 1585 * We do not currently check for optimal rotational layout if there 1586 * are multiple choices in the same cylinder group. Instead we just 1587 * take the first one that we find following bpref. 1588 */ 1589static ufs2_daddr_t 1590ffs_clusteralloc(ip, cg, bpref, len) 1591 struct inode *ip; |
1589 int cg; | 1592 u_int cg; |
1590 ufs2_daddr_t bpref; 1591 int len; 1592{ 1593 struct fs *fs; 1594 struct cg *cgp; 1595 struct buf *bp; 1596 struct ufsmount *ump; 1597 int i, run, bit, map, got; --- 107 unchanged lines hidden (view full) --- 1705 * allocate it using the following policy: 1706 * 1) allocate the requested inode. 1707 * 2) allocate the next available inode after the requested 1708 * inode in the specified cylinder group. 1709 */ 1710static ufs2_daddr_t 1711ffs_nodealloccg(ip, cg, ipref, mode) 1712 struct inode *ip; | 1593 ufs2_daddr_t bpref; 1594 int len; 1595{ 1596 struct fs *fs; 1597 struct cg *cgp; 1598 struct buf *bp; 1599 struct ufsmount *ump; 1600 int i, run, bit, map, got; --- 107 unchanged lines hidden (view full) --- 1708 * allocate it using the following policy: 1709 * 1) allocate the requested inode. 1710 * 2) allocate the next available inode after the requested 1711 * inode in the specified cylinder group. 1712 */ 1713static ufs2_daddr_t 1714ffs_nodealloccg(ip, cg, ipref, mode) 1715 struct inode *ip; |
1713 int cg; | 1716 u_int cg; |
1714 ufs2_daddr_t ipref; 1715 int mode; 1716{ 1717 struct fs *fs; 1718 struct cg *cgp; 1719 struct buf *bp, *ibp; 1720 struct ufsmount *ump; 1721 u_int8_t *inosused; --- 84 unchanged lines hidden (view full) --- 1806 fs->fs_cs(fs, cg).cs_ndir++; 1807 } 1808 UFS_UNLOCK(ump); 1809 if (DOINGSOFTDEP(ITOV(ip))) 1810 softdep_setup_inomapdep(bp, ip, cg * fs->fs_ipg + ipref); 1811 bdwrite(bp); 1812 if (ibp != NULL) 1813 bawrite(ibp); | 1717 ufs2_daddr_t ipref; 1718 int mode; 1719{ 1720 struct fs *fs; 1721 struct cg *cgp; 1722 struct buf *bp, *ibp; 1723 struct ufsmount *ump; 1724 u_int8_t *inosused; --- 84 unchanged lines hidden (view full) --- 1809 fs->fs_cs(fs, cg).cs_ndir++; 1810 } 1811 UFS_UNLOCK(ump); 1812 if (DOINGSOFTDEP(ITOV(ip))) 1813 softdep_setup_inomapdep(bp, ip, cg * fs->fs_ipg + ipref); 1814 bdwrite(bp); 1815 if (ibp != NULL) 1816 bawrite(ibp); |
1814 return (cg * fs->fs_ipg + ipref); | 1817 return ((ino_t)(cg * fs->fs_ipg + ipref)); |
1815} 1816 1817/* 1818 * check if a block is free 1819 */ 1820static int 1821ffs_isfreeblock(struct fs *fs, u_char *cp, ufs1_daddr_t h) 1822{ --- 28 unchanged lines hidden (view full) --- 1851 ufs2_daddr_t bno; 1852 long size; 1853 ino_t inum; 1854{ 1855 struct cg *cgp; 1856 struct buf *bp; 1857 ufs1_daddr_t fragno, cgbno; 1858 ufs2_daddr_t cgblkno; | 1818} 1819 1820/* 1821 * check if a block is free 1822 */ 1823static int 1824ffs_isfreeblock(struct fs *fs, u_char *cp, ufs1_daddr_t h) 1825{ --- 28 unchanged lines hidden (view full) --- 1854 ufs2_daddr_t bno; 1855 long size; 1856 ino_t inum; 1857{ 1858 struct cg *cgp; 1859 struct buf *bp; 1860 ufs1_daddr_t fragno, cgbno; 1861 ufs2_daddr_t cgblkno; |
1859 int i, cg, blk, frags, bbase; | 1862 int i, blk, frags, bbase; 1863 u_int cg; |
1860 u_int8_t *blksfree; 1861 struct cdev *dev; 1862 1863 cg = dtog(fs, bno); 1864 if (devvp->v_type == VREG) { 1865 /* devvp is a snapshot */ 1866 dev = VTOI(devvp)->i_devvp->v_rdev; 1867 cgblkno = fragstoblks(fs, cgtod(fs, cg)); --- 181 unchanged lines hidden (view full) --- 2049 struct fs *fs; 2050 struct vnode *devvp; 2051 ino_t ino; 2052 int mode; 2053{ 2054 struct cg *cgp; 2055 struct buf *bp; 2056 ufs2_daddr_t cgbno; | 1864 u_int8_t *blksfree; 1865 struct cdev *dev; 1866 1867 cg = dtog(fs, bno); 1868 if (devvp->v_type == VREG) { 1869 /* devvp is a snapshot */ 1870 dev = VTOI(devvp)->i_devvp->v_rdev; 1871 cgblkno = fragstoblks(fs, cgtod(fs, cg)); --- 181 unchanged lines hidden (view full) --- 2053 struct fs *fs; 2054 struct vnode *devvp; 2055 ino_t ino; 2056 int mode; 2057{ 2058 struct cg *cgp; 2059 struct buf *bp; 2060 ufs2_daddr_t cgbno; |
2057 int error, cg; | 2061 int error; 2062 u_int cg; |
2058 u_int8_t *inosused; 2059 struct cdev *dev; 2060 2061 cg = ino_to_cg(fs, ino); 2062 if (devvp->v_type == VREG) { 2063 /* devvp is a snapshot */ 2064 dev = VTOI(devvp)->i_devvp->v_rdev; 2065 cgbno = fragstoblks(fs, cgtod(fs, cg)); 2066 } else { 2067 /* devvp is a normal disk device */ 2068 dev = devvp->v_rdev; 2069 cgbno = fsbtodb(fs, cgtod(fs, cg)); 2070 } | 2063 u_int8_t *inosused; 2064 struct cdev *dev; 2065 2066 cg = ino_to_cg(fs, ino); 2067 if (devvp->v_type == VREG) { 2068 /* devvp is a snapshot */ 2069 dev = VTOI(devvp)->i_devvp->v_rdev; 2070 cgbno = fragstoblks(fs, cgtod(fs, cg)); 2071 } else { 2072 /* devvp is a normal disk device */ 2073 dev = devvp->v_rdev; 2074 cgbno = fsbtodb(fs, cgtod(fs, cg)); 2075 } |
2071 if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg) | 2076 if (ino >= fs->fs_ipg * fs->fs_ncg) |
2072 panic("ffs_freefile: range: dev = %s, ino = %lu, fs = %s", 2073 devtoname(dev), (u_long)ino, fs->fs_fsmnt); 2074 if ((error = bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp))) { 2075 brelse(bp); 2076 return (error); 2077 } 2078 cgp = (struct cg *)bp->b_data; 2079 if (!cg_chkmagic(cgp)) { 2080 brelse(bp); 2081 return (0); 2082 } 2083 bp->b_xflags |= BX_BKGRDWRITE; 2084 cgp->cg_old_time = cgp->cg_time = time_second; 2085 inosused = cg_inosused(cgp); 2086 ino %= fs->fs_ipg; 2087 if (isclr(inosused, ino)) { | 2077 panic("ffs_freefile: range: dev = %s, ino = %lu, fs = %s", 2078 devtoname(dev), (u_long)ino, fs->fs_fsmnt); 2079 if ((error = bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp))) { 2080 brelse(bp); 2081 return (error); 2082 } 2083 cgp = (struct cg *)bp->b_data; 2084 if (!cg_chkmagic(cgp)) { 2085 brelse(bp); 2086 return (0); 2087 } 2088 bp->b_xflags |= BX_BKGRDWRITE; 2089 cgp->cg_old_time = cgp->cg_time = time_second; 2090 inosused = cg_inosused(cgp); 2091 ino %= fs->fs_ipg; 2092 if (isclr(inosused, ino)) { |
2088 printf("dev = %s, ino = %lu, fs = %s\n", devtoname(dev), 2089 (u_long)ino + cg * fs->fs_ipg, fs->fs_fsmnt); | 2093 printf("dev = %s, ino = %u, fs = %s\n", devtoname(dev), 2094 ino + cg * fs->fs_ipg, fs->fs_fsmnt); |
2090 if (fs->fs_ronly == 0) 2091 panic("ffs_freefile: freeing free inode"); 2092 } 2093 clrbit(inosused, ino); 2094 if (ino < cgp->cg_irotor) 2095 cgp->cg_irotor = ino; 2096 cgp->cg_cs.cs_nifree++; 2097 UFS_LOCK(ump); --- 18 unchanged lines hidden (view full) --- 2116ffs_checkfreefile(fs, devvp, ino) 2117 struct fs *fs; 2118 struct vnode *devvp; 2119 ino_t ino; 2120{ 2121 struct cg *cgp; 2122 struct buf *bp; 2123 ufs2_daddr_t cgbno; | 2095 if (fs->fs_ronly == 0) 2096 panic("ffs_freefile: freeing free inode"); 2097 } 2098 clrbit(inosused, ino); 2099 if (ino < cgp->cg_irotor) 2100 cgp->cg_irotor = ino; 2101 cgp->cg_cs.cs_nifree++; 2102 UFS_LOCK(ump); --- 18 unchanged lines hidden (view full) --- 2121ffs_checkfreefile(fs, devvp, ino) 2122 struct fs *fs; 2123 struct vnode *devvp; 2124 ino_t ino; 2125{ 2126 struct cg *cgp; 2127 struct buf *bp; 2128 ufs2_daddr_t cgbno; |
2124 int ret, cg; | 2129 int ret; 2130 u_int cg; |
2125 u_int8_t *inosused; 2126 2127 cg = ino_to_cg(fs, ino); 2128 if (devvp->v_type == VREG) { 2129 /* devvp is a snapshot */ 2130 cgbno = fragstoblks(fs, cgtod(fs, cg)); 2131 } else { 2132 /* devvp is a normal disk device */ 2133 cgbno = fsbtodb(fs, cgtod(fs, cg)); 2134 } | 2131 u_int8_t *inosused; 2132 2133 cg = ino_to_cg(fs, ino); 2134 if (devvp->v_type == VREG) { 2135 /* devvp is a snapshot */ 2136 cgbno = fragstoblks(fs, cgtod(fs, cg)); 2137 } else { 2138 /* devvp is a normal disk device */ 2139 cgbno = fsbtodb(fs, cgtod(fs, cg)); 2140 } |
2135 if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg) | 2141 if (ino >= fs->fs_ipg * fs->fs_ncg) |
2136 return (1); 2137 if (bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp)) { 2138 brelse(bp); 2139 return (1); 2140 } 2141 cgp = (struct cg *)bp->b_data; 2142 if (!cg_chkmagic(cgp)) { 2143 brelse(bp); --- 580 unchanged lines hidden --- | 2142 return (1); 2143 if (bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp)) { 2144 brelse(bp); 2145 return (1); 2146 } 2147 cgp = (struct cg *)bp->b_data; 2148 if (!cg_chkmagic(cgp)) { 2149 brelse(bp); --- 580 unchanged lines hidden --- |