From owner-freebsd-stable@FreeBSD.ORG Tue Oct 26 20:42:31 2004 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5F56D16A4CE for ; Tue, 26 Oct 2004 20:42:31 +0000 (GMT) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id D829643D45 for ; Tue, 26 Oct 2004 20:42:30 +0000 (GMT) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.13.1/8.13.1) with ESMTP id i9QKgNS4018723; Tue, 26 Oct 2004 13:42:27 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <200410262042.i9QKgNS4018723@gw.catspoiler.org> Date: Tue, 26 Oct 2004 13:42:23 -0700 (PDT) From: Don Lewis To: fbsdlist@merdin.com In-Reply-To: <1076237332.20040827215245@kaluga.ru> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii cc: freebsd-stable@FreeBSD.org Subject: Re: ffs_alloc panic patch X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2004 20:42:31 -0000 On 27 Aug, Pavel Merdine wrote: > Hello, > > I'd like to propose the following patch: > > ------------------------------------------------------------------ > --- ffs_alloc.c.orig Fri May 14 19:03:50 2004 > +++ ffs_alloc.c Sat Aug 7 03:36:32 2004 > @@ -712,7 +712,7 @@ > minbfree = 1; > cgsize = fs->fs_fsize * fs->fs_fpg; > dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir; > - curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 0; > + curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 512; > if (dirsize < curdirsize) > dirsize = curdirsize; > maxcontigdirs = min((avgbfree * fs->fs_bsize) / dirsize, 255); > ------------------------------------------------------------------ > > It should solve the problem of "panic: integer divide fault" on the > last line of the code above. The panic happens on: > 1. directory creation > 2. when disk is empty > 3. when avg_dir_size avg_file_size are set to values, so > avg_dir_size * avg_file_size is negative in integer. > example: avg_dir_size = 8000, avf_file_size = 375000. > (curdirsize == 0 and dirsize < 0, so dirsize = 0) I'd prefer to cap dirsize at cgsize in this case. Even without the panic, I think you'll find the performance of the file system in this case will be terrible.