From nobody@FreeBSD.org  Thu Feb 16 14:41:42 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D676816A420
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 16 Feb 2006 14:41:42 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9119C43D46
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 16 Feb 2006 14:41:42 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k1GEff0p083359
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 16 Feb 2006 14:41:41 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k1GEffxh083357;
	Thu, 16 Feb 2006 14:41:41 GMT
	(envelope-from nobody)
Message-Id: <200602161441.k1GEffxh083357@www.freebsd.org>
Date: Thu, 16 Feb 2006 14:41:41 GMT
From: Ilya Danilyuk <furcube@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: kernel panic after setting big value of tunefs -f and -s
X-Send-Pr-Version: www-2.3

>Number:         93435
>Category:       kern
>Synopsis:       [ufs] [panic] kernel panic after setting big value of tunefs -f and -s
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 16 14:50:09 GMT 2006
>Closed-Date:    Sun Sep 16 09:49:36 GMT 2007
>Last-Modified:  Sun Sep 16 10:07:11 GMT 2007
>Originator:     Ilya Danilyuk
>Release:        6.0
>Organization:
>Environment:
FreeBSD mr114-121.lan 6.1-PRERELEASE FreeBSD 6.1-PRERELEASE #0: Tue Feb 14 23:42:40 MSK 2006     ilya@mr114-121.lan:/usr/src/obj/usr/src/sys/SERV_DBG  i386

>Description:
I cvsup'd kernel and built it with DDB.

After altering tunefs' options (setting average file size to 200M and average files per directory to 40)
tunefs -f 209715200 -s 40

i've got a kernel panic:

Fatal trap 18: integer divide fault while in kernel mode
instruction pointer     = 0x20:0xc0602d2d
stack pointer           = 0x28:0xda9c293c
frame pointer           = 0x28:0xda9c2978
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, def32 1, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 4933 (pure-ftpd)

part of trace report of ddb (simplified):
ffs_dirpref(c35608c4,da9c2c14,da9c2c00,3fff,200) + 0x22d
ffs_valloc+0x9f
VOP_MKDIR_APV+0x3e
kern_mkdir+0x3af

it seems like problem is here:
ffs_alloc.c
line 1051

	dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir;
	curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 0;
	if (dirsize < curdirsize)
		dirsize = curdirsize;
	maxcontigdirs = min((avgbfree * fs->fs_bsize) / dirsize, 255);

dirsize is 32-bit, but result of 200M*40 is 33 bit
>How-To-Repeat:
use tunefs with big average file size and average files per dir
and create directories and files on volume (sometimes there's no error)

for example
tunefs -f 209715200 -s 40 /volume
and then mkdir /something ; mkdir -p /something1/somth3  e.t.c.

>Fix:
maybe change integers to uint64...
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: gavin 
State-Changed-When: Sun Sep 16 09:48:26 UTC 2007 
State-Changed-Why:  
Astrodog notes this is a duplicate of kern/89202 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93435 
>Unformatted:
