Deleted Added
full compact
ext2_alloc.c (249218) ext2_alloc.c (251612)
1/*-
2 * modified for Lites 1.1
3 *
4 * Aug 1995, Godmar Back (gback@cs.utah.edu)
5 * University of Utah, Department of Computer Science
6 */
7/*-
8 * Copyright (c) 1982, 1986, 1989, 1993

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

28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)ffs_alloc.c 8.8 (Berkeley) 2/21/94
1/*-
2 * modified for Lites 1.1
3 *
4 * Aug 1995, Godmar Back (gback@cs.utah.edu)
5 * University of Utah, Department of Computer Science
6 */
7/*-
8 * Copyright (c) 1982, 1986, 1989, 1993

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

28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)ffs_alloc.c 8.8 (Berkeley) 2/21/94
36 * $FreeBSD: head/sys/fs/ext2fs/ext2_alloc.c 249218 2013-04-06 22:21:23Z jeff $
36 * $FreeBSD: head/sys/fs/ext2fs/ext2_alloc.c 251612 2013-06-11 02:47:07Z pfg $
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/conf.h>
42#include <sys/vnode.h>
43#include <sys/stat.h>
44#include <sys/mount.h>

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

58static void ext2_fserr(struct m_ext2fs *, uid_t, char *);
59static u_long ext2_hashalloc(struct inode *, int, long, int,
60 daddr_t (*)(struct inode *, int, daddr_t,
61 int));
62static daddr_t ext2_nodealloccg(struct inode *, int, daddr_t, int);
63static daddr_t ext2_mapsearch(struct m_ext2fs *, char *, daddr_t);
64
65/*
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/conf.h>
42#include <sys/vnode.h>
43#include <sys/stat.h>
44#include <sys/mount.h>

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

58static void ext2_fserr(struct m_ext2fs *, uid_t, char *);
59static u_long ext2_hashalloc(struct inode *, int, long, int,
60 daddr_t (*)(struct inode *, int, daddr_t,
61 int));
62static daddr_t ext2_nodealloccg(struct inode *, int, daddr_t, int);
63static daddr_t ext2_mapsearch(struct m_ext2fs *, char *, daddr_t);
64
65/*
66 * Allocate a block in the file system.
66 * Allocate a block in the filesystem.
67 *
68 * A preference may be optionally specified. If a preference is given
69 * the following hierarchy is used to allocate a block:
70 * 1) allocate the requested block.
71 * 2) allocate a rotationally optimal block in the same cylinder.
72 * 3) allocate a block in the same cylinder group.
73 * 4) quadradically rehash into other cylinder groups, until an
74 * available block is located.

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

120
121 ip->i_blocks += btodb(fs->e2fs_bsize);
122 ip->i_flag |= IN_CHANGE | IN_UPDATE;
123 *bnp = bno;
124 return (0);
125 }
126nospace:
127 EXT2_UNLOCK(ump);
67 *
68 * A preference may be optionally specified. If a preference is given
69 * the following hierarchy is used to allocate a block:
70 * 1) allocate the requested block.
71 * 2) allocate a rotationally optimal block in the same cylinder.
72 * 3) allocate a block in the same cylinder group.
73 * 4) quadradically rehash into other cylinder groups, until an
74 * available block is located.

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

120
121 ip->i_blocks += btodb(fs->e2fs_bsize);
122 ip->i_flag |= IN_CHANGE | IN_UPDATE;
123 *bnp = bno;
124 return (0);
125 }
126nospace:
127 EXT2_UNLOCK(ump);
128 ext2_fserr(fs, cred->cr_uid, "file system full");
129 uprintf("\n%s: write failed, file system is full\n", fs->e2fs_fsmnt);
128 ext2_fserr(fs, cred->cr_uid, "filesystem full");
129 uprintf("\n%s: write failed, filesystem is full\n", fs->e2fs_fsmnt);
130 return (ENOSPC);
131}
132
133/*
134 * Reallocate a sequence of blocks into a contiguous sequence of blocks.
135 *
136 * The vnode and an array of buffer pointers for a range of sequential
137 * logical blocks to be made contiguous is given. The allocator attempts

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

333 if (ssize < len)
334 brelse(ebp);
335 if (sbap != &ip->i_db[0])
336 brelse(sbp);
337 return (ENOSPC);
338}
339
340/*
130 return (ENOSPC);
131}
132
133/*
134 * Reallocate a sequence of blocks into a contiguous sequence of blocks.
135 *
136 * The vnode and an array of buffer pointers for a range of sequential
137 * logical blocks to be made contiguous is given. The allocator attempts

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

333 if (ssize < len)
334 brelse(ebp);
335 if (sbap != &ip->i_db[0])
336 brelse(sbp);
337 return (ENOSPC);
338}
339
340/*
341 * Allocate an inode in the file system.
341 * Allocate an inode in the filesystem.
342 *
343 */
344int
345ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp)
346{
347 struct timespec ts;
348 struct inode *pip;
349 struct m_ext2fs *fs;

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

1078 panic("ext2_mapsearch: map corrupted");
1079 /* NOTREACHED */
1080 }
1081 }
1082 return ((loc - bbp) * NBBY + ffs(~*loc) - 1);
1083}
1084
1085/*
342 *
343 */
344int
345ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp)
346{
347 struct timespec ts;
348 struct inode *pip;
349 struct m_ext2fs *fs;

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

1078 panic("ext2_mapsearch: map corrupted");
1079 /* NOTREACHED */
1080 }
1081 }
1082 return ((loc - bbp) * NBBY + ffs(~*loc) - 1);
1083}
1084
1085/*
1086 * Fserr prints the name of a file system with an error diagnostic.
1086 * Fserr prints the name of a filesystem with an error diagnostic.
1087 *
1088 * The form of the error message is:
1089 * fs: error message
1090 */
1091static void
1092ext2_fserr(struct m_ext2fs *fs, uid_t uid, char *cp)
1093{
1094

--- 17 unchanged lines hidden ---
1087 *
1088 * The form of the error message is:
1089 * fs: error message
1090 */
1091static void
1092ext2_fserr(struct m_ext2fs *fs, uid_t uid, char *cp)
1093{
1094

--- 17 unchanged lines hidden ---