Deleted Added
full compact
ffs_balloc.c (187790) ffs_balloc.c (207141)
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_balloc.c 8.8 (Berkeley) 6/16/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_balloc.c 8.8 (Berkeley) 6/16/95
60 */
61
62#include <sys/cdefs.h>
63__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_balloc.c 187790 2009-01-27 21:48:47Z rwatson $");
63__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_balloc.c 207141 2010-04-24 07:05:35Z jeff $");
64
65#include <sys/param.h>
66#include <sys/systm.h>
67#include <sys/bio.h>
68#include <sys/buf.h>
69#include <sys/lock.h>
70#include <sys/mount.h>
71#include <sys/vnode.h>

--- 43 unchanged lines hidden (view full) ---

115 if (size > fs->fs_bsize)
116 panic("ffs_balloc_ufs1: blk too big");
117 *bpp = NULL;
118 if (flags & IO_EXT)
119 return (EOPNOTSUPP);
120 if (lbn < 0)
121 return (EFBIG);
122
64
65#include <sys/param.h>
66#include <sys/systm.h>
67#include <sys/bio.h>
68#include <sys/buf.h>
69#include <sys/lock.h>
70#include <sys/mount.h>
71#include <sys/vnode.h>

--- 43 unchanged lines hidden (view full) ---

115 if (size > fs->fs_bsize)
116 panic("ffs_balloc_ufs1: blk too big");
117 *bpp = NULL;
118 if (flags & IO_EXT)
119 return (EOPNOTSUPP);
120 if (lbn < 0)
121 return (EFBIG);
122
123 if (DOINGSOFTDEP(vp))
124 softdep_prealloc(vp, MNT_WAIT);
123 /*
124 * If the next write will extend the file into a new block,
125 * and the file is currently composed of a fragment
126 * this fragment has to be extended to be a full block.
127 */
128 lastlbn = lblkno(fs, ip->i_size);
129 if (lastlbn < NDADDR && lastlbn < lbn) {
130 nb = lastlbn;

--- 282 unchanged lines hidden (view full) ---

413 * have to deallocate any indirect blocks that we have allocated.
414 * We have to fsync the file before we start to get rid of all
415 * of its dependencies so that we do not leave them dangling.
416 * We have to sync it at the end so that the soft updates code
417 * does not find any untracked changes. Although this is really
418 * slow, running out of disk space is not expected to be a common
419 * occurence. The error return from fsync is ignored as we already
420 * have an error to return to the user.
125 /*
126 * If the next write will extend the file into a new block,
127 * and the file is currently composed of a fragment
128 * this fragment has to be extended to be a full block.
129 */
130 lastlbn = lblkno(fs, ip->i_size);
131 if (lastlbn < NDADDR && lastlbn < lbn) {
132 nb = lastlbn;

--- 282 unchanged lines hidden (view full) ---

415 * have to deallocate any indirect blocks that we have allocated.
416 * We have to fsync the file before we start to get rid of all
417 * of its dependencies so that we do not leave them dangling.
418 * We have to sync it at the end so that the soft updates code
419 * does not find any untracked changes. Although this is really
420 * slow, running out of disk space is not expected to be a common
421 * occurence. The error return from fsync is ignored as we already
422 * have an error to return to the user.
423 *
424 * XXX Still have to journal the free below
421 */
422 (void) ffs_syncvnode(vp, MNT_WAIT);
423 for (deallocated = 0, blkp = allociblk, lbns_remfree = lbns;
424 blkp < allocblk; blkp++, lbns_remfree++) {
425 /*
426 * We shall not leave the freed blocks on the vnode
427 * buffer object lists.
428 */

--- 39 unchanged lines hidden (view full) ---

468 }
469 (void) ffs_syncvnode(vp, MNT_WAIT);
470 /*
471 * After the buffers are invalidated and on-disk pointers are
472 * cleared, free the blocks.
473 */
474 for (blkp = allociblk; blkp < allocblk; blkp++) {
475 ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize,
425 */
426 (void) ffs_syncvnode(vp, MNT_WAIT);
427 for (deallocated = 0, blkp = allociblk, lbns_remfree = lbns;
428 blkp < allocblk; blkp++, lbns_remfree++) {
429 /*
430 * We shall not leave the freed blocks on the vnode
431 * buffer object lists.
432 */

--- 39 unchanged lines hidden (view full) ---

472 }
473 (void) ffs_syncvnode(vp, MNT_WAIT);
474 /*
475 * After the buffers are invalidated and on-disk pointers are
476 * cleared, free the blocks.
477 */
478 for (blkp = allociblk; blkp < allocblk; blkp++) {
479 ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize,
476 ip->i_number);
480 ip->i_number, NULL);
477 }
478 return (error);
479}
480
481/*
482 * Balloc defines the structure of file system storage
483 * by allocating the physical blocks on a device given
484 * the inode and the logical block number in a file.

--- 25 unchanged lines hidden (view full) ---

510 lbn = lblkno(fs, startoffset);
511 size = blkoff(fs, startoffset) + size;
512 if (size > fs->fs_bsize)
513 panic("ffs_balloc_ufs2: blk too big");
514 *bpp = NULL;
515 if (lbn < 0)
516 return (EFBIG);
517
481 }
482 return (error);
483}
484
485/*
486 * Balloc defines the structure of file system storage
487 * by allocating the physical blocks on a device given
488 * the inode and the logical block number in a file.

--- 25 unchanged lines hidden (view full) ---

514 lbn = lblkno(fs, startoffset);
515 size = blkoff(fs, startoffset) + size;
516 if (size > fs->fs_bsize)
517 panic("ffs_balloc_ufs2: blk too big");
518 *bpp = NULL;
519 if (lbn < 0)
520 return (EFBIG);
521
522 if (DOINGSOFTDEP(vp))
523 softdep_prealloc(vp, MNT_WAIT);
524
518 /*
519 * Check for allocating external data.
520 */
521 if (flags & IO_EXT) {
522 if (lbn >= NXADDR)
523 return (EFBIG);
524 /*
525 * If the next write will extend the data into a new block,

--- 399 unchanged lines hidden (view full) ---

925 * have to deallocate any indirect blocks that we have allocated.
926 * We have to fsync the file before we start to get rid of all
927 * of its dependencies so that we do not leave them dangling.
928 * We have to sync it at the end so that the soft updates code
929 * does not find any untracked changes. Although this is really
930 * slow, running out of disk space is not expected to be a common
931 * occurence. The error return from fsync is ignored as we already
932 * have an error to return to the user.
525 /*
526 * Check for allocating external data.
527 */
528 if (flags & IO_EXT) {
529 if (lbn >= NXADDR)
530 return (EFBIG);
531 /*
532 * If the next write will extend the data into a new block,

--- 399 unchanged lines hidden (view full) ---

932 * have to deallocate any indirect blocks that we have allocated.
933 * We have to fsync the file before we start to get rid of all
934 * of its dependencies so that we do not leave them dangling.
935 * We have to sync it at the end so that the soft updates code
936 * does not find any untracked changes. Although this is really
937 * slow, running out of disk space is not expected to be a common
938 * occurence. The error return from fsync is ignored as we already
939 * have an error to return to the user.
940 *
941 * XXX Still have to journal the free below
933 */
934 (void) ffs_syncvnode(vp, MNT_WAIT);
935 for (deallocated = 0, blkp = allociblk, lbns_remfree = lbns;
936 blkp < allocblk; blkp++, lbns_remfree++) {
937 /*
938 * We shall not leave the freed blocks on the vnode
939 * buffer object lists.
940 */

--- 39 unchanged lines hidden (view full) ---

980 }
981 (void) ffs_syncvnode(vp, MNT_WAIT);
982 /*
983 * After the buffers are invalidated and on-disk pointers are
984 * cleared, free the blocks.
985 */
986 for (blkp = allociblk; blkp < allocblk; blkp++) {
987 ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize,
942 */
943 (void) ffs_syncvnode(vp, MNT_WAIT);
944 for (deallocated = 0, blkp = allociblk, lbns_remfree = lbns;
945 blkp < allocblk; blkp++, lbns_remfree++) {
946 /*
947 * We shall not leave the freed blocks on the vnode
948 * buffer object lists.
949 */

--- 39 unchanged lines hidden (view full) ---

989 }
990 (void) ffs_syncvnode(vp, MNT_WAIT);
991 /*
992 * After the buffers are invalidated and on-disk pointers are
993 * cleared, free the blocks.
994 */
995 for (blkp = allociblk; blkp < allocblk; blkp++) {
996 ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize,
988 ip->i_number);
997 ip->i_number, NULL);
989 }
990 return (error);
991}
998 }
999 return (error);
1000}