diff --git a/sys/ufs/lfs/lfs_alloc.c b/sys/ufs/lfs/lfs_alloc.c index 5cd6c449da01..66f5e6344175 100644 --- a/sys/ufs/lfs/lfs_alloc.c +++ b/sys/ufs/lfs/lfs_alloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_alloc.c,v 1.88 2006/04/10 21:20:19 perseant Exp $ */ +/* $NetBSD: lfs_alloc.c,v 1.89 2006/04/22 00:12:45 perseant Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.88 2006/04/10 21:20:19 perseant Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.89 2006/04/22 00:12:45 perseant Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -290,19 +290,19 @@ extend_ifile(struct lfs *fs, struct ucred *cred) if (fs->lfs_version == 1) { for (ifp_v1 = (IFILE_V1 *)bp->b_data; i < xmax; ++ifp_v1) { + SET_BITMAP_FREE(fs, i); ifp_v1->if_version = 1; ifp_v1->if_daddr = LFS_UNUSED_DADDR; ifp_v1->if_nextfree = ++i; - SET_BITMAP_FREE(fs, i); } ifp_v1--; ifp_v1->if_nextfree = oldlast; } else { for (ifp = (IFILE *)bp->b_data; i < xmax; ++ifp) { + SET_BITMAP_FREE(fs, i); ifp->if_version = 1; ifp->if_daddr = LFS_UNUSED_DADDR; ifp->if_nextfree = ++i; - SET_BITMAP_FREE(fs, i); } ifp--; ifp->if_nextfree = oldlast; @@ -512,7 +512,7 @@ lfs_freelist_prev(struct lfs *fs, ino_t ino) /* Search our own word first */ bound = ino & ~BMMASK; - for (tino = ino - 1; tino > bound && tino > LFS_UNUSED_INUM; tino--) + for (tino = ino - 1; tino >= bound && tino > LFS_UNUSED_INUM; tino--) if (ISSET_BITMAP_FREE(fs, tino)) return tino; /* If there are no lower words to search, just return */ @@ -531,7 +531,8 @@ lfs_freelist_prev(struct lfs *fs, ino_t ino) return LFS_UNUSED_INUM; /* Search the word we found */ - for (tino = (bb << BMSHIFT) | BMMASK; tino > LFS_UNUSED_INUM; tino--) + for (tino = (bb << BMSHIFT) | BMMASK; tino >= (bb << BMSHIFT) && + tino > LFS_UNUSED_INUM; tino--) if (ISSET_BITMAP_FREE(fs, tino)) break;