ffs_alloc.c (47085) | ffs_alloc.c (50253) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95 |
34 * $Id: ffs_alloc.c,v 1.57 1999/05/06 18:13:11 peter Exp $ | 34 * $Id: ffs_alloc.c,v 1.58 1999/05/12 22:32:07 peter Exp $ |
35 */ 36 37#include "opt_quota.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/buf.h> | 35 */ 36 37#include "opt_quota.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/buf.h> |
42#include <sys/conf.h> |
|
42#include <sys/proc.h> 43#include <sys/vnode.h> 44#include <sys/mount.h> 45#include <sys/kernel.h> 46#include <sys/sysctl.h> 47#include <sys/syslog.h> 48 49#include <ufs/ufs/quota.h> --- 59 unchanged lines hidden (view full) --- 109#ifdef QUOTA 110 int error; 111#endif 112 113 *bnp = 0; 114 fs = ip->i_fs; 115#ifdef DIAGNOSTIC 116 if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { | 43#include <sys/proc.h> 44#include <sys/vnode.h> 45#include <sys/mount.h> 46#include <sys/kernel.h> 47#include <sys/sysctl.h> 48#include <sys/syslog.h> 49 50#include <ufs/ufs/quota.h> --- 59 unchanged lines hidden (view full) --- 110#ifdef QUOTA 111 int error; 112#endif 113 114 *bnp = 0; 115 fs = ip->i_fs; 116#ifdef DIAGNOSTIC 117 if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { |
117 printf("dev = 0x%lx, bsize = %ld, size = %d, fs = %s\n", 118 (u_long)ip->i_dev, (long)fs->fs_bsize, size, fs->fs_fsmnt); | 118 printf("dev = %s, bsize = %ld, size = %d, fs = %s\n", 119 devtoname(ip->i_dev), (long)fs->fs_bsize, size, 120 fs->fs_fsmnt); |
119 panic("ffs_alloc: bad size"); 120 } 121 if (cred == NOCRED) 122 panic("ffs_alloc: missing credential"); 123#endif /* DIAGNOSTIC */ 124 if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) 125 goto nospace; 126 if (cred->cr_uid != 0 && --- 53 unchanged lines hidden (view full) --- 180 ufs_daddr_t bprev, bno; 181 182 *bpp = 0; 183 fs = ip->i_fs; 184#ifdef DIAGNOSTIC 185 if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || 186 (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { 187 printf( | 121 panic("ffs_alloc: bad size"); 122 } 123 if (cred == NOCRED) 124 panic("ffs_alloc: missing credential"); 125#endif /* DIAGNOSTIC */ 126 if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) 127 goto nospace; 128 if (cred->cr_uid != 0 && --- 53 unchanged lines hidden (view full) --- 182 ufs_daddr_t bprev, bno; 183 184 *bpp = 0; 185 fs = ip->i_fs; 186#ifdef DIAGNOSTIC 187 if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || 188 (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { 189 printf( |
188 "dev = 0x%lx, bsize = %ld, osize = %d, nsize = %d, fs = %s\n", 189 (u_long)ip->i_dev, (long)fs->fs_bsize, osize, | 190 "dev = %s, bsize = %ld, osize = %d, nsize = %d, fs = %s\n", 191 devtoname(ip->i_dev), (long)fs->fs_bsize, osize, |
190 nsize, fs->fs_fsmnt); 191 panic("ffs_realloccg: bad size"); 192 } 193 if (cred == NOCRED) 194 panic("ffs_realloccg: missing credential"); 195#endif /* DIAGNOSTIC */ 196 if (cred->cr_uid != 0 && 197 freespace(fs, fs->fs_minfree) - numfrags(fs, nsize - osize) < 0) 198 goto nospace; 199 if ((bprev = ip->i_db[lbprev]) == 0) { | 192 nsize, fs->fs_fsmnt); 193 panic("ffs_realloccg: bad size"); 194 } 195 if (cred == NOCRED) 196 panic("ffs_realloccg: missing credential"); 197#endif /* DIAGNOSTIC */ 198 if (cred->cr_uid != 0 && 199 freespace(fs, fs->fs_minfree) - numfrags(fs, nsize - osize) < 0) 200 goto nospace; 201 if ((bprev = ip->i_db[lbprev]) == 0) { |
200 printf("dev = 0x%lx, bsize = %ld, bprev = %ld, fs = %s\n", 201 (u_long)ip->i_dev, (long)fs->fs_bsize, (long)bprev, | 202 printf("dev = %s, bsize = %ld, bprev = %ld, fs = %s\n", 203 devtoname(ip->i_dev), (long)fs->fs_bsize, (long)bprev, |
202 fs->fs_fsmnt); 203 panic("ffs_realloccg: bad bprev"); 204 } 205 /* 206 * Allocate the extra space in the buffer. 207 */ 208 error = bread(ITOV(ip), lbprev, osize, NOCRED, &bp); 209 if (error) { --- 68 unchanged lines hidden (view full) --- 278 if (fs->fs_cstotal.cs_nffree < 279 fs->fs_dsize * (fs->fs_minfree - 2) / 100) 280 break; 281 log(LOG_NOTICE, "%s: optimization changed from TIME to SPACE\n", 282 fs->fs_fsmnt); 283 fs->fs_optim = FS_OPTSPACE; 284 break; 285 default: | 204 fs->fs_fsmnt); 205 panic("ffs_realloccg: bad bprev"); 206 } 207 /* 208 * Allocate the extra space in the buffer. 209 */ 210 error = bread(ITOV(ip), lbprev, osize, NOCRED, &bp); 211 if (error) { --- 68 unchanged lines hidden (view full) --- 280 if (fs->fs_cstotal.cs_nffree < 281 fs->fs_dsize * (fs->fs_minfree - 2) / 100) 282 break; 283 log(LOG_NOTICE, "%s: optimization changed from TIME to SPACE\n", 284 fs->fs_fsmnt); 285 fs->fs_optim = FS_OPTSPACE; 286 break; 287 default: |
286 printf("dev = 0x%lx, optim = %ld, fs = %s\n", 287 (u_long)ip->i_dev, (long)fs->fs_optim, fs->fs_fsmnt); | 288 printf("dev = %s, optim = %ld, fs = %s\n", 289 devtoname(ip->i_dev), (long)fs->fs_optim, fs->fs_fsmnt); |
288 panic("ffs_realloccg: bad optim"); 289 /* NOTREACHED */ 290 } 291 bno = (ufs_daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request, 292 ffs_alloccg); 293 if (bno > 0) { 294 bp->b_blkno = fsbtodb(fs, bno); 295 if (!DOINGSOFTDEP(ITOV(ip))) --- 994 unchanged lines hidden (view full) --- 1290 struct buf *bp; 1291 ufs_daddr_t blkno; 1292 int i, error, cg, blk, frags, bbase; 1293 1294 fs = ip->i_fs; 1295 VOP_FREEBLKS(ip->i_devvp, fsbtodb(fs, bno), size); 1296 if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0 || 1297 fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) { | 290 panic("ffs_realloccg: bad optim"); 291 /* NOTREACHED */ 292 } 293 bno = (ufs_daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request, 294 ffs_alloccg); 295 if (bno > 0) { 296 bp->b_blkno = fsbtodb(fs, bno); 297 if (!DOINGSOFTDEP(ITOV(ip))) --- 994 unchanged lines hidden (view full) --- 1292 struct buf *bp; 1293 ufs_daddr_t blkno; 1294 int i, error, cg, blk, frags, bbase; 1295 1296 fs = ip->i_fs; 1297 VOP_FREEBLKS(ip->i_devvp, fsbtodb(fs, bno), size); 1298 if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0 || 1299 fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) { |
1298 printf("dev=0x%lx, bno = %d, bsize = %d, size = %ld, fs = %s\n", 1299 (u_long)ip->i_dev, bno, fs->fs_bsize, size, fs->fs_fsmnt); | 1300 printf("dev=%s, bno = %ld, bsize = %ld, size = %ld, fs = %s\n", 1301 devtoname(ip->i_dev), (long)bno, (long)fs->fs_bsize, size, 1302 fs->fs_fsmnt); |
1300 panic("ffs_blkfree: bad size"); 1301 } 1302 cg = dtog(fs, bno); 1303 if ((u_int)bno >= fs->fs_size) { 1304 printf("bad block %ld, ino %lu\n", 1305 (long)bno, (u_long)ip->i_number); 1306 ffs_fserr(fs, ip->i_uid, "bad block"); 1307 return; --- 9 unchanged lines hidden (view full) --- 1317 brelse(bp); 1318 return; 1319 } 1320 cgp->cg_time = time_second; 1321 bno = dtogd(fs, bno); 1322 if (size == fs->fs_bsize) { 1323 blkno = fragstoblks(fs, bno); 1324 if (!ffs_isfreeblock(fs, cg_blksfree(cgp), blkno)) { | 1303 panic("ffs_blkfree: bad size"); 1304 } 1305 cg = dtog(fs, bno); 1306 if ((u_int)bno >= fs->fs_size) { 1307 printf("bad block %ld, ino %lu\n", 1308 (long)bno, (u_long)ip->i_number); 1309 ffs_fserr(fs, ip->i_uid, "bad block"); 1310 return; --- 9 unchanged lines hidden (view full) --- 1320 brelse(bp); 1321 return; 1322 } 1323 cgp->cg_time = time_second; 1324 bno = dtogd(fs, bno); 1325 if (size == fs->fs_bsize) { 1326 blkno = fragstoblks(fs, bno); 1327 if (!ffs_isfreeblock(fs, cg_blksfree(cgp), blkno)) { |
1325 printf("dev = 0x%lx, block = %ld, fs = %s\n", 1326 (u_long)ip->i_dev, (long)bno, fs->fs_fsmnt); | 1328 printf("dev = %s, block = %ld, fs = %s\n", 1329 devtoname(ip->i_dev), (long)bno, fs->fs_fsmnt); |
1327 panic("ffs_blkfree: freeing free block"); 1328 } 1329 ffs_setblock(fs, cg_blksfree(cgp), blkno); 1330 ffs_clusteracct(fs, cgp, blkno, 1); 1331 cgp->cg_cs.cs_nbfree++; 1332 fs->fs_cstotal.cs_nbfree++; 1333 fs->fs_cs(fs, cg).cs_nbfree++; 1334 i = cbtocylno(fs, bno); --- 7 unchanged lines hidden (view full) --- 1342 blk = blkmap(fs, cg_blksfree(cgp), bbase); 1343 ffs_fragacct(fs, blk, cgp->cg_frsum, -1); 1344 /* 1345 * deallocate the fragment 1346 */ 1347 frags = numfrags(fs, size); 1348 for (i = 0; i < frags; i++) { 1349 if (isset(cg_blksfree(cgp), bno + i)) { | 1330 panic("ffs_blkfree: freeing free block"); 1331 } 1332 ffs_setblock(fs, cg_blksfree(cgp), blkno); 1333 ffs_clusteracct(fs, cgp, blkno, 1); 1334 cgp->cg_cs.cs_nbfree++; 1335 fs->fs_cstotal.cs_nbfree++; 1336 fs->fs_cs(fs, cg).cs_nbfree++; 1337 i = cbtocylno(fs, bno); --- 7 unchanged lines hidden (view full) --- 1345 blk = blkmap(fs, cg_blksfree(cgp), bbase); 1346 ffs_fragacct(fs, blk, cgp->cg_frsum, -1); 1347 /* 1348 * deallocate the fragment 1349 */ 1350 frags = numfrags(fs, size); 1351 for (i = 0; i < frags; i++) { 1352 if (isset(cg_blksfree(cgp), bno + i)) { |
1350 printf("dev = 0x%lx, block = %ld, fs = %s\n", 1351 (u_long)ip->i_dev, (long)(bno + i), | 1353 printf("dev = %s, block = %ld, fs = %s\n", 1354 devtoname(ip->i_dev), (long)(bno + i), |
1352 fs->fs_fsmnt); 1353 panic("ffs_blkfree: freeing free frag"); 1354 } 1355 setbit(cg_blksfree(cgp), bno + i); 1356 } 1357 cgp->cg_cs.cs_nffree += i; 1358 fs->fs_cstotal.cs_nffree += i; 1359 fs->fs_cs(fs, cg).cs_nffree += i; --- 117 unchanged lines hidden (view full) --- 1477 cgp = (struct cg *)bp->b_data; 1478 if (!cg_chkmagic(cgp)) { 1479 brelse(bp); 1480 return (0); 1481 } 1482 cgp->cg_time = time_second; 1483 ino %= fs->fs_ipg; 1484 if (isclr(cg_inosused(cgp), ino)) { | 1355 fs->fs_fsmnt); 1356 panic("ffs_blkfree: freeing free frag"); 1357 } 1358 setbit(cg_blksfree(cgp), bno + i); 1359 } 1360 cgp->cg_cs.cs_nffree += i; 1361 fs->fs_cstotal.cs_nffree += i; 1362 fs->fs_cs(fs, cg).cs_nffree += i; --- 117 unchanged lines hidden (view full) --- 1480 cgp = (struct cg *)bp->b_data; 1481 if (!cg_chkmagic(cgp)) { 1482 brelse(bp); 1483 return (0); 1484 } 1485 cgp->cg_time = time_second; 1486 ino %= fs->fs_ipg; 1487 if (isclr(cg_inosused(cgp), ino)) { |
1485 printf("dev = 0x%lx, ino = %lu, fs = %s\n", 1486 (u_long)pip->i_dev, (u_long)ino, fs->fs_fsmnt); | 1488 printf("dev = %s, ino = %lu, fs = %s\n", 1489 devtoname(pip->i_dev), (u_long)ino, fs->fs_fsmnt); |
1487 if (fs->fs_ronly == 0) 1488 panic("ffs_vfree: freeing free inode"); 1489 } 1490 clrbit(cg_inosused(cgp), ino); 1491 if (ino < cgp->cg_irotor) 1492 cgp->cg_irotor = ino; 1493 cgp->cg_cs.cs_nifree++; 1494 fs->fs_cstotal.cs_nifree++; --- 185 unchanged lines hidden --- | 1490 if (fs->fs_ronly == 0) 1491 panic("ffs_vfree: freeing free inode"); 1492 } 1493 clrbit(cg_inosused(cgp), ino); 1494 if (ino < cgp->cg_irotor) 1495 cgp->cg_irotor = ino; 1496 cgp->cg_cs.cs_nifree++; 1497 fs->fs_cstotal.cs_nifree++; --- 185 unchanged lines hidden --- |