From f6da000c05feb73d9ea67e2f4d2b2f12ca9d7581 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 19 Sep 1997 11:13:16 +0000 Subject: [Regarding the previous patch] This is completely wrong. 1. ffs_alloc() actually allowed writing one block less one frag (normally 7 frags or 7/8 blocks) beyond the limit. 2. freebufspace() gives the free space in frags, but `size' is in bytes, so the change results in approximately `size' fragments too many being reserved. 3. ffs_realloccg() has the same bug but wasn't changed. PR: 3398 Submitted by: bde Eyeballed by: phk --- sys/ufs/ffs/ffs_alloc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/ufs/ffs/ffs_alloc.c') diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 7bb60a5..a4c1173 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95 - * $Id: ffs_alloc.c,v 1.35 1997/09/02 20:06:44 bde Exp $ + * $Id: ffs_alloc.c,v 1.36 1997/09/18 18:07:45 phk Exp $ */ #include "opt_quota.h" @@ -117,7 +117,8 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp) #endif /* DIAGNOSTIC */ if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) goto nospace; - if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) - size < 0) + if (cred->cr_uid != 0 && + freespace(fs, fs->fs_minfree) - numfrags(fs, size) < 0) goto nospace; #ifdef QUOTA error = chkdq(ip, (long)btodb(size), cred, 0); @@ -187,7 +188,8 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) if (cred == NOCRED) panic("ffs_realloccg: missing credential"); #endif /* DIAGNOSTIC */ - if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) + if (cred->cr_uid != 0 && + freespace(fs, fs->fs_minfree) - numfrags(fs, nsize - osize) < 0) goto nospace; if ((bprev = ip->i_db[lbprev]) == 0) { printf("dev = 0x%lx, bsize = %ld, bprev = %ld, fs = %s\n", -- cgit v1.1