This patch fixes a problem whereby filesystems that ran

out of inodes in a cylinder group would fail to check for
free inodes in other cylinder groups. This bug was introduced
in the UFS2 code merge two days ago.

An inode is allocated by calling ffs_valloc which calls
ffs_hashalloc to do the filesystem scan. Ffs_hashalloc
walks around the cylinder groups calling its passed allocator
(ffs_nodealloccg in this case) until the allocator returns a
non-zero result. The bug is that ffs_hashalloc expects the
passed allocator function to return a 64-bit ufs2_daddr_t.
When allocating inodes, it calls ffs_nodealloccg which was
returning a 32-bit ino_t. The ffs_hashalloc code checked
a 64-bit return value and usually found random non-zero bits in
the high 32-bits so decided that the allocation had succeeded
(in this case in the only cylinder group that it checked).
When the result was passed back to ffs_valloc it looked at
only the bottom 32-bits, saw zero and declared the system
out of inodes. But ffs_hashalloc had really only checked
one cylinder group.

The fix is to change ffs_nodealloccg to return 64-bit results.

Sponsored by:	DARPA & NAI Labs.
Submitted by:	Poul-Henning Kamp <phk@critter.freebsd.dk>
Reviewed by:	Maxime Henrion <mux@freebsd.org>
This commit is contained in:
Kirk McKusick 2002-06-22 21:24:58 +00:00
parent dbc46ca401
commit 5006e77609

View File

@ -86,7 +86,7 @@ static ufs2_daddr_t ffs_fragextend(struct inode *, int, ufs2_daddr_t, int, int);
static void ffs_fserr(struct fs *, ino_t, char *);
static ufs2_daddr_t ffs_hashalloc
(struct inode *, int, ufs2_daddr_t, int, allocfcn_t *);
static ino_t ffs_nodealloccg(struct inode *, int, ufs2_daddr_t, int);
static ufs2_daddr_t ffs_nodealloccg(struct inode *, int, ufs2_daddr_t, int);
static ufs1_daddr_t ffs_mapsearch(struct fs *, struct cg *, ufs2_daddr_t, int);
static int ffs_reallocblks_ufs1(struct vop_reallocblks_args *);
static int ffs_reallocblks_ufs2(struct vop_reallocblks_args *);
@ -1543,7 +1543,7 @@ ffs_clusteralloc(ip, cg, bpref, len)
* 2) allocate the next available inode after the requested
* inode in the specified cylinder group.
*/
static ino_t
static ufs2_daddr_t
ffs_nodealloccg(ip, cg, ipref, mode)
struct inode *ip;
int cg;