Deleted Added
full compact
ffs_alloc.c (92462) ffs_alloc.c (92728)
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 * $FreeBSD: head/sys/ufs/ffs/ffs_alloc.c 92462 2002-03-17 01:25:47Z mckusick $
34 * $FreeBSD: head/sys/ufs/ffs/ffs_alloc.c 92728 2002-03-19 22:40:48Z alfred $
35 */
36
37#include "opt_quota.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/bio.h>
42#include <sys/buf.h>

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

53#include <ufs/ufs/quota.h>
54#include <ufs/ufs/inode.h>
55#include <ufs/ufs/ufs_extern.h>
56#include <ufs/ufs/ufsmount.h>
57
58#include <ufs/ffs/fs.h>
59#include <ufs/ffs/ffs_extern.h>
60
35 */
36
37#include "opt_quota.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/bio.h>
42#include <sys/buf.h>

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

53#include <ufs/ufs/quota.h>
54#include <ufs/ufs/inode.h>
55#include <ufs/ufs/ufs_extern.h>
56#include <ufs/ufs/ufsmount.h>
57
58#include <ufs/ffs/fs.h>
59#include <ufs/ffs/ffs_extern.h>
60
61typedef ufs_daddr_t allocfcn_t __P((struct inode *ip, int cg, ufs_daddr_t bpref,
62 int size));
61typedef ufs_daddr_t allocfcn_t(struct inode *ip, int cg, ufs_daddr_t bpref,
62 int size);
63
63
64static ufs_daddr_t ffs_alloccg __P((struct inode *, int, ufs_daddr_t, int));
64static ufs_daddr_t ffs_alloccg(struct inode *, int, ufs_daddr_t, int);
65static ufs_daddr_t
65static ufs_daddr_t
66 ffs_alloccgblk __P((struct inode *, struct buf *, ufs_daddr_t));
66 ffs_alloccgblk(struct inode *, struct buf *, ufs_daddr_t);
67#ifdef DIAGNOSTIC
67#ifdef DIAGNOSTIC
68static int ffs_checkblk __P((struct inode *, ufs_daddr_t, long));
68static int ffs_checkblk(struct inode *, ufs_daddr_t, long);
69#endif
69#endif
70static ufs_daddr_t ffs_clusteralloc __P((struct inode *, int, ufs_daddr_t,
71 int));
72static ino_t ffs_dirpref __P((struct inode *));
73static ufs_daddr_t ffs_fragextend __P((struct inode *, int, long, int, int));
74static void ffs_fserr __P((struct fs *, ino_t, char *));
70static ufs_daddr_t ffs_clusteralloc(struct inode *, int, ufs_daddr_t, int);
71static ino_t ffs_dirpref(struct inode *);
72static ufs_daddr_t ffs_fragextend(struct inode *, int, long, int, int);
73static void ffs_fserr(struct fs *, ino_t, char *);
75static u_long ffs_hashalloc
74static u_long ffs_hashalloc
76 __P((struct inode *, int, long, int, allocfcn_t *));
77static ino_t ffs_nodealloccg __P((struct inode *, int, ufs_daddr_t, int));
78static ufs_daddr_t ffs_mapsearch __P((struct fs *, struct cg *, ufs_daddr_t,
79 int));
75 (struct inode *, int, long, int, allocfcn_t *);
76static ino_t ffs_nodealloccg(struct inode *, int, ufs_daddr_t, int);
77static ufs_daddr_t ffs_mapsearch(struct fs *, struct cg *, ufs_daddr_t, int);
80
81/*
82 * Allocate a block in the file system.
83 *
84 * The size of the requested block is given, which must be some
85 * multiple of fs_fsize and <= fs_bsize.
86 * A preference may be optionally specified. If a preference is given
87 * the following hierarchy is used to allocate a block:

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

1888 * as in use.
1889 * freeblks(blockno, size) - blocks [blockno..blockno + size - 1]
1890 * are marked as free. Blocks should never have to be marked
1891 * as in use.
1892 * setflags(flags, set/clear) - the fs_flags field has the specified
1893 * flags set (second parameter +1) or cleared (second parameter -1).
1894 */
1895
78
79/*
80 * Allocate a block in the file system.
81 *
82 * The size of the requested block is given, which must be some
83 * multiple of fs_fsize and <= fs_bsize.
84 * A preference may be optionally specified. If a preference is given
85 * the following hierarchy is used to allocate a block:

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

1886 * as in use.
1887 * freeblks(blockno, size) - blocks [blockno..blockno + size - 1]
1888 * are marked as free. Blocks should never have to be marked
1889 * as in use.
1890 * setflags(flags, set/clear) - the fs_flags field has the specified
1891 * flags set (second parameter +1) or cleared (second parameter -1).
1892 */
1893
1896static int sysctl_ffs_fsck __P((SYSCTL_HANDLER_ARGS));
1894static int sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS);
1897
1898SYSCTL_PROC(_vfs_ffs, FFS_ADJ_REFCNT, adjrefcnt, CTLFLAG_WR|CTLTYPE_STRUCT,
1899 0, 0, sysctl_ffs_fsck, "S,fsck", "Adjust Inode Reference Count");
1900
1901SYSCTL_NODE(_vfs_ffs, FFS_ADJ_BLKCNT, adjblkcnt, CTLFLAG_WR,
1902 sysctl_ffs_fsck, "Adjust Inode Used Blocks Count");
1903
1904SYSCTL_NODE(_vfs_ffs, FFS_DIR_FREE, freedirs, CTLFLAG_WR,

--- 174 unchanged lines hidden ---
1895
1896SYSCTL_PROC(_vfs_ffs, FFS_ADJ_REFCNT, adjrefcnt, CTLFLAG_WR|CTLTYPE_STRUCT,
1897 0, 0, sysctl_ffs_fsck, "S,fsck", "Adjust Inode Reference Count");
1898
1899SYSCTL_NODE(_vfs_ffs, FFS_ADJ_BLKCNT, adjblkcnt, CTLFLAG_WR,
1900 sysctl_ffs_fsck, "Adjust Inode Used Blocks Count");
1901
1902SYSCTL_NODE(_vfs_ffs, FFS_DIR_FREE, freedirs, CTLFLAG_WR,

--- 174 unchanged lines hidden ---