From nobody@FreeBSD.org  Fri Apr 24 20:11:02 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 70175106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 24 Apr 2009 20:11:02 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5C2658FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 24 Apr 2009 20:11:02 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n3OKB17i073530
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 24 Apr 2009 20:11:01 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n3OKB1Va073528;
	Fri, 24 Apr 2009 20:11:01 GMT
	(envelope-from nobody)
Message-Id: <200904242011.n3OKB1Va073528@www.freebsd.org>
Date: Fri, 24 Apr 2009 20:11:01 GMT
From: John Kilburg <john@physics.unlv.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: panic: ffs_valloc: dup alloc
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         133980
>Category:       kern
>Synopsis:       [panic] [ffs] panic: ffs_valloc: dup alloc
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    mckusick
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 24 20:20:02 UTC 2009
>Closed-Date:    Sun Feb 28 04:58:18 UTC 2010
>Last-Modified:  Sun Feb 28 04:58:18 UTC 2010
>Originator:     John Kilburg
>Release:        7.2-PRERELEASE
>Organization:
UNLV Department of Physics and Astronomy
>Environment:
FreeBSD nandromeda 7.2-PRERELEASE FreeBSD 7.2-PRERELEASE #1: Thu Apr 23 19:12:21 PDT 2009     root@nandromeda:/usr/obj/usr/src/sys/NANDROMEDA  amd64
>Description:
Putting a heavy load on a large filesystem seems to cause g_vfs_done error =5 with bad write offsets and then a panic:

Apr 23 18:44:38 nandromeda kernel: g_vfs_done():da1[WRITE(offset=-15856836640768, length=16384)]error = 5
Apr 23 18:44:38 nandromeda kernel: mode = 0174117, inum = 2356354177, fs = /data
Apr 23 18:44:38 nandromeda kernel: panic: ffs_valloc: dup alloc

The filesystem was originally on a GPT partition with GEOM_LABEL and GEOM_GPT compiled into the kernel.  The host never crashed but gave huge numbers of g_vfs_done errors with crazy offsets (e.g. -15856836640768).  Eventually it slowed down to a crawl and had to be rebooted to recover performance.

I then compiled the kernel with all of the GEOM drivers removed and the filesystem on the device without any partitioning (/dev/da1).  The device is an Areca 1280 RAID 6 device (~19TB).

Without the GEOM options the host seems to crash after the first g_vfs_done error.

This is a problem with 7.1/amd64 as well.  I plan on trying with 6.4 and also with different hardware.

I made sure that fsck completed successfully on the filesystem before repeating the test which caused this crash.  The filesystem was created with "newfs -U /dev/da1"

The load I used was 4 concurrent rsync/ssh sessions from one host to the machine which crashed.  This seemed to do a better job of saturating the network link than 1-3 concurrent sessions.  Saturating the network link is always the goal, right? :)


>How-To-Repeat:
Run 4 concurrent rsync/ssh sessions from a Sun X4500 running Solaris to a 19TB filesystem on a FreeBSD 7 system.


>Fix:


Patch attached with submission follows:

nandromeda dumped core - see /var/crash/vmcore.1

Thu Apr 23 21:21:08 PDT 2009

FreeBSD nandromeda 7.2-PRERELEASE FreeBSD 7.2-PRERELEASE #1: Thu Apr 23 19:12:21 PDT 2009     root@nandromeda:/usr/obj/usr/src/sys/NANDROMEDA  amd64

panic: ffs_valloc: dup alloc

GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...

Unread portion of the kernel message buffer:
mode = 0177443, inum = 2356354304, fs = /data
panic: ffs_valloc: dup alloc
cpuid = 2
Uptime: 1h41m34s
Physical memory: 8056 MB
Dumping 651 MB: 636 620 604 588 572 556 540 524 508 492 476 460 444 428 412 396 380 364 348 332 316 300 284 268 252 236 220 204 188 172 156 140 124 108 92 76 60 44 28 12

#0  doadump () at pcpu.h:195
195	pcpu.h: No such file or directory.
	in pcpu.h
(kgdb) #0  doadump () at pcpu.h:195
#1  0x0000000000000004 in ?? ()
#2  0xffffffff802833f9 in boot (howto=260)
    at /usr/src/sys/kern/kern_shutdown.c:418
#3  0xffffffff80283802 in panic (fmt=0x104 <Address 0x104 out of bounds>)
    at /usr/src/sys/kern/kern_shutdown.c:574
#4  0xffffffff803f2ce2 in ffs_valloc (pvp=0xffffff0116c5c7e0, mode=33152, cred=Variable "cred" is not available.

) at /usr/src/sys/ufs/ffs/ffs_alloc.c:987
#5  0xffffffff8041ca7e in ufs_makeinode (mode=33152, dvp=0xffffff011e3131f8, 
    vpp=0xffffffff4d358a38, cnp=0xffffffff4d358a60)
    at /usr/src/sys/ufs/ufs/ufs_vnops.c:2252
#6  0xffffffff80497e30 in VOP_CREATE_APV (vop=Variable "vop" is not available.
) at vnode_if.c:206
#7  0xffffffff8031363f in vn_open_cred (ndp=0xffffffff4d358a10, 
    flagp=0xffffffff4d35895c, cmode=Variable "cmode" is not available.
) at vnode_if.h:112
#8  0xffffffff80310d71 in kern_open (td=0xffffff00059d06e0, 
    path=0x7fffffffb6a0 <Address 0x7fffffffb6a0 out of bounds>, pathseg=Variable "pathseg" is not available.
)
    at /usr/src/sys/kern/vfs_syscalls.c:1042
#9  0xffffffff804630b7 in syscall (frame=0xffffffff4d358c80)
    at /usr/src/sys/amd64/amd64/trap.c:900
#10 0xffffffff80447aeb in Xfast_syscall ()
    at /usr/src/sys/amd64/amd64/exception.S:330
#11 0x000000080075c64c in ?? ()
Previous frame inner to this frame (corrupt stack?)
(kgdb) 

------------------------------------------------------------------------
ps -axl

  UID   PID  PPID CPU PRI NI   VSZ   RSS MWCHAN STAT  TT       TIME COMMAND
    0     0     0   0 -16  0     0     0 sched  DLs   ??  253623:23.00 [swapper]
    0     1     0   0   8  0  2180     0 wait   DLs   ??  119106:35.00 [init]
    0     2     0   0  -8  0     0     0 -      DL    ??  5458004:33.00 [g_event]
    0     3     0   0  -8  0     0     0 -      DL    ??  150786447:15.00 [g_up]
    0     4     0   0  -8  0     0     0 -      DL    ??  209822043:17.00 [g_down]
    0     5     0   0   8  0     0     0 -      DL    ??    0:00.00 [thread tas
    0     6     0   0   8  0     0     0 -      DL    ??    0:00.00 [acpi_task_
    0     7     0   0   8  0     0     0 -      DL    ??    0:00.00 [acpi_task_
    0     8     0   0   8  0     0     0 -      DL    ??    0:00.00 [acpi_task_
    0     9     0   0  -8  0     0     0 ccb_sc DL    ??    0:00.00 [xpt_thrd]
    0    10     0   0 -16  0     0     0 audit_ DL    ??    0:00.00 [audit]
    0    11     0   0 171  0     0     0 -      RL    ??  103053679054:53.00 [idle: cpu3
    0    12     0   0 171  0     0     0 -      RL    ??  102634377891:29.00 [idle: cpu2
    0    13     0   0 171  0     0     0 -      RL    ??  102344820363:15.00 [idle: cpu1
    0    14     0   0 171  0     0     0 -      RL    ??  103694445335:26.00 [idle: cpu0
    0    15     0   0 -44  0     0     0 -      WL    ??  13941:44.00 [swi1: net]
    0    16     0   0 -32  0     0     0 -      WL    ??  182541997:08.00 [swi4: cloc
    0    17     0   0 -36  0     0     0 -      WL    ??    0:00.00 [swi3: vm]
    0    18     0   0 -16  0     0     0 -      DL    ??  7206177:25.00 [yarrow]
    0    19     0   0 -24  0     0     0 -      WL    ??    0:00.00 [swi6: Gian
    0    20     0   0 -24  0     0     0 -      WL    ??  21623:22.00 [swi6: task
    0    21     0   0 -40  0     0     0 -      WL    ??  223703888:40.00 [swi2: camb
    0    22     0   0   8  0     0     0 -      DL    ??    0:00.00 [kqueue tas
    0    23     0   0 -28  0     0     0 -      WL    ??    0:00.00 [swi5: +]
    0    24     0   0 -52  0     0     0 -      WL    ??    0:00.00 [irq9: acpi
    0    25     0   0 -64  0     0     0 -      WL    ??    0:00.00 [irq21: ohc
    0    26     0   0   8  0     0     0 usbevt DL    ??  6727:47.00 [usb0]
    0    27     0   0   8  0     0     0 usbtsk DL    ??    0:00.00 [usbtask-hc
    0    28     0   0   8  0     0     0 usbtsk DL    ??    0:00.00 [usbtask-dr
    0    29     0   0 -64  0     0     0 -      WL    ??    0:00.00 [irq22: ehc
    0    30     0   0   8  0     0     0 usbevt DL    ??  7816:55.00 [usb1]
    0    31     0   0 -64  0     0     0 -      WL    ??    0:00.00 [irq14: ata
    0    32     0   0 -64  0     0     0 -      WL    ??    0:00.00 [irq15: ata
    0    33     0   0 -64  0     0     0 -      WL    ??    0:00.00 [irq23: ata
    0    34     0   0 -64  0     0     0 -      WL    ??    0:00.00 [irq20: ata
    0    35     0   0 -68  0     0     0 -      DL    ??  40362111:52.00 [nfe0 taskq
    0    36     0   0 -68  0     0     0 -      DL    ??    0:00.00 [nfe1 taskq
    0    37     0   0 -64  0     0     0 -      RL    ??  155892032:19.00 [irq16: arc
    0    38     0   0  -8  0     0     0 -      DL    ??  489835:22.00 [fdc0]
    0    39     0   0 -60  0     0     0 -      WL    ??    0:00.00 [irq1: atkb
    0    40     0   0 -48  0     0     0 -      WL    ??    0:00.00 [swi0: sio]
    0    41     0   0 -16  0     0     0 waitin DL    ??  473:11.00 [sctp_itera
    0    42     0   0 -16  0     0     0 psleep DL    ??  103329:20.00 [pagedaemon
    0    43     0   0  20  0     0     0 psleep DL    ??  259:17.00 [vmdaemon]
    0    44     0   0 171  0     0     0 pgzero DL    ??  2344:44.00 [pagezero]
    0    45     0   0 -16  0     0     0 psleep DL    ??  494271:32.00 [bufdaemon]
    0    46     0   0  20  0     0     0 syncer DL    ??  3283446:40.00 [syncer]
    0    47     0   0  -4  0     0     0 vlruwt DL    ??  567010:08.00 [vnlru]
    0    48     0   0 -16  0     0     0 sdflus DL    ??  1052092:46.00 [softdepflu
    0   164     1   0  20  0  2568     0 pause  Ds    ??  9405:21.00 [adjkerntz]
    0   460     1   0  44  0  2180     0 select Ds    ??  49754:42.00 [devd]
    0   532     1   0  44  0  5692     0 -      Rs    ??  376058:17.00 [syslogd]
    0   627     1   0  52  0 22880     0 select Ds    ??  173197:29.00 [sshd]
    0   655     1   0  44  0 10484     0 -      Rs    ??  2103958:15.00 [ntpd]
    0   662     1   0  44  0  5692     0 -      Rs    ??  35625921:52.00 [powerd]
    0   680     1   0  44  0 22880     0 select Ds    ??  122559:36.00 [sshd]
    0   686     1   0  20  0 10700     0 pause  Ds    ??  81919:22.00 [sendmail]
   25   690     1   0  20  0 10700     0 pause  Ds    ??  89053:02.00 [sendmail]
    0   696     1   0   8  0  6748     0 nanslp Ds    ??  363524:13.00 [cron]
    0   735     1   0   5  0  5688     0 ttyin  Ds+   ??  74639:49.00 [getty]
    0   736     1   0   5  0  5688     0 ttyin  Ds+   ??  82494:40.00 [getty]
    0   737     1   0   5  0  5688     0 ttyin  Ds+   ??  77392:44.00 [getty]
    0  1074   627   0  45  0 33772     0 select Ds    ??  53468759:07.00 [sshd]
    0  1080  1074   0  -8  0 11776     0 -      Rs    ??  195303028:56.00 [rsync]
    0  1087  1080   0  44  0 96768     0 select D     ??  40493507:01.00 [rsync]
    0  1088   680   0   4  0 33772     0 sbwait Ds    ??  701853:42.00 [sshd]
 1001  1091  1088   0  44  0 33772     0 select D     ??  553974:33.00 [sshd]
 1001  1093  1091   0   8  0  9016     0 wait   Ds    ??  1084641:37.00 [bash]
 1001  1125  1093   0  44  0  8116     0 -      R+    ??  517407:59.00 [top]
    0  1126   627   0  49  0 34796     0 -      Rs    ??  11515919:08.00 [sshd]
    0  1128   627   0  97  0 39916     0 -      Rs    ??  54288603:34.00 [sshd]
    0  1133  1128   0  52  0  5632     0 select Ds    ??  641551:52.00 [rsync]
    0  1134  1126   0  47  0  6656     0 select Ds    ??  5248745:36.00 [rsync]
    0  1135  1134   0  -8  0  7680     0 -      R     ??  5465926:21.00 [rsync]
    0  1136  1133   0  56  0  7680     0 -      R     ??  18240675:35.00 [rsync]

------------------------------------------------------------------------
vmstat -s

        0 cpu context switches
        0 device interrupts
        0 software interrupts
        0 traps
        0 system calls
        0 kernel threads created
        0  fork() calls
        0 vfork() calls
        0 rfork() calls
        0 swap pager pageins
        0 swap pager pages paged in
        0 swap pager pageouts
        0 swap pager pages paged out
        0 vnode pager pageins
        0 vnode pager pages paged in
        0 vnode pager pageouts
        0 vnode pager pages paged out
        0 page daemon wakeups
        0 pages examined by the page daemon
      225 pages reactivated
        0 copy-on-write faults
        0 copy-on-write optimized faults
        0 zero fill pages zeroed
        0 zero fill pages prezeroed
        0 intransit blocking page faults
        0 total VM faults taken
        0 pages affected by kernel thread creation
        0 pages affected by  fork()
        0 pages affected by vfork()
        0 pages affected by rfork()
      232 pages cached
        0 pages freed
        0 pages freed by daemon
   185690 pages freed by exiting processes
     9120 pages active
    55831 pages inactive
        6 pages in VM cache
    98351 pages wired down
  1832641 pages free
     4096 bytes per page
  4820409 total name lookups
          cache hits (87% pos + 0% neg) system 0% per-directory
          deletions 0%, falsehits 0%, toolong 0%

------------------------------------------------------------------------
vmstat -m

         Type InUse MemUse HighUse Requests  Size(s)
        sigio    -1     0K       -        0  
     filedesc 984595 -1008K       -   985952  16,32,64,128,256,512,1024,8192
         kenv   -44    -9K       -       32  16
       kqueue 151932  -147K       -   152064  32,64,128,256,1024
    proc-args 40293   -40K       -    41024  16,32,64,128,256,512,1024,2048,4096
       acpica 5803166 -5991K       -  5872336  16,32,64,256,512,2048,8192,16384,32768,65536,131072,262144,524288
      ithread  -102   -16K       -        0  
     acpitask   315     0K       -      320  16,64
CAM dev queue    -2     0K       -        0  
       KTRACE  -100   -11K       -        0  
    CAM queue 29124   -31K       -    29472  256,1024,4096
       linker   772    -2K       -      832  32,64,256
        lockf   424    -1K       -      448  64
  ata_generic    -1     0K       -        0  
       ip6ndp    -4     0K       -        0  
         temp 1717550223 -1677332K       - 1717582352  16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072
       devbuf 31898 -38875K       -    51456  16,32,64,128,256,1024
       module  -183   -21K       -        0  
      ata_dma    -8    -1K       -        0  
     mtx_pool    -1    -7K       -        0  
      subproc 4353272 -4626K       -  4354560  16,32,64,128,256,512,1024,2048,4096
         proc    -2   -15K       -        0  
      session  6201    -7K       -     6272  16,32,64,128,256
         pgrp 32997   -34K       -    33280  16,32,64,128,256,512,2048
         cred 1179859 -1162K       -  1184512  16,32,64,128,256,512,1024,2048,4096,16384,32768
      uidinfo  2957    -4K       -     3008  16,32,64,128,256
       plimit 144829  -143K       -   145408  16,32,64,128,256,512,2048,4096
   acd_driver    -1    -1K       -        0  
    sysctltmp 13774   -12K       -    14272  16,32,64,128,256,512,1024,4096
    sysctloid -2193  -187K       -     1744  16,64,128,512,1024
       sysctl 2825696 -2858K       -  2927632  16,32,64,128,256,512,1024,4096,8192,16384,32768,65536,131072,262144,524288
         umtx  -160   -19K       -        0  
     p1003.1b    -1     0K       -        0  
         SWAP    -2 -1095K       -        0  
       kbdmux    -6    -7K       -        0  
       bus-sc 1716211 -1771K       -  1717968  16,2048,8192,16384
          bus 2059372 -2084K       -  2064640  32,64,128,256,512,1024,2048,4096,8192,16384,32768
      devstat   -10   -19K       -        0  
 eventhandler   -56    -3K       -        0  
         kobj 57218  -503K       -    57344  32,64,128
         rman 49946   -75K       -    50560  16,32,128,2048,4096
      acpisem   -13     0K       -        0  
         sbuf 306396  -298K       -   306832  64,128,256,512,1024,2048
      CAM SIM    -2     0K       -        0  
        stack   510     0K       -      512  32
    taskqueue   -13     0K       -        0  
       Unitno    54     0K       -       64  32
          iov 69792   -67K       -    70240  32,128,256,512,1024,4096
     ioctlops 166409  -164K       -   169328  16,32,64,128,256,512,1024,2048,4096,8192,16384
          msg    -4   -29K       -        0  
          sem    -4   -10K       -        0  
          shm    -1   -19K       -        0  
         ttys 151761  -232K       -   153472  16,32,64,128,256,512,1024,2048,4096,8192
         ptys    -2     0K       -        0  
     mbuf_tag   341     0K       -      352  16,32,64
      scsi_da   705     0K       -      752  16,32,64,128,512
          pcb  3950  -159K       -     4096  16,32,64,128,256,512
       soname 57299   -56K       -    58304  16,64,128,256,512,1024,2048,4096
       biobuf 12282   -11K       -    12288  16,64
     vfscache    -1 -1023K       -        0  
   cl_savebuf  3425    -2K       -     3456  16,32,64,128
     vfs_hash    -1  -511K       -        0  
       vnodes    -1     0K       -        0  
   CAM periph 10012   -10K       -    10064  16,64,128,512
  vnodemarker 1084342 -1060K       -  1086464  16,64,128,256,512,1024,2048,4096,8192
        mount  3168    -6K       -     3344  16,128,512
      acpidev   -88    -4K       -        0  
          BPF    -3     0K       -        0  
  ether_multi    48     0K       -       64  16
       ifaddr   -45   -10K       -        0  
        ifnet    -4    -5K       -        0  
        clone    -4   -15K       -        0  
       arpcom    -2     0K       -        0  
           lo    -1     0K       -        0  
      entropy -1024   -63K       -        0  
       USBdev    -9    -3K       -        0  
     routetbl 27215   -93K       -    27488  16,64,128,256,1024
     in_multi    -2     0K       -        0  
  IpFw/IpAcct   -20    -2K       -        0  
    sctp_iter   510     0K       -      512  32
     sctp_ifn    -2     0K       -        0  
     sctp_ifa    -3     0K       -        0  
     sctp_vrf    -1     0K       -        0  
    sctp_a_it    30     0K       -       32  32
    hostcache    -1   -35K       -        0  
          USB  2771    -9K       -     2816  32,64
     syncache    -1   -99K       -        0  
    in6_multi   -16     0K       -        0  
       DEVFS1   -92   -45K       -        0  
audit_evclass   997    -4K       -     1184  16,64,512
     savedino  8160    -7K       -     8192  16,32,64,128
    newdirblk    -1     0K       -        0  
       dirrem 14867   -13K       -    15104  16,32,64,256,512,1024
        mkdir   756     0K       -      768  32,128
       diradd 15300   -22K       -    15680  16,32,64,128,256,512,1024
     freefile  1890     0K       -     1920  32,64,128
     freeblks  7395    -6K       -     7424  16,32,64,128
     freefrag  8126    -7K       -     8256  16,32,64,256,512,1024
   allocindir -3914  -824K       -     2688  16,32,64,128
     indirdep   -13     0K       -        0  
  allocdirect 38132  -130K       -    38656  16,32,64,128,256,512
    bmsafemap  4056    -4K       -     4096  16,32,64,128
       newblk 448937  -444K       -   456064  16,32,64,128,256,512,1024,2048,4096,8192,16384,32768
     inodedep 37092  -581K       -    37376  16,32,64,256,512,1024
      pagedep  3044  -130K       -     3072  16,32,128
  ufs_dirhash 1273961 -1310K       -  1276512  16,32,128,256,512,1024,2048,4096,8192,16384
    ufs_mount 2185707 -4324K       -  2185728  16,32
      UMAHash 17393   -35K       -    17408  16,32,64
       DEVFS3   152   -25K       -      256  16
    vm_pgdata    -2  -127K       -        0  
        DEVFS     2     0K       -       16  16
      io_apic    -1    -1K       -        0  
    pfs_nodes   -20    -4K       -        0  
      memdesc    -1    -3K       -        0  
          msi   -16    -1K       -        0  
     nexusdev    -4     0K       -        0  
         GEOM 147807  -162K       -   148368  16,32,64,128,256,1024,2048
       isadev    -6     0K       -        0  
     atkbddev    -1     0K       -        0  
      CAM XPT 997734439 -975324K       - 998709920  16,64,128,256,512,1024,2048,4096,8192,32768,65536,131072,262144,524288,1048576,2097152,4194304
     pci_link   -38    -1K       -        0  
    acpi_perf    -4     0K       -        0  
         cdev   -21    -4K       -        0  

------------------------------------------------------------------------
vmstat -z

vmstat: memstat_kvm_uma: invalid address (0xffffff0127a76000)
ITEM                     SIZE     LIMIT      USED      FREE  REQUESTS  FAILURES



------------------------------------------------------------------------
vmstat -i

interrupt                          total       rate
irq1: atkbd0                           6          0
irq6: fdc0                             8          0
irq14: ata0                           88          0
irq16: arcmsr0                    974161       9457
irq21: ohci0+                          1          0
cpu0: timer                     12192302     118371
irq256: nfe0                      284118       2758
cpu1: timer                     12184287     118294
cpu2: timer                     12184287     118294
cpu3: timer                     12184287     118294
Total                           50003545     485471

------------------------------------------------------------------------
pstat -T

101/12328 files
0M/8191M swap space

------------------------------------------------------------------------
pstat -s

Device          1K-blocks     Used    Avail Capacity
/dev/da0s1b       8388480        0  8388480     0%

------------------------------------------------------------------------
iostat

iostat: kvm_getcptime: 
iostat: disabling CPU time statistics
      tty             da0              da1            pass0 
 tin tout  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s 
   710261 12.04 154  1.81  18.42 9218 165.80   0.00   0  0.00 

------------------------------------------------------------------------
ipcs -a

Message Queues:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP                 CBYTES                 QNUM               QBYTES        LSPID        LRPID STIME    RTIME    CTIME   

Shared Memory:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP         NATTCH        SEGSZ         CPID         LPID ATIME    DTIME    CTIME   

Semaphores:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP          NSEMS OTIME    CTIME   


------------------------------------------------------------------------
ipcs -T

msginfo:
	msgmax:        16384	(max characters in a message)
	msgmni:           40	(# of message queues)
	msgmnb:         2048	(max characters in a message queue)
	msgtql:           40	(max # of messages in system)
	msgssz:            8	(size of a message segment)
	msgseg:         2048	(# of message segments in system)

shminfo:
	shmmax:     33554432	(max shared memory segment size)
	shmmin:            1	(min shared memory segment size)
	shmmni:          192	(max number of shared memory identifiers)
	shmseg:          128	(max shared memory segments per process)
	shmall:         8192	(max amount of shared memory in pages)

seminfo:
	semmap:           30	(# of entries in semaphore map)
	semmni:           10	(# of semaphore identifiers)
	semmns:           60	(# of semaphores in system)
	semmnu:           30	(# of undo structures in system)
	semmsl:           60	(max # of semaphores per id)
	semopm:          100	(max # of operations per semop call)
	semume:           10	(max # of undo entries per process)
	semusz:          152	(size in bytes of undo structure)
	semvmx:        32767	(semaphore maximum value)
	semaem:        16384	(adjust on exit max value)


------------------------------------------------------------------------
nfsstat

nfsstat: kvm_nlist: can't get names

------------------------------------------------------------------------
netstat -s

tcp:
	139914 packets sent
		70141 data packets (4538480 bytes)
		0 data packets (0 bytes) retransmitted
		0 data packets unnecessarily retransmitted
		0 resends initiated by MTU discovery
		54571 ack-only packets (68 delayed)
		0 URG only packets
		0 window probe packets
		15194 window update packets
		8 control packets
	170793 packets received
		55642 acks (for 4538500 bytes)
		36 duplicate acks
		0 acks for unsent data
		126884 packets (124726576 bytes) received in-sequence
		17 completely duplicate packets (0 bytes)
		0 old duplicate packets
		0 packets with some dup. data (0 bytes duped)
		1619 out-of-order packets (1954900 bytes)
		4 packets (4 bytes) of data after window
		4 window probes
		0 window update packets
		0 packets received after close
		235 discarded for bad checksums
		0 discarded for bad header offset fields
		0 discarded because packet too short
		0 discarded due to memory problems
	0 connection requests
	12 connection accepts
	0 bad connection attempts
	0 listen queue overflows
	0 ignored RSTs in the windows
	12 connections established (including accepts)
	14 connections closed (including 0 drops)
		8 connections updated cached RTT on close
		8 connections updated cached RTT variance on close
		0 connections updated cached ssthresh on close
	0 embryonic connections dropped
	53585 segments updated rtt (of 36280 attempts)
	0 retransmit timeouts
		0 connections dropped by rexmit timeout
	0 persist timeouts
		0 connections dropped by persist timeout
	0 Connections (fin_wait_2) dropped because of timeout
	0 keepalive timeouts
		0 keepalive probes sent
		0 connections dropped by keepalive
	15159 correct ACK header predictions
	113137 correct data packet header predictions
	12 syncache entries added
		0 retransmitted
		0 dupsyn
		0 dropped
		12 completed
		0 bucket overflow
		0 cache overflow
		0 reset
		0 stale
		0 aborted
		0 badack
		0 unreach
		0 zone failures
	12 cookies sent
	0 cookies received
	0 SACK recovery episodes
	0 segment rexmits in SACK recovery episodes
	0 byte rexmits in SACK recovery episodes
	0 SACK options (SACK blocks) received
	1509 SACK options (SACK blocks) sent
	0 SACK scoreboard overflow
udp:
	111 datagrams received
	0 with incomplete header
	0 with bad data length field
	0 with bad checksum
	0 with no checksum
	0 dropped due to no socket
	0 broadcast/multicast datagrams undelivered
	0 dropped due to full socket buffers
	0 not for hashed pcb
	111 delivered
	163 datagrams output
	0 times multicast source filter matched
ip:
	170904 total packets received
	0 bad header checksums
	0 with size smaller than minimum
	0 with data size < data length
	0 with ip length > max ip packet size
	0 with header length < data size
	0 with data length < header length
	0 with bad options
	0 with incorrect version number
	0 fragments received
	0 fragments dropped (dup or out of space)
	0 fragments dropped after timeout
	0 packets reassembled ok
	170904 packets for this host
	0 packets for unknown/unsupported protocol
	0 packets forwarded (0 packets fast forwarded)
	0 packets not forwardable
	0 packets received for unknown multicast group
	0 redirects sent
	140088 packets sent from this host
	0 packets sent with fabricated ip header
	0 output packets dropped due to no bufs, etc.
	0 output packets discarded due to no route
	0 output datagrams fragmented
	0 fragments created
	0 datagrams that can't be fragmented
	0 tunneling packets that can't find gif
	0 datagrams with bad address in header
icmp:
	0 calls to icmp_error
	0 errors not generated in response to an icmp message
	0 messages with bad code fields
	0 messages less than the minimum length
	0 messages with bad checksum
	0 messages with bad length
	0 multicast echo requests ignored
	0 multicast timestamp requests ignored
	0 message responses generated
	0 invalid return addresses
	0 no return routes
igmp:
	0 messages received
	0 messages received with too few bytes
	0 messages received with bad checksum
	0 membership queries received
	0 membership queries received with invalid field(s)
	0 membership reports received
	0 membership reports received with invalid field(s)
	0 membership reports received for groups to which we belong
	0 membership reports sent
ip6:
	0 total packets received
	0 with size smaller than minimum
	0 with data size < data length
	0 with bad options
	0 with incorrect version number
	0 fragments received
	0 fragments dropped (dup or out of space)
	0 fragments dropped after timeout
	0 fragments that exceeded limit
	0 packets reassembled ok
	0 packets for this host
	0 packets forwarded
	0 packets not forwardable
	0 redirects sent
	4 packets sent from this host
	0 packets sent with fabricated ip header
	0 output packets dropped due to no bufs, etc.
	0 output packets discarded due to no route
	0 output datagrams fragmented
	0 fragments created
	0 datagrams that can't be fragmented
	0 packets that violated scope rules
	0 multicast packets which we don't join
	Mbuf statistics:
		0 one mbuf
		0 one ext mbuf
		0 two or more ext mbuf
	0 packets whose headers are not continuous
	0 tunneling packets that can't find gif
	0 packets discarded because of too many headers
	0 failures of source address selection
	0 forward cache hit
	0 forward cache miss
	Source addresses selection rule applied:
icmp6:
	0 calls to icmp6_error
	0 errors not generated in response to an icmp6 message
	0 errors not generated because of rate limitation
	Output histogram:
		multicast listener report: 4
	0 messages with bad code fields
	0 messages < minimum length
	0 bad checksums
	0 messages with bad length
	Histogram of error messages to be generated:
		0 no route
		0 administratively prohibited
		0 beyond scope
		0 address unreachable
		0 port unreachable
		0 packet too big
		0 time exceed transit
		0 time exceed reassembly
		0 erroneous header field
		0 unrecognized next header
		0 unrecognized option
		0 redirect
		0 unknown
	0 message responses generated
	0 messages with too many ND options
	0 messages with bad ND options
	0 bad neighbor solicitation messages
	0 bad neighbor advertisement messages
	0 bad router solicitation messages
	0 bad router advertisement messages
	0 bad redirect messages
	0 path MTU changes
rip6:
	0 messages received
	0 checksum calculations on inbound
	0 messages with bad checksum
	0 messages dropped due to no socket
	0 multicast messages dropped due to no socket
	0 messages dropped due to full socket buffers
	0 delivered
	0 datagrams output

------------------------------------------------------------------------
netstat -m

netstat: memstat_kvm_all: invalid address (0xffffff0127a76000)

------------------------------------------------------------------------
netstat -id

Name    Mtu Network       Address              Ipkts Ierrs    Opkts Oerrs  Coll Drop
nfe0   8192 <Link#1>      00:24:8c:0c:37:74   170939     0   140084     0     0    0 
nfe0   8192 10.246.6.0    nandromeda.physic   170906     -   140164     -     -    - 
nfe1*  1500 <Link#2>      00:24:8c:0c:37:a6        0     0        0     0     0    0 
lo0   16384 <Link#3>                              10     0       10     0     0    0 
lo0   16384 fe80:3::1     fe80:3::1                0     -        0     -     -    - 
lo0   16384 localhost     ::1                      0     -        0     -     -    - 
lo0   16384 your-net      localhost                0     -        0     -     -    - 

------------------------------------------------------------------------
netstat -anr

Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.246.6.1         UGS         0    27647   nfe0
10.246.6.0/24      link#1             UC          0        0   nfe0
10.246.6.1         00:11:5c:8a:be:4c  UHLW        2        0   nfe0   7177
10.246.6.3         00:14:4f:20:d9:e8  UHLW        1   112442   nfe0   7126
10.246.6.16        00:24:8c:0c:37:74  UHLW        1       10    lo0
127.0.0.1          127.0.0.1          UH          0        0    lo0

Internet6:
Destination                       Gateway                       Flags      Netif Expire
::1                               ::1                           UHL         lo0
fe80::%lo0/64                     fe80::1%lo0                   U           lo0
fe80::1%lo0                       link#3                        UHL         lo0
ff01:3::/32                       fe80::1%lo0                   UC          lo0
ff02::%lo0/32                     fe80::1%lo0                   UC          lo0

------------------------------------------------------------------------
netstat -anA

Active Internet connections (including servers)
Tcpcb    Proto Recv-Q Send-Q  Local Address      Foreign Address    (state)
ffffff000574e2d8 tcp4   65700      0 10.246.6.16.23     10.246.6.3.50477   ESTABLISHED
ffffff000516eb60 tcp4   65700      0 10.246.6.16.23     10.246.6.3.50475   ESTABLISHED
ffffff000574e000 tcp4       0      0 10.246.6.16.22     131.216.65.5.51839 ESTABLISHED
ffffff000574e5b0 tcp4       0      0 10.246.6.16.23     10.246.6.3.50473   ESTABLISHED
ffffff000510f2d8 tcp4       0      0 *.22               *.*                LISTEN
ffffff000510f000 tcp6       0      0 *.22               *.*                LISTEN
ffffff000510f5b0 tcp4       0      0 *.23               *.*                LISTEN
ffffff000510f888 tcp6       0      0 *.23               *.*                LISTEN
ffffff0003f92900 udp4       0      0 127.0.0.1.123      *.*                
ffffff0003f92a20 udp6       0      0 ::1.123            *.*                
ffffff0003f92b40 udp6       0      0 fe80:3::1.123      *.*                
ffffff0003f92c60 udp4       0      0 10.246.6.16.123    *.*                
ffffff0003f92d80 udp6       0      0 *.123              *.*                
ffffff0003f3c000 udp4       0      0 *.123              *.*                
Active UNIX domain sockets
Address  Type   Recv-Q Send-Q    Inode     Conn     Refs  Nextref Addr
ffffff000591dc98 stream      0      0        0 ffffff000591dd90        0        0
ffffff000591dd90 stream      0      0        0 ffffff000591dc98        0        0
ffffff0127628000 stream      0      0        0 ffffff01276280f8        0        0
ffffff01276280f8 stream      0      0        0 ffffff0127628000        0        0
ffffff000504b9b0 stream      0      0        0 ffffff000504b8b8        0        0
ffffff000504b8b8 stream      0      0        0 ffffff000504b9b0        0        0
ffffff000504b1f0 stream      0      0        0 ffffff000504b0f8        0        0
ffffff000504b0f8 stream   6161      0        0 ffffff000504b1f0        0        0
ffffff0003f93d90 stream      0      0 ffffff0003f61dc8        0        0        0 /var/run/devd.pipe
ffffff0003f945d0 dgram       0      0        0 ffffff0003f93aa8        0        0
ffffff0003f937c0 dgram       0      0        0 ffffff0003f939b0        0 ffffff0003f938b8
ffffff0003f938b8 dgram       0      0        0 ffffff0003f939b0        0        0
ffffff0003f939b0 dgram       0      0 ffffff0003f475e8        0 ffffff0003f937c0        0 /var/run/logpriv
ffffff0003f93aa8 dgram       0      0 ffffff0003f477e0        0 ffffff0003f945d0        0 /var/run/log

------------------------------------------------------------------------
netstat -aL

Current listen queue sizes (qlen/incqlen/maxqlen)
Proto Listen         Local Address         
tcp4  0/0/128        *.ssh                  
tcp6  0/0/128        *.ssh                  
tcp4  0/0/128        *.telnet               
tcp6  0/0/128        *.telnet               
unix  0/0/4          /var/run/devd.pipe

------------------------------------------------------------------------
fstat

USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
root     rsync       1136 root /             2 drwxr-xr-x     512  r
root     rsync       1136   wd /data         2 drwxr-xr-x     512  r
root     rsync       1136 text /        284321 -rwxr-xr-x  1225071  r
root     rsync       1136    0* pipe ffffff0003e44ba0 <-> ffffff0003e44cf8   8192 rw
root     rsync       1136    1 /data    1631871111 -rw-------  97779712 rw
root     rsync       1136    2* pipe ffffff0003e48440 <-> ffffff0003e482e8      0 rw
root     rsync       1136    4* local stream ffffff000591dc98 <-> ffffff000591dd90
root     rsync       1135 root /             2 drwxr-xr-x     512  r
root     rsync       1135   wd /data         2 drwxr-xr-x     512  r
root     rsync       1135 text /        284321 -rwxr-xr-x  1225071  r
root     rsync       1135    0* pipe ffffff0003f54000 <-> ffffff0003f54158  12288 rw
root     rsync       1135    2* pipe ffffff000513da10 <-> ffffff000513d8b8      0 rw
root     rsync       1135    4* local stream ffffff0127628000 <-> ffffff01276280f8
root     rsync       1134 root /             2 drwxr-xr-x     512  r
root     rsync       1134   wd /data         2 drwxr-xr-x     512  r
root     rsync       1134 text /        284321 -rwxr-xr-x  1225071  r
root     rsync       1134    1* pipe ffffff0003f54440 <-> ffffff0003f542e8      0 rw
root     rsync       1134    2* pipe ffffff000513da10 <-> ffffff000513d8b8      0 rw
root     rsync       1134    3* local stream ffffff01276280f8 <-> ffffff0127628000
root     rsync       1133 root /             2 drwxr-xr-x     512  r
root     rsync       1133   wd /data         2 drwxr-xr-x     512  r
root     rsync       1133 text /        284321 -rwxr-xr-x  1225071  r
root     rsync       1133    1* pipe ffffff0003fb7158 <-> ffffff0003fb7000      0 rw
root     rsync       1133    2* pipe ffffff0003e48440 <-> ffffff0003e482e8      0 rw
root     rsync       1133    3* local stream ffffff000591dd90 <-> ffffff000591dc98
root     sshd        1128 root /             2 drwxr-xr-x     512  r
root     sshd        1128   wd /             2 drwxr-xr-x     512  r
root     sshd        1128 text /        213157 -r-xr-xr-x  243184  r
root     sshd        1128    0 /dev         13 crw-rw-rw-    null rw
root     sshd        1128    1 /dev         13 crw-rw-rw-    null rw
root     sshd        1128    2 /dev         13 crw-rw-rw-    null rw
root     sshd        1128    3* internet stream tcp ffffff000574e2d8
root     sshd        1128    4* pipe ffffff0003e44000 <-> ffffff0003e44158      0 rw
root     sshd        1128    5* pipe ffffff0003e44158 <-> ffffff0003e44000      0 rw
root     sshd        1128    7* pipe ffffff0003e44cf8 <-> ffffff0003e44ba0      0 rw
root     sshd        1128    8* pipe ffffff0003fb7000 <-> ffffff0003fb7158      0 rw
root     sshd        1128   10* pipe ffffff0003e482e8 <-> ffffff0003e48440      0 rw
root     sshd        1126 root /             2 drwxr-xr-x     512  r
root     sshd        1126   wd /             2 drwxr-xr-x     512  r
root     sshd        1126 text /        213157 -r-xr-xr-x  243184  r
root     sshd        1126    0 /dev         13 crw-rw-rw-    null rw
root     sshd        1126    1 /dev         13 crw-rw-rw-    null rw
root     sshd        1126    2 /dev         13 crw-rw-rw-    null rw
root     sshd        1126    3* internet stream tcp ffffff000516eb60
root     sshd        1126    4* pipe ffffff0003f548b8 <-> ffffff0003f54a10      0 rw
root     sshd        1126    5* pipe ffffff0003f54a10 <-> ffffff0003f548b8      0 rw
root     sshd        1126    7* pipe ffffff0003f54158 <-> ffffff0003f54000      0 rw
root     sshd        1126    8* pipe ffffff0003f542e8 <-> ffffff0003f54440      0 rw
root     sshd        1126   10* pipe ffffff000513d8b8 <-> ffffff000513da10      0 rw
remote   top         1125 root /             2 drwxr-xr-x     512  r
remote   top         1125   wd /space   21620736 drwxr-xr-x     512  r
remote   top         1125 text /        215962 -r-xr-xr-x   53680  r
remote   top         1125    0 /dev         96 crw--w----   ttyp0 rw
remote   top         1125    1 /dev         96 crw--w----   ttyp0 rw
remote   top         1125    2 /dev         96 crw--w----   ttyp0 rw
remote   top         1125    4 /dev         13 crw-rw-rw-    null  r
remote   top         1125    5 /dev         13 crw-rw-rw-    null  r
remote   bash        1093 root /             2 drwxr-xr-x     512  r
remote   bash        1093   wd /space   21620736 drwxr-xr-x     512  r
remote   bash        1093 text /        617892 -rwxr-xr-x  672696  r
remote   bash        1093    0 /dev         96 crw--w----   ttyp0 rw
remote   bash        1093    1 /dev         96 crw--w----   ttyp0 rw
remote   bash        1093    2 /dev         96 crw--w----   ttyp0 rw
remote   bash        1093  255 /dev         96 crw--w----   ttyp0 rw
remote   sshd        1091 root /             2 drwxr-xr-x     512  r
remote   sshd        1091   wd /             2 drwxr-xr-x     512  r
remote   sshd        1091 text /        213157 -r-xr-xr-x  243184  r
remote   sshd        1091    0 /dev         13 crw-rw-rw-    null rw
remote   sshd        1091    1 /dev         13 crw-rw-rw-    null rw
remote   sshd        1091    2 /dev         13 crw-rw-rw-    null rw
remote   sshd        1091    3* internet stream tcp ffffff000574e000
remote   sshd        1091    4* local stream ffffff000504b8b8 <-> ffffff000504b9b0
remote   sshd        1091    5* pipe ffffff0003e488b8 <-> ffffff0003e48a10      0 rw
remote   sshd        1091    6* pipe ffffff0003e48a10 <-> ffffff0003e488b8      0 rw
remote   sshd        1091    7 /dev         95 crw-rw-rw-   ptyp0 rw
remote   sshd        1091    9 /dev         95 crw-rw-rw-   ptyp0 rw
remote   sshd        1091   10 /dev         95 crw-rw-rw-   ptyp0 rw
root     sshd        1088 root /             2 drwxr-xr-x     512  r
root     sshd        1088   wd /             2 drwxr-xr-x     512  r
root     sshd        1088 text /        213157 -r-xr-xr-x  243184  r
root     sshd        1088    0 /dev         13 crw-rw-rw-    null  r
root     sshd        1088    1 /dev         13 crw-rw-rw-    null rw
root     sshd        1088    2 /dev         13 crw-rw-rw-    null rw
root     sshd        1088    3* internet stream tcp ffffff000574e000
root     sshd        1088    4 /dev         95 crw-rw-rw-   ptyp0 rw
root     sshd        1088    5* local stream ffffff000504b9b0 <-> ffffff000504b8b8
root     rsync       1087 root /             2 drwxr-xr-x     512  r
root     rsync       1087   wd /data         2 drwxr-xr-x     512  r
root     rsync       1087 text /        284321 -rwxr-xr-x  1225071  r
root     rsync       1087    0* pipe ffffff0003fb68b8 <-> ffffff0003fb6a10  11691 rw
root     rsync       1087    2* pipe ffffff0003fb6440 <-> ffffff0003fb62e8      0 rw
root     rsync       1087    4* local stream ffffff000504b1f0 <-> ffffff000504b0f8
root     rsync       1080 root /             2 drwxr-xr-x     512  r
root     rsync       1080   wd /data         2 drwxr-xr-x     512  r
root     rsync       1080 text /        284321 -rwxr-xr-x  1225071  r
root     rsync       1080    1* pipe ffffff0003fb6728 <-> ffffff0003fb65d0      0 rw
root     rsync       1080    2* pipe ffffff0003fb6440 <-> ffffff0003fb62e8      0 rw
root     rsync       1080    3* local stream ffffff000504b0f8 <-> ffffff000504b1f0
root     sshd        1074 root /             2 drwxr-xr-x     512  r
root     sshd        1074   wd /             2 drwxr-xr-x     512  r
root     sshd        1074 text /        213157 -r-xr-xr-x  243184  r
root     sshd        1074    0 /dev         13 crw-rw-rw-    null rw
root     sshd        1074    1 /dev         13 crw-rw-rw-    null rw
root     sshd        1074    2 /dev         13 crw-rw-rw-    null rw
root     sshd        1074    3* internet stream tcp ffffff000574e5b0
root     sshd        1074    4* pipe ffffff0003fb6ba0 <-> ffffff0003fb6cf8      0 rw
root     sshd        1074    5* pipe ffffff0003fb6cf8 <-> ffffff0003fb6ba0      0 rw
root     sshd        1074    7* pipe ffffff0003fb6a10 <-> ffffff0003fb68b8      0 rw
root     sshd        1074    8* pipe ffffff0003fb65d0 <-> ffffff0003fb6728      0 rw
root     sshd        1074   10* pipe ffffff0003fb62e8 <-> ffffff0003fb6440      0 rw
root     getty        737 root /             2 drwxr-xr-x     512  r
root     getty        737   wd /             2 drwxr-xr-x     512  r
root     getty        737 text /        216274 -r-xr-xr-x   27736  r
root     getty        737    0 /dev         55 crw-------   ttyv2 rw
root     getty        737    1 /dev         55 crw-------   ttyv2 rw
root     getty        737    2 /dev         55 crw-------   ttyv2 rw
root     getty        736 root /             2 drwxr-xr-x     512  r
root     getty        736   wd /             2 drwxr-xr-x     512  r
root     getty        736 text /        216274 -r-xr-xr-x   27736  r
root     getty        736    0 /dev         54 crw-------   ttyv1 rw
root     getty        736    1 /dev         54 crw-------   ttyv1 rw
root     getty        736    2 /dev         54 crw-------   ttyv1 rw
root     getty        735 root /             2 drwxr-xr-x     512  r
root     getty        735   wd /             2 drwxr-xr-x     512  r
root     getty        735 text /        216274 -r-xr-xr-x   27736  r
root     getty        735    0 /dev         53 crw-------   ttyv0 rw
root     getty        735    1 /dev         53 crw-------   ttyv0 rw
root     getty        735    2 /dev         53 crw-------   ttyv0 rw
root     cron         696 root /             2 drwxr-xr-x     512  r
root     cron         696   wd /var     1059840 drwxr-x---     512  r
root     cron         696 text /        216015 -r-xr-xr-x   39152  r
root     cron         696    0 /dev         13 crw-rw-rw-    null rw
root     cron         696    1 /dev         13 crw-rw-rw-    null rw
root     cron         696    2 /dev         13 crw-rw-rw-    null rw
root     cron         696    3 /var     895002 -rw-------       3  w
smmsp    sendmail     690 root /             2 drwxr-xr-x     512  r
smmsp    sendmail     690   wd /var     918534 drwxrwx---     512  r
smmsp    sendmail     690 text /        215125 -r-xr-sr-x  685424  r
smmsp    sendmail     690    0 /dev         13 crw-rw-rw-    null  r
smmsp    sendmail     690    1 /dev         13 crw-rw-rw-    null  w
smmsp    sendmail     690    2 /dev         13 crw-rw-rw-    null  w
smmsp    sendmail     690    3* local dgram ffffff0003f945d0 <-> ffffff0003f93aa8
smmsp    sendmail     690    4 /var     918536 -rw-------      49  w
root     sendmail     686 root /             2 drwxr-xr-x     512  r
root     sendmail     686   wd /var     918531 drwxr-xr-x     512  r
root     sendmail     686 text /        215125 -r-xr-sr-x  685424  r
root     sendmail     686    0 /dev         13 crw-rw-rw-    null  r
root     sendmail     686    1 /dev         13 crw-rw-rw-    null  w
root     sendmail     686    2 /dev         13 crw-rw-rw-    null  w
root     sendmail     686    3* local dgram ffffff0003f937c0 <-> ffffff0003f939b0
root     sendmail     686    4 /var     895001 -rw-------      41  w
root     sshd         680 root /             2 drwxr-xr-x     512  r
root     sshd         680   wd /             2 drwxr-xr-x     512  r
root     sshd         680 text /        213157 -r-xr-xr-x  243184  r
root     sshd         680    0 /dev         13 crw-rw-rw-    null rw
root     sshd         680    1 /dev         13 crw-rw-rw-    null rw
root     sshd         680    2 /dev         13 crw-rw-rw-    null rw
root     sshd         680    3* internet6 stream tcp ffffff000510f000
root     sshd         680    4* internet stream tcp ffffff000510f2d8
root     powerd       662 root /             2 drwxr-xr-x     512  r
root     powerd       662   wd /             2 drwxr-xr-x     512  r
root     powerd       662 text /        216028 -r-xr-xr-x   14112  r
root     powerd       662    0 /dev         13 crw-rw-rw-    null rw
root     powerd       662    1 /dev         13 crw-rw-rw-    null rw
root     powerd       662    2 /dev         13 crw-rw-rw-    null rw
root     powerd       662    3 /var     894999 -rw-------       3  w
root     ntpd         655 root /             2 drwxr-xr-x     512  r
root     ntpd         655   wd /             2 drwxr-xr-x     512  r
root     ntpd         655 text /        215071 -r-xr-xr-x  377184  r
root     ntpd         655    0 /dev         13 crw-rw-rw-    null rw
root     ntpd         655    1 /dev         13 crw-rw-rw-    null rw
root     ntpd         655    2 /dev         13 crw-rw-rw-    null rw
root     ntpd         655    3* local dgram ffffff0003f938b8 <-> ffffff0003f939b0
root     ntpd         655   20* internet dgram udp ffffff0003f3c000
root     ntpd         655   21* internet6 dgram udp ffffff0003f92d80
root     ntpd         655   22* internet dgram udp ffffff0003f92c60
root     ntpd         655   23* internet6 dgram udp ffffff0003f92b40
root     ntpd         655   24* internet6 dgram udp ffffff0003f92a20
root     ntpd         655   25* internet dgram udp ffffff0003f92900
root     ntpd         655   26* route raw 0 ffffff0003f7ab40
root     sshd         627 root /             2 drwxr-xr-x     512  r
root     sshd         627   wd /             2 drwxr-xr-x     512  r
root     sshd         627 text /        213157 -r-xr-xr-x  243184  r
root     sshd         627    0 /dev         13 crw-rw-rw-    null rw
root     sshd         627    1 /dev         13 crw-rw-rw-    null rw
root     sshd         627    2 /dev         13 crw-rw-rw-    null rw
root     sshd         627    3* internet6 stream tcp ffffff000510f888
root     sshd         627    4* internet stream tcp ffffff000510f5b0
root     syslogd      532 root /             2 drwxr-xr-x     512  r
root     syslogd      532   wd /             2 drwxr-xr-x     512  r
root     syslogd      532 text /        215136 -r-xr-xr-x   39016  r
root     syslogd      532    0 /dev         13 crw-rw-rw-    null rw
root     syslogd      532    1 /dev         13 crw-rw-rw-    null rw
root     syslogd      532    2 /dev         13 crw-rw-rw-    null rw
root     syslogd      532    3 /var     894987 -rw-------       3  w
root     syslogd      532    4* local dgram ffffff0003f93aa8
root     syslogd      532    5* local dgram ffffff0003f939b0
root     syslogd      532    6 /dev          6 crw-------    klog  r
root     syslogd      532    8 /var/log     41 -rw-------   28668  w
root     syslogd      532    9 -         -         bad    -
root     syslogd      532   10 /var/log     53 -rw-r--r--    3089  w
root     syslogd      532   11 /var/log     14 -rw-------      65  w
root     syslogd      532   12 /var/log      7 -rw-------   22094  w
root     syslogd      532   13 /var/log     52 -rw-r-----    1780  w
root     syslogd      532   14 /var/log     10 -rw-r--r--     406  w
root     syslogd      532   15 /var/log     16 -rw-------      65  w
root     syslogd      532   16 /var/log     22 -rw-------   71649  w
root     syslogd      532   17 /var/log      9 -rw-------     407  w
root     syslogd      532   18 /var/log     15 -rw-r-----      65  w
root     syslogd      532   19 /var/log     13 -rw-r-----      65  w
root     devd         460 root /             2 drwxr-xr-x     512  r
root     devd         460   wd /             2 drwxr-xr-x     512  r
root     devd         460 text /        706573 -r-xr-xr-x  402112  r
root     devd         460    0 /dev         13 crw-rw-rw-    null rw
root     devd         460    1 /dev         13 crw-rw-rw-    null rw
root     devd         460    2 /dev         13 crw-rw-rw-    null rw
root     devd         460    3 /dev          5 crw-------  devctl  r
root     devd         460    4* local stream ffffff0003f93d90
root     devd         460    5 /var     894986 -rw-------       3  w
root     adjkerntz    164 root /             2 drwxr-xr-x     512  r
root     adjkerntz    164   wd /             2 drwxr-xr-x     512  r
root     adjkerntz    164 text /        712254 -r-xr-xr-x    9184  r
root     adjkerntz    164    0 /dev         13 crw-rw-rw-    null rw
root     adjkerntz    164    1 /dev         13 crw-rw-rw-    null rw
root     adjkerntz    164    2 /dev         13 crw-rw-rw-    null rw
root     init           1 root /             2 drwxr-xr-x     512  r
root     init           1   wd /             2 drwxr-xr-x     512  r
root     init           1 text /        706598 -r-xr-xr-x  707360  r

------------------------------------------------------------------------
dmesg

Copyright (c) 1992-2009 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 7.2-PRERELEASE #1: Thu Apr 23 19:12:21 PDT 2009
    root@nandromeda:/usr/obj/usr/src/sys/NANDROMEDA
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Dual-Core AMD Opteron(tm) Processor 2212 (2000.10-MHz K8-class CPU)
  Origin = "AuthenticAMD"  Id = 0x40f12  Stepping = 2
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x2001<SSE3,CX16>
  AMD Features=0xea500800<SYSCALL,NX,MMX+,FFXSR,RDTSCP,LM,3DNow!+,3DNow!>
  AMD Features2=0x1f<LAHF,CMP,SVM,ExtAPIC,CR8>
  Cores per package: 2
usable memory = 8447954944 (8056 MB)
avail memory  = 8150515712 (7772 MB)
ACPI APIC Table: <111108 APIC1437>
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
 cpu2 (AP): APIC ID:  2
 cpu3 (AP): APIC ID:  3
ioapic0 <Version 1.1> irqs 0-23 on motherboard
kbd1 at kbdmux0
acpi0: <111108 XSDT1437> on motherboard
acpi0: [ITHREAD]
acpi0: Power Button (fixed)
acpi0: reservation of fec00000, 1000 (3) failed
acpi0: reservation of fee00000, 1000 (3) failed
acpi0: reservation of 0, a0000 (3) failed
acpi0: reservation of 100000, cff00000 (3) failed
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x2008-0x200b on acpi0
acpi_hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 25000000 Hz quality 900
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pci0: <memory, RAM> at device 0.0 (no driver attached)
isab0: <PCI-ISA bridge> port 0x2f00-0x2f7f at device 1.0 on pci0
isa0: <ISA bus> on isab0
pci0: <serial bus, SMBus> at device 1.1 (no driver attached)
ohci0: <OHCI (generic) USB controller> mem 0xfddfb000-0xfddfbfff irq 21 at device 2.0 on pci0
ohci0: [GIANT-LOCKED]
ohci0: [ITHREAD]
usb0: OHCI version 1.0, legacy support
usb0: SMM does not respond, resetting
usb0: <OHCI (generic) USB controller> on ohci0
usb0: USB revision 1.0
uhub0: <nVidia OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0
uhub0: 10 ports with 10 removable, self powered
ehci0: <EHCI (generic) USB 2.0 controller> mem 0xfddfac00-0xfddfacff irq 22 at device 2.1 on pci0
ehci0: [GIANT-LOCKED]
ehci0: [ITHREAD]
usb1: EHCI version 1.0
usb1: companion controller, 10 ports each: usb0
usb1: <EHCI (generic) USB 2.0 controller> on ehci0
usb1: USB revision 2.0
uhub1: <nVidia EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb1
uhub1: 10 ports with 10 removable, self powered
atapci0: <nVidia nForce MCP55 UDMA133 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xffa0-0xffaf at device 4.0 on pci0
ata0: <ATA channel 0> on atapci0
ata0: [ITHREAD]
ata1: <ATA channel 1> on atapci0
ata1: [ITHREAD]
atapci1: <nVidia nForce MCP55 SATA300 controller> port 0xd480-0xd487,0xd400-0xd403,0xd080-0xd087,0xd000-0xd003,0xcc00-0xcc0f mem 0xfddf9000-0xfddf9fff irq 23 at device 5.0 on pci0
atapci1: [ITHREAD]
ata2: <ATA channel 0> on atapci1
ata2: [ITHREAD]
ata3: <ATA channel 1> on atapci1
ata3: [ITHREAD]
atapci2: <nVidia nForce MCP55 SATA300 controller> port 0xc880-0xc887,0xc800-0xc803,0xc480-0xc487,0xc400-0xc403,0xc080-0xc08f mem 0xfddf8000-0xfddf8fff irq 20 at device 5.1 on pci0
atapci2: [ITHREAD]
ata4: <ATA channel 0> on atapci2
ata4: [ITHREAD]
ata5: <ATA channel 1> on atapci2
ata5: [ITHREAD]
atapci3: <nVidia nForce MCP55 SATA300 controller> port 0xc000-0xc007,0xbc00-0xbc03,0xb880-0xb887,0xb800-0xb803,0xb480-0xb48f mem 0xfddf7000-0xfddf7fff irq 21 at device 5.2 on pci0
atapci3: [ITHREAD]
ata6: <ATA channel 0> on atapci3
ata6: [ITHREAD]
ata7: <ATA channel 1> on atapci3
ata7: [ITHREAD]
pcib1: <ACPI PCI-PCI bridge> at device 6.0 on pci0
pci1: <ACPI PCI bus> on pcib1
vgapci0: <VGA-compatible display> port 0xec00-0xec7f mem 0xf8000000-0xfbffffff,0xfdec0000-0xfdefffff at device 4.0 on pci1
nfe0: <NVIDIA nForce MCP55 Networking Adapter> port 0xb400-0xb407 mem 0xfddf6000-0xfddf6fff,0xfddfa800-0xfddfa8ff,0xfddfa400-0xfddfa40f irq 22 at device 8.0 on pci0
miibus0: <MII bus> on nfe0
e1000phy0: <Marvell 88E1116 Gigabit PHY> PHY 1 on miibus0
e1000phy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX-FDX, auto
nfe0: Ethernet address: 00:24:8c:0c:37:74
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe1: <NVIDIA nForce MCP55 Networking Adapter> port 0xb080-0xb087 mem 0xfddf5000-0xfddf5fff,0xfddfa000-0xfddfa0ff,0xfddf4c00-0xfddf4c0f irq 23 at device 9.0 on pci0
miibus1: <MII bus> on nfe1
e1000phy1: <Marvell 88E1116 Gigabit PHY> PHY 1 on miibus1
e1000phy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX-FDX, auto
nfe1: Ethernet address: 00:24:8c:0c:37:a6
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
pcib2: <ACPI PCI-PCI bridge> at device 10.0 on pci0
pci2: <ACPI PCI bus> on pcib2
pcib3: <ACPI PCI-PCI bridge> at device 13.0 on pci0
pci3: <ACPI PCI bus> on pcib3
pcib4: <ACPI PCI-PCI bridge> at device 14.0 on pci0
pci4: <ACPI PCI bus> on pcib4
pcib5: <ACPI PCI-PCI bridge> at device 15.0 on pci0
pci5: <ACPI PCI bus> on pcib5
arcmsr0: <Areca SATA Host Adapter RAID Controller (RAID6 capable)
> mem 0xfdffe000-0xfdffffff irq 16 at device 0.0 on pci5
ARECA RAID ADAPTER0: Driver Version 1.20.00.15 2007-10-07 
ARECA RAID ADAPTER0: FIRMWARE VERSION V1.46 2008-08-06 
arcmsr0: [ITHREAD]
acpi_button0: <Power Button> on acpi0
fdc0: <floppy drive controller (FDE)> port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on acpi0
fdc0: [FILTER]
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
atkbd0: [ITHREAD]
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: port may not be enabled
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: port may not be enabled
sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
sio0: type 16550A
sio0: [FILTER]
sio1: configured irq 3 not in bitmap of probed irqs 0
sio1: port may not be enabled
sio1: configured irq 3 not in bitmap of probed irqs 0
sio1: port may not be enabled
sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0
sio1: type 16550A
sio1: [FILTER]
cpu0: <ACPI CPU> on acpi0
powernow0: <PowerNow! K8> on cpu0
cpu1: <ACPI CPU> on acpi0
powernow1: <PowerNow! K8> on cpu1
cpu2: <ACPI CPU> on acpi0
powernow2: <PowerNow! K8> on cpu2
cpu3: <ACPI CPU> on acpi0
powernow3: <PowerNow! K8> on cpu3
orm0: <ISA Option ROMs> at iomem 0xc0000-0xc7fff,0xc8000-0xc97ff on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
Timecounters tick every 1.000 msec
ipfw2 (+ipv6) initialized, divert enabled, nat loadable, rule-based forwarding disabled, default to accept, logging limited to 5 packets/entry by default
Waiting 5 seconds for SCSI devices to settle
acd0: DVDR <PIONEER DVD-RW DVR-116D/1.07> at ata0-master UDMA66
(probe16:arcmsr0:0:16:0): inquiry data fails comparison at DV1 step
da0 at arcmsr0 bus 0 target 0 lun 0
da0: <Areca Vol R1 OS R001> Fixed Direct Access SCSI-5 device 
da0: 166.666MB/s transfers (83.333MHz DT, offset 32, 16bit)
da0: Command Queueing Enabled
da0: 238418MB (488281088 512 byte sectors: 255H 63S/T 30394C)
da1 at arcmsr0 bus 0 target 1 lun 0
da1: <Areca Vol R6 Data R001> Fixed Direct Access SCSI-5 device 
da1: 166.666MB/s transfers (83.333MHz DT, offset 32, 16bit)
da1: Command Queueing Enabled
da1: 19073485MB (39062497280 512 byte sectors: 255H 63S/T 2431527C)
SMP: AP CPU #1 Launched!
SMP: AP CPU #2 Launched!
SMP: AP CPU #3 Launched!
Trying to mount root from ufs:/dev/da0s1a
Loading configuration files.
kernel dumps on /dev/da0s1b
Entropy harvesting:
 interrupts
 ethernet
 point_to_point
 kickstart
>Release-Note:
>Audit-Trail:

From: John Kilburg <john@physics.unlv.edu>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/133980: panic: ffs_valloc: dup alloc
Date: Fri, 24 Apr 2009 13:58:03 -0700

 Here is a link to the complete core.txt file with the kernel config
 added to the end:
 
 http://www.physics.unlv.edu/~john/combined_core.txt
 
 							-john

From: John Kilburg <john@physics.unlv.edu>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133980: panic: ffs_valloc: dup alloc 
Date: Fri, 24 Apr 2009 13:54:53 -0700

 I noticed that I did not read the bug report form very well and
 gave the core.txt file in the place of a patch attachment.  There
 is no patch attached to the end of that.
 
 							-john

From: John Kilburg <john@physics.unlv.edu>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133980: panic: ffs_valloc: dup alloc
Date: Fri, 01 May 2009 12:06:27 -0700

 The same panic occurs with RELENG_7/i386.
 
 It also happens more frequently than I originally thought.  It died
 after a few hours with 2 rsync sessions.
 
 							-john

From: John Kilburg <john@physics.unlv.edu>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/133980: panic: ffs_valloc: dup alloc
Date: Thu, 07 May 2009 18:28:38 -0700

 I am guessing now that this is a problem that I've seen mentioned
 in passing as a possibility in a few postings about the maximum
 number of inodes for UFS2.
 
 Using the default settings the filesystem ended up with more than
 2^31 inodes.  I decreased the inode density to about half the
 default (~1.4M inodes) and now things seem to be working perfectly.
 I rsync'd with 3 sessions, did a make buildworld and otherwise
 loaded the thing with no problems at all.
 
 It would be nice if newfs (or something) warned people about the
 effective 2^31 inode limit for ufs2 until the problem is spotted.
 I guess the real fix is to switch to a filesystem that doesn't
 have static inode allocation. :)
 
 							-john
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon May 18 03:09:32 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=133980 

From: Jaakko Heinonen <jh@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133980: [panic] [ffs] panic: ffs_valloc: dup alloc
Date: Tue, 1 Dec 2009 19:01:11 +0200

 Here is a link to Bruce Evans' follow-up which didn't make it to the
 audit-trail:
 
 http://docs.freebsd.org/cgi/mid.cgi?20090508120355.S1497
Responsible-Changed-From-To: freebsd-fs->mckusick 
Responsible-Changed-By: mckusick 
Responsible-Changed-When: Wed Feb 10 00:43:46 UTC 2010 
Responsible-Changed-Why:  
I will take responsibility for this one. 

It will require a change in the kernel to properly handle 
inode numbers as unsigned. 

It will also require a change to newfs to ensure that a 
filesystem allocates no more than 2^32 inodes. 

Stay tuned for these patches. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=133980 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133980: commit references a PR
Date: Wed, 10 Feb 2010 20:10:52 +0000 (UTC)

 Author: mckusick
 Date: Wed Feb 10 20:10:35 2010
 New Revision: 203763
 URL: http://svn.freebsd.org/changeset/base/203763
 
 Log:
   This fix corrects a problem in the file system that treats large
   inode numbers as negative rather than unsigned. For a default
   (16K block) file system, this bug began to show up at a file system
   size above about 16Tb.
   
   To fully handle this problem, newfs must be updated to ensure that
   it will never create a filesystem with more than 2^32 inodes. That
   patch will be forthcoming soon.
   
   Reported by: Scott Burns, John Kilburg, Bruce Evans
   Followup by: Jeff Roberson
   PR:          133980
   MFC after:   2 weeks
 
 Modified:
   head/sys/ufs/ffs/ffs_alloc.c
   head/sys/ufs/ffs/fs.h
 
 Modified: head/sys/ufs/ffs/ffs_alloc.c
 ==============================================================================
 --- head/sys/ufs/ffs/ffs_alloc.c	Wed Feb 10 19:03:48 2010	(r203762)
 +++ head/sys/ufs/ffs/ffs_alloc.c	Wed Feb 10 20:10:35 2010	(r203763)
 @@ -93,24 +93,25 @@ __FBSDID("$FreeBSD$");
  #include <ufs/ffs/fs.h>
  #include <ufs/ffs/ffs_extern.h>
  
 -typedef ufs2_daddr_t allocfcn_t(struct inode *ip, int cg, ufs2_daddr_t bpref,
 +typedef ufs2_daddr_t allocfcn_t(struct inode *ip, u_int cg, ufs2_daddr_t bpref,
  				  int size);
  
 -static ufs2_daddr_t ffs_alloccg(struct inode *, int, ufs2_daddr_t, int);
 +static ufs2_daddr_t ffs_alloccg(struct inode *, u_int, ufs2_daddr_t, int);
  static ufs2_daddr_t
  	      ffs_alloccgblk(struct inode *, struct buf *, ufs2_daddr_t);
  #ifdef INVARIANTS
  static int	ffs_checkblk(struct inode *, ufs2_daddr_t, long);
  #endif
 -static ufs2_daddr_t ffs_clusteralloc(struct inode *, int, ufs2_daddr_t, int);
 +static ufs2_daddr_t ffs_clusteralloc(struct inode *, u_int, ufs2_daddr_t, int);
  static void	ffs_clusteracct(struct ufsmount *, struct fs *, struct cg *,
  		    ufs1_daddr_t, int);
  static ino_t	ffs_dirpref(struct inode *);
 -static ufs2_daddr_t ffs_fragextend(struct inode *, int, ufs2_daddr_t, int, int);
 +static ufs2_daddr_t ffs_fragextend(struct inode *, u_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 ufs2_daddr_t ffs_nodealloccg(struct inode *, int, ufs2_daddr_t, int);
 +		(struct inode *, u_int, ufs2_daddr_t, int, allocfcn_t *);
 +static ufs2_daddr_t ffs_nodealloccg(struct inode *, u_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 *);
 @@ -145,7 +146,7 @@ ffs_alloc(ip, lbn, bpref, size, flags, c
  	struct fs *fs;
  	struct ufsmount *ump;
  	ufs2_daddr_t bno;
 -	int cg, reclaimed;
 +	u_int cg, reclaimed;
  	static struct timeval lastfail;
  	static int curfail;
  	int64_t delta;
 @@ -248,7 +249,8 @@ ffs_realloccg(ip, lbprev, bprev, bpref, 
  	struct fs *fs;
  	struct buf *bp;
  	struct ufsmount *ump;
 -	int cg, request, error, reclaimed;
 +	u_int cg, request, reclaimed;
 +	int error;
  	ufs2_daddr_t bno;
  	static struct timeval lastfail;
  	static int curfail;
 @@ -933,7 +935,8 @@ ffs_valloc(pvp, mode, cred, vpp)
  	struct timespec ts;
  	struct ufsmount *ump;
  	ino_t ino, ipref;
 -	int cg, error, error1;
 +	u_int cg;
 +	int error, error1;
  	static struct timeval lastfail;
  	static int curfail;
  
 @@ -1043,11 +1046,11 @@ ffs_dirpref(pip)
  	struct inode *pip;
  {
  	struct fs *fs;
 -	int cg, prefcg, dirsize, cgsize;
 -	int avgifree, avgbfree, avgndir, curdirsize;
 -	int minifree, minbfree, maxndir;
 -	int mincg, minndir;
 -	int maxcontigdirs;
 +	u_int cg, prefcg, dirsize, cgsize;
 +	u_int avgifree, avgbfree, avgndir, curdirsize;
 +	u_int minifree, minbfree, maxndir;
 +	u_int mincg, minndir;
 +	u_int maxcontigdirs;
  
  	mtx_assert(UFS_MTX(pip->i_ump), MA_OWNED);
  	fs = pip->i_fs;
 @@ -1171,8 +1174,8 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap)
  	ufs1_daddr_t *bap;
  {
  	struct fs *fs;
 -	int cg;
 -	int avgbfree, startcg;
 +	u_int cg;
 +	u_int avgbfree, startcg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  	fs = ip->i_fs;
 @@ -1221,8 +1224,8 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
  	ufs2_daddr_t *bap;
  {
  	struct fs *fs;
 -	int cg;
 -	int avgbfree, startcg;
 +	u_int cg;
 +	u_int avgbfree, startcg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  	fs = ip->i_fs;
 @@ -1275,14 +1278,14 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
  static ufs2_daddr_t
  ffs_hashalloc(ip, cg, pref, size, allocator)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t pref;
  	int size;	/* size for data blocks, mode for inodes */
  	allocfcn_t *allocator;
  {
  	struct fs *fs;
  	ufs2_daddr_t result;
 -	int i, icg = cg;
 +	u_int i, icg = cg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  #ifdef INVARIANTS
 @@ -1333,7 +1336,7 @@ ffs_hashalloc(ip, cg, pref, size, alloca
  static ufs2_daddr_t
  ffs_fragextend(ip, cg, bprev, osize, nsize)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bprev;
  	int osize, nsize;
  {
 @@ -1416,7 +1419,7 @@ fail:
  static ufs2_daddr_t
  ffs_alloccg(ip, cg, bpref, size)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bpref;
  	int size;
  {
 @@ -1586,7 +1589,7 @@ gotit:
  static ufs2_daddr_t
  ffs_clusteralloc(ip, cg, bpref, len)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bpref;
  	int len;
  {
 @@ -1710,7 +1713,7 @@ fail:
  static ufs2_daddr_t
  ffs_nodealloccg(ip, cg, ipref, mode)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t ipref;
  	int mode;
  {
 @@ -1811,7 +1814,7 @@ gotit:
  	bdwrite(bp);
  	if (ibp != NULL)
  		bawrite(ibp);
 -	return (cg * fs->fs_ipg + ipref);
 +	return ((ino_t)(cg * fs->fs_ipg + ipref));
  }
  
  /*
 @@ -1856,7 +1859,8 @@ ffs_blkfree(ump, fs, devvp, bno, size, i
  	struct buf *bp;
  	ufs1_daddr_t fragno, cgbno;
  	ufs2_daddr_t cgblkno;
 -	int i, cg, blk, frags, bbase;
 +	int i, blk, frags, bbase;
 +	u_int cg;
  	u_int8_t *blksfree;
  	struct cdev *dev;
  
 @@ -2054,7 +2058,8 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  	struct cg *cgp;
  	struct buf *bp;
  	ufs2_daddr_t cgbno;
 -	int error, cg;
 +	int error;
 +	u_int cg;
  	u_int8_t *inosused;
  	struct cdev *dev;
  
 @@ -2068,7 +2073,7 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  		dev = devvp->v_rdev;
  		cgbno = fsbtodb(fs, cgtod(fs, cg));
  	}
 -	if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
 +	if (ino >= fs->fs_ipg * fs->fs_ncg)
  		panic("ffs_freefile: range: dev = %s, ino = %lu, fs = %s",
  		    devtoname(dev), (u_long)ino, fs->fs_fsmnt);
  	if ((error = bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp))) {
 @@ -2085,8 +2090,8 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  	inosused = cg_inosused(cgp);
  	ino %= fs->fs_ipg;
  	if (isclr(inosused, ino)) {
 -		printf("dev = %s, ino = %lu, fs = %s\n", devtoname(dev),
 -		    (u_long)ino + cg * fs->fs_ipg, fs->fs_fsmnt);
 +		printf("dev = %s, ino = %u, fs = %s\n", devtoname(dev),
 +		    ino + cg * fs->fs_ipg, fs->fs_fsmnt);
  		if (fs->fs_ronly == 0)
  			panic("ffs_freefile: freeing free inode");
  	}
 @@ -2121,7 +2126,8 @@ ffs_checkfreefile(fs, devvp, ino)
  	struct cg *cgp;
  	struct buf *bp;
  	ufs2_daddr_t cgbno;
 -	int ret, cg;
 +	int ret;
 +	u_int cg;
  	u_int8_t *inosused;
  
  	cg = ino_to_cg(fs, ino);
 @@ -2132,7 +2138,7 @@ ffs_checkfreefile(fs, devvp, ino)
  		/* devvp is a normal disk device */
  		cgbno = fsbtodb(fs, cgtod(fs, cg));
  	}
 -	if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
 +	if (ino >= fs->fs_ipg * fs->fs_ncg)
  		return (1);
  	if (bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp)) {
  		brelse(bp);
 
 Modified: head/sys/ufs/ffs/fs.h
 ==============================================================================
 --- head/sys/ufs/ffs/fs.h	Wed Feb 10 19:03:48 2010	(r203762)
 +++ head/sys/ufs/ffs/fs.h	Wed Feb 10 20:10:35 2010	(r203763)
 @@ -264,7 +264,7 @@ struct fs {
  	int32_t  fs_old_time;		/* last time written */
  	int32_t	 fs_old_size;		/* number of blocks in fs */
  	int32_t	 fs_old_dsize;		/* number of data blocks in fs */
 -	int32_t	 fs_ncg;		/* number of cylinder groups */
 +	u_int32_t fs_ncg;		/* number of cylinder groups */
  	int32_t	 fs_bsize;		/* size of basic blocks in fs */
  	int32_t	 fs_fsize;		/* size of frag blocks in fs */
  	int32_t	 fs_frag;		/* number of frags in a block in fs */
 @@ -304,7 +304,7 @@ struct fs {
  	int32_t  fs_old_spc;		/* sectors per cylinder */
  	int32_t	 fs_old_ncyl;		/* cylinders in filesystem */
  	int32_t	 fs_old_cpg;		/* cylinders per group */
 -	int32_t	 fs_ipg;		/* inodes per group */
 +	u_int32_t fs_ipg;		/* inodes per group */
  	int32_t	 fs_fpg;		/* blocks per group * fs_frag */
  /* this data must be re-computed after crashes */
  	struct	csum fs_old_cstotal;	/* cylinder summary information */
 @@ -335,10 +335,10 @@ struct fs {
  	int64_t	 fs_dsize;		/* number of data blocks in fs */
  	ufs2_daddr_t fs_csaddr;		/* blk addr of cyl grp summary area */
  	int64_t	 fs_pendingblocks;	/* (u) blocks being freed */
 -	int32_t	 fs_pendinginodes;	/* (u) inodes being freed */
 -	int32_t	 fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
 -	int32_t	 fs_avgfilesize;	/* expected average file size */
 -	int32_t	 fs_avgfpdir;		/* expected # of files per directory */
 +	u_int32_t fs_pendinginodes;	/* (u) inodes being freed */
 +	ino_t	 fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
 +	u_int32_t fs_avgfilesize;	/* expected average file size */
 +	u_int32_t fs_avgfpdir;		/* expected # of files per directory */
  	int32_t	 fs_save_cgsize;	/* save real cg size to use fs_bsize */
  	int32_t	 fs_sparecon32[26];	/* reserved for future constants */
  	int32_t  fs_flags;		/* see FS_ flags below */
 @@ -463,26 +463,26 @@ struct cg {
  	int32_t	 cg_firstfield;		/* historic cyl groups linked list */
  	int32_t	 cg_magic;		/* magic number */
  	int32_t  cg_old_time;		/* time last written */
 -	int32_t	 cg_cgx;		/* we are the cgx'th cylinder group */
 +	u_int32_t cg_cgx;		/* we are the cgx'th cylinder group */
  	int16_t	 cg_old_ncyl;		/* number of cyl's this cg */
  	int16_t  cg_old_niblk;		/* number of inode blocks this cg */
 -	int32_t	 cg_ndblk;		/* number of data blocks this cg */
 -	struct	csum cg_cs;		/* cylinder summary information */
 -	int32_t	 cg_rotor;		/* position of last used block */
 -	int32_t	 cg_frotor;		/* position of last used frag */
 -	int32_t	 cg_irotor;		/* position of last used inode */
 -	int32_t	 cg_frsum[MAXFRAG];	/* counts of available frags */
 +	u_int32_t cg_ndblk;		/* number of data blocks this cg */
 +	struct	 csum cg_cs;		/* cylinder summary information */
 +	u_int32_t cg_rotor;		/* position of last used block */
 +	u_int32_t cg_frotor;		/* position of last used frag */
 +	u_int32_t cg_irotor;		/* position of last used inode */
 +	u_int32_t cg_frsum[MAXFRAG];	/* counts of available frags */
  	int32_t	 cg_old_btotoff;	/* (int32) block totals per cylinder */
  	int32_t	 cg_old_boff;		/* (u_int16) free block positions */
 -	int32_t	 cg_iusedoff;		/* (u_int8) used inode map */
 -	int32_t	 cg_freeoff;		/* (u_int8) free block map */
 -	int32_t	 cg_nextfreeoff;	/* (u_int8) next available space */
 -	int32_t	 cg_clustersumoff;	/* (u_int32) counts of avail clusters */
 -	int32_t	 cg_clusteroff;		/* (u_int8) free cluster map */
 -	int32_t	 cg_nclusterblks;	/* number of clusters this cg */
 -	int32_t  cg_niblk;		/* number of inode blocks this cg */
 -	int32_t	 cg_initediblk;		/* last initialized inode */
 -	int32_t	 cg_unrefs;		/* number of unreferenced inodes */
 +	u_int32_t cg_iusedoff;		/* (u_int8) used inode map */
 +	u_int32_t cg_freeoff;		/* (u_int8) free block map */
 +	u_int32_t cg_nextfreeoff;	/* (u_int8) next available space */
 +	u_int32_t cg_clustersumoff;	/* (u_int32) counts of avail clusters */
 +	u_int32_t cg_clusteroff;		/* (u_int8) free cluster map */
 +	u_int32_t cg_nclusterblks;	/* number of clusters this cg */
 +	u_int32_t cg_niblk;		/* number of inode blocks this cg */
 +	u_int32_t cg_initediblk;		/* last initialized inode */
 +	u_int32_t cg_unrefs;		/* number of unreferenced inodes */
  	int32_t	 cg_sparecon32[2];	/* reserved for future use */
  	ufs_time_t cg_time;		/* time last written */
  	int64_t	 cg_sparecon64[3];	/* reserved for future use */
 @@ -529,11 +529,11 @@ struct cg {
   *     inode number to cylinder group number.
   *     inode number to filesystem block address.
   */
 -#define	ino_to_cg(fs, x)	((x) / (fs)->fs_ipg)
 +#define	ino_to_cg(fs, x)	(((ino_t)(x)) / (fs)->fs_ipg)
  #define	ino_to_fsba(fs, x)						\
 -	((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) +			\
 -	    (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
 -#define	ino_to_fsbo(fs, x)	((x) % INOPB(fs))
 +	((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) +		\
 +	    (blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / INOPB(fs))))))
 +#define	ino_to_fsbo(fs, x)	(((ino_t)(x)) % INOPB(fs))
  
  /*
   * Give cylinder group number for a filesystem block.
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133980: commit references a PR
Date: Wed, 10 Feb 2010 20:17:56 +0000 (UTC)

 Author: mckusick
 Date: Wed Feb 10 20:17:46 2010
 New Revision: 203764
 URL: http://svn.freebsd.org/changeset/base/203764
 
 Log:
   Ensure that newfs will never create a filesystem with more than 2^32
   inodes by cutting back on the number of inodes per cylinder group if
   necessary to stay under the limit. For a default (16K block) file
   system, this limit begins to take effect for file systems above 32Tb.
   
   This fix is in addition to -r203763 which corrected a problem in the
   kernel that treated large inode numbers as negative rather than unsigned.
   For a default (16K block) file system, this bug began to show up at a
   file system size above about 16Tb.
   
   Reported by: Scott Burns, John Kilburg, Bruce Evans
   Followup by: Jeff Roberson
   PR:          133980
   MFC after:   2 weeks
 
 Modified:
   head/sbin/newfs/mkfs.c
   head/sbin/newfs/newfs.c
   head/sbin/newfs/newfs.h
 
 Modified: head/sbin/newfs/mkfs.c
 ==============================================================================
 --- head/sbin/newfs/mkfs.c	Wed Feb 10 20:10:35 2010	(r203763)
 +++ head/sbin/newfs/mkfs.c	Wed Feb 10 20:17:46 2010	(r203764)
 @@ -118,6 +118,8 @@ mkfs(struct partition *pp, char *fsys)
  	time_t utime;
  	quad_t sizepb;
  	int width;
 +	ino_t maxinum;
 +	int minfragsperinode;	/* minimum ratio of frags to inodes */
  	char tmpbuf[100];	/* XXX this will break in about 2,500 years */
  	union {
  		struct fs fdummy;
 @@ -170,6 +172,8 @@ mkfs(struct partition *pp, char *fsys)
  	if (sblock.fs_avgfpdir <= 0)
  		printf("illegal expected number of files per directory %d\n",
  		    sblock.fs_avgfpdir), exit(15);
 +
 +restart:
  	/*
  	 * collect and verify the block and fragment sizes
  	 */
 @@ -216,6 +220,8 @@ mkfs(struct partition *pp, char *fsys)
  		    sblock.fs_fsize, MAXFRAG, sblock.fs_bsize / MAXFRAG);
  		sblock.fs_fsize = sblock.fs_bsize / MAXFRAG;
  	}
 +	if (maxbsize == 0)
 +		maxbsize = bsize;
  	if (maxbsize < bsize || !POWEROF2(maxbsize)) {
  		sblock.fs_maxbsize = sblock.fs_bsize;
  		printf("Extent size set to %d\n", sblock.fs_maxbsize);
 @@ -225,6 +231,14 @@ mkfs(struct partition *pp, char *fsys)
  	} else {
  		sblock.fs_maxbsize = maxbsize;
  	}
 +	/*
 +	 * Maxcontig sets the default for the maximum number of blocks
 +	 * that may be allocated sequentially. With file system clustering
 +	 * it is possible to allocate contiguous blocks up to the maximum
 +	 * transfer size permitted by the controller or buffering.
 +	 */
 +	if (maxcontig == 0)
 +		maxcontig = MAX(1, MAXPHYS / bsize);
  	sblock.fs_maxcontig = maxcontig;
  	if (sblock.fs_maxcontig < sblock.fs_maxbsize / sblock.fs_bsize) {
  		sblock.fs_maxcontig = sblock.fs_maxbsize / sblock.fs_bsize;
 @@ -315,9 +329,26 @@ mkfs(struct partition *pp, char *fsys)
  	 * can put into each cylinder group. If this is too big, we reduce
  	 * the density until it fits.
  	 */
 +	maxinum = (((int64_t)(1)) << 32) - INOPB(&sblock);
 +	minfragsperinode = 1 + fssize / maxinum;
 +	if (density == 0) {
 +		density = MAX(NFPI, minfragsperinode) * fsize;
 +	} else if (density < minfragsperinode * fsize) {
 +		origdensity = density;
 +		density = minfragsperinode * fsize;
 +		fprintf(stderr, "density increased from %d to %d\n",
 +		    origdensity, density);
 +	}
  	origdensity = density;
  	for (;;) {
  		fragsperinode = MAX(numfrags(&sblock, density), 1);
 +		if (fragsperinode < minfragsperinode) {
 +			bsize <<= 1;
 +			fsize <<= 1;
 +			printf("Block size too small for a file system %s %d\n",
 +			     "of this size. Increasing blocksize to", bsize);
 +			goto restart;
 +		}
  		minfpg = fragsperinode * INOPB(&sblock);
  		if (minfpg > sblock.fs_size)
  			minfpg = sblock.fs_size;
 @@ -406,7 +437,10 @@ mkfs(struct partition *pp, char *fsys)
  	if (sblock.fs_sbsize > SBLOCKSIZE)
  		sblock.fs_sbsize = SBLOCKSIZE;
  	sblock.fs_minfree = minfree;
 -	sblock.fs_maxbpg = maxbpg;
 +	if (maxbpg == 0)
 +		sblock.fs_maxbpg = MAXBLKPG(sblock.fs_bsize);
 +	else
 +		sblock.fs_maxbpg = maxbpg;
  	sblock.fs_optim = opt;
  	sblock.fs_cgrotor = 0;
  	sblock.fs_pendingblocks = 0;
 
 Modified: head/sbin/newfs/newfs.c
 ==============================================================================
 --- head/sbin/newfs/newfs.c	Wed Feb 10 20:10:35 2010	(r203763)
 +++ head/sbin/newfs/newfs.c	Wed Feb 10 20:17:46 2010	(r203764)
 @@ -79,38 +79,6 @@ __FBSDID("$FreeBSD$");
  
  #include "newfs.h"
  
 -/*
 - * The following two constants set the default block and fragment sizes.
 - * Both constants must be a power of 2 and meet the following constraints:
 - *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
 - *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
 - *	DESBLKSIZE / DESFRAGSIZE <= 8
 - */
 -#define	DFL_FRAGSIZE	2048
 -#define	DFL_BLKSIZE	16384
 -
 -/*
 - * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual
 - * number used depends upon how much information can be stored
 - * in a cylinder group map which must fit in a single file system
 - * block. The default is to use as many as possible blocks per group.
 - */
 -#define	MAXBLKSPERCG	0x7fffffff	/* desired fs_fpg ("infinity") */
 -
 -/*
 - * MAXBLKPG determines the maximum number of data blocks which are
 - * placed in a single cylinder group. The default is one indirect
 - * block worth of data blocks.
 - */
 -#define MAXBLKPG(bsize)	((bsize) / sizeof(ufs2_daddr_t))
 -
 -/*
 - * Each file system has a number of inodes statically allocated.
 - * We allocate one inode slot per NFPI fragments, expecting this
 - * to be far more than we will ever need.
 - */
 -#define	NFPI		4
 -
  int	Eflag;			/* Erase previous disk contents */
  int	Lflag;			/* add a volume label */
  int	Nflag;			/* run without writing file system */
 @@ -387,25 +355,11 @@ main(int argc, char *argv[])
  		fsize = MAX(DFL_FRAGSIZE, sectorsize);
  	if (bsize <= 0)
  		bsize = MIN(DFL_BLKSIZE, 8 * fsize);
 -	if (maxbsize == 0)
 -		maxbsize = bsize;
 -	/*
 -	 * Maxcontig sets the default for the maximum number of blocks
 -	 * that may be allocated sequentially. With file system clustering
 -	 * it is possible to allocate contiguous blocks up to the maximum
 -	 * transfer size permitted by the controller or buffering.
 -	 */
 -	if (maxcontig == 0)
 -		maxcontig = MAX(1, MAXPHYS / bsize);
 -	if (density == 0)
 -		density = NFPI * fsize;
  	if (minfree < MINFREE && opt != FS_OPTSPACE) {
  		fprintf(stderr, "Warning: changing optimization to space ");
  		fprintf(stderr, "because minfree is less than %d%%\n", MINFREE);
  		opt = FS_OPTSPACE;
  	}
 -	if (maxbpg == 0)
 -		maxbpg = MAXBLKPG(bsize);
  	realsectorsize = sectorsize;
  	if (sectorsize != DEV_BSIZE) {		/* XXX */
  		int secperblk = sectorsize / DEV_BSIZE;
 
 Modified: head/sbin/newfs/newfs.h
 ==============================================================================
 --- head/sbin/newfs/newfs.h	Wed Feb 10 20:10:35 2010	(r203763)
 +++ head/sbin/newfs/newfs.h	Wed Feb 10 20:17:46 2010	(r203764)
 @@ -41,6 +41,38 @@
  #include <libufs.h>
  
  /*
 + * The following two constants set the default block and fragment sizes.
 + * Both constants must be a power of 2 and meet the following constraints:
 + *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
 + *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
 + *	DESBLKSIZE / DESFRAGSIZE <= 8
 + */
 +#define	DFL_FRAGSIZE	2048
 +#define	DFL_BLKSIZE	16384
 +
 +/*
 + * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual
 + * number used depends upon how much information can be stored
 + * in a cylinder group map which must fit in a single file system
 + * block. The default is to use as many as possible blocks per group.
 + */
 +#define	MAXBLKSPERCG	0x7fffffff	/* desired fs_fpg ("infinity") */
 +
 +/*
 + * MAXBLKPG determines the maximum number of data blocks which are
 + * placed in a single cylinder group. The default is one indirect
 + * block worth of data blocks.
 + */
 +#define MAXBLKPG(bsize)	((bsize) / sizeof(ufs2_daddr_t))
 +
 +/*
 + * Each file system has a number of inodes statically allocated.
 + * We allocate one inode slot per NFPI fragments, expecting this
 + * to be far more than we will ever need.
 + */
 +#define	NFPI		4
 +
 +/*
   * variables set up by front end.
   */
  extern int	Eflag;		/* Erase previous disk contents */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: mckusick 
State-Changed-When: Wed Feb 10 21:05:07 UTC 2010 
State-Changed-Why:  
Update to reflect that a fix is in head. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=133980 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133980: commit references a PR
Date: Fri, 26 Feb 2010 21:49:28 +0000 (UTC)

 Author: mckusick
 Date: Fri Feb 26 21:49:11 2010
 New Revision: 204375
 URL: http://svn.freebsd.org/changeset/base/204375
 
 Log:
   MFC of 203763, 203764, 203768, 203769, 203770, 203782, and 203784.
   
   These fixes correct a problem in the file system that treats large
   inode numbers as negative rather than unsigned. For a default
   (16K block) file system, this bug began to show up at a file system
   size above about 16Tb.
   
   These fixes also update newfs to ensure that it will never create a
   filesystem with more than 2^32 inodes.
   
   They also update libufs, tunefs, and growfs so that they properly
   handle inode numbers as unsigned.
   
   Reported by: Scott Burns, John Kilburg, and Bruce Evans
   Followup by: Jeff Roberson
   PR:          133980
 
 Modified:
   stable/8/lib/libufs/cgroup.c
   stable/8/lib/libufs/sblock.c
   stable/8/sbin/growfs/growfs.c
   stable/8/sbin/newfs/mkfs.c
   stable/8/sbin/newfs/newfs.c
   stable/8/sbin/newfs/newfs.h
   stable/8/sbin/tunefs/tunefs.c
   stable/8/sys/ufs/ffs/ffs_alloc.c
   stable/8/sys/ufs/ffs/fs.h
 Directory Properties:
   stable/8/lib/libufs/   (props changed)
   stable/8/sbin/growfs/   (props changed)
   stable/8/sbin/newfs/   (props changed)
   stable/8/sbin/tunefs/   (props changed)
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/xen/xenpci/   (props changed)
   stable/8/sys/netinet/   (props changed)
 
 Modified: stable/8/lib/libufs/cgroup.c
 ==============================================================================
 --- stable/8/lib/libufs/cgroup.c	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/lib/libufs/cgroup.c	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -59,7 +59,7 @@ cgread1(struct uufsd *disk, int c)
  
  	fs = &disk->d_fs;
  
 -	if (c >= fs->fs_ncg) {
 +	if ((unsigned)c >= fs->fs_ncg) {
  		return (0);
  	}
  	ccg = fsbtodb(fs, cgtod(fs, c)) * disk->d_bsize;
 
 Modified: stable/8/lib/libufs/sblock.c
 ==============================================================================
 --- stable/8/lib/libufs/sblock.c	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/lib/libufs/sblock.c	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -93,7 +93,7 @@ int
  sbwrite(struct uufsd *disk, int all)
  {
  	struct fs *fs;
 -	int i;
 +	unsigned i;
  
  	ERROR(disk, NULL);
  
 
 Modified: stable/8/sbin/growfs/growfs.c
 ==============================================================================
 --- stable/8/sbin/growfs/growfs.c	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/sbin/growfs/growfs.c	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -174,10 +174,9 @@ static void
  growfs(int fsi, int fso, unsigned int Nflag)
  {
  	DBG_FUNC("growfs")
 -	int	i;
 -	int	cylno, j;
  	time_t	utime;
 -	int	width;
 +	uint	cylno;
 +	int	i, j, width;
  	char	tmpbuf[100];
  #ifdef FSIRAND
  	static int	randinit=0;
 @@ -373,10 +372,11 @@ initcg(int cylno, time_t utime, int fso,
  {
  	DBG_FUNC("initcg")
  	static void *iobuf;
 -	long d, dlower, dupper, blkno, start;
 +	long blkno, start;
  	ufs2_daddr_t i, cbase, dmax;
  	struct ufs1_dinode *dp1;
  	struct csum *cs;
 +	uint d, dupper, dlower;
  
  	if (iobuf == NULL && (iobuf = malloc(sblock.fs_bsize)) == NULL) {
  		errx(37, "panic: cannot allocate I/O buffer");
 @@ -431,7 +431,7 @@ initcg(int cylno, time_t utime, int fso,
  		acg.cg_nextfreeoff = acg.cg_clusteroff +
  		    howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT);
  	}
 -	if (acg.cg_nextfreeoff > sblock.fs_cgsize) {
 +	if (acg.cg_nextfreeoff > (unsigned)sblock.fs_cgsize) {
  		/*
  		 * This should never happen as we would have had that panic
  		 * already on file system creation
 @@ -746,7 +746,7 @@ updjcg(int cylno, time_t utime, int fsi,
  	 * needed, update the free space in the superblock.
  	 */
  	acg.cg_time = utime;
 -	if (cylno == sblock.fs_ncg - 1) {
 +	if ((unsigned)cylno == sblock.fs_ncg - 1) {
  		/*
  		 * This is still the last cylinder group.
  		 */
 @@ -940,8 +940,8 @@ updcsloc(time_t utime, int fsi, int fso,
  	int	ocscg, ncscg;
  	int	blocks;
  	ufs2_daddr_t	cbase, dupper, odupper, d, f, g;
 -	int	ind;
 -	int	cylno, inc;
 +	int	ind, inc;
 +	uint	cylno;
  	struct gfs_bpp	*bp;
  	int	i, l;
  	int	lcs=0;
 
 Modified: stable/8/sbin/newfs/mkfs.c
 ==============================================================================
 --- stable/8/sbin/newfs/mkfs.c	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/sbin/newfs/mkfs.c	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -114,10 +114,13 @@ void
  mkfs(struct partition *pp, char *fsys)
  {
  	int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg;
 -	long i, j, cylno, csfrags;
 +	long i, j, csfrags;
 +	uint cg;
  	time_t utime;
  	quad_t sizepb;
  	int width;
 +	ino_t maxinum;
 +	int minfragsperinode;	/* minimum ratio of frags to inodes */
  	char tmpbuf[100];	/* XXX this will break in about 2,500 years */
  	union {
  		struct fs fdummy;
 @@ -170,6 +173,8 @@ mkfs(struct partition *pp, char *fsys)
  	if (sblock.fs_avgfpdir <= 0)
  		printf("illegal expected number of files per directory %d\n",
  		    sblock.fs_avgfpdir), exit(15);
 +
 +restart:
  	/*
  	 * collect and verify the block and fragment sizes
  	 */
 @@ -216,6 +221,8 @@ mkfs(struct partition *pp, char *fsys)
  		    sblock.fs_fsize, MAXFRAG, sblock.fs_bsize / MAXFRAG);
  		sblock.fs_fsize = sblock.fs_bsize / MAXFRAG;
  	}
 +	if (maxbsize == 0)
 +		maxbsize = bsize;
  	if (maxbsize < bsize || !POWEROF2(maxbsize)) {
  		sblock.fs_maxbsize = sblock.fs_bsize;
  		printf("Extent size set to %d\n", sblock.fs_maxbsize);
 @@ -225,6 +232,14 @@ mkfs(struct partition *pp, char *fsys)
  	} else {
  		sblock.fs_maxbsize = maxbsize;
  	}
 +	/*
 +	 * Maxcontig sets the default for the maximum number of blocks
 +	 * that may be allocated sequentially. With file system clustering
 +	 * it is possible to allocate contiguous blocks up to the maximum
 +	 * transfer size permitted by the controller or buffering.
 +	 */
 +	if (maxcontig == 0)
 +		maxcontig = MAX(1, MAXPHYS / bsize);
  	sblock.fs_maxcontig = maxcontig;
  	if (sblock.fs_maxcontig < sblock.fs_maxbsize / sblock.fs_bsize) {
  		sblock.fs_maxcontig = sblock.fs_maxbsize / sblock.fs_bsize;
 @@ -315,9 +330,26 @@ mkfs(struct partition *pp, char *fsys)
  	 * can put into each cylinder group. If this is too big, we reduce
  	 * the density until it fits.
  	 */
 +	maxinum = (((int64_t)(1)) << 32) - INOPB(&sblock);
 +	minfragsperinode = 1 + fssize / maxinum;
 +	if (density == 0) {
 +		density = MAX(NFPI, minfragsperinode) * fsize;
 +	} else if (density < minfragsperinode * fsize) {
 +		origdensity = density;
 +		density = minfragsperinode * fsize;
 +		fprintf(stderr, "density increased from %d to %d\n",
 +		    origdensity, density);
 +	}
  	origdensity = density;
  	for (;;) {
  		fragsperinode = MAX(numfrags(&sblock, density), 1);
 +		if (fragsperinode < minfragsperinode) {
 +			bsize <<= 1;
 +			fsize <<= 1;
 +			printf("Block size too small for a file system %s %d\n",
 +			     "of this size. Increasing blocksize to", bsize);
 +			goto restart;
 +		}
  		minfpg = fragsperinode * INOPB(&sblock);
  		if (minfpg > sblock.fs_size)
  			minfpg = sblock.fs_size;
 @@ -406,7 +438,10 @@ mkfs(struct partition *pp, char *fsys)
  	if (sblock.fs_sbsize > SBLOCKSIZE)
  		sblock.fs_sbsize = SBLOCKSIZE;
  	sblock.fs_minfree = minfree;
 -	sblock.fs_maxbpg = maxbpg;
 +	if (maxbpg == 0)
 +		sblock.fs_maxbpg = MAXBLKPG(sblock.fs_bsize);
 +	else
 +		sblock.fs_maxbpg = maxbpg;
  	sblock.fs_optim = opt;
  	sblock.fs_cgrotor = 0;
  	sblock.fs_pendingblocks = 0;
 @@ -476,9 +511,9 @@ mkfs(struct partition *pp, char *fsys)
  			fsdummy.fs_magic = 0;
  			bwrite(&disk, part_ofs + SBLOCK_UFS1 / disk.d_bsize,
  			    chdummy, SBLOCKSIZE);
 -			for (i = 0; i < fsdummy.fs_ncg; i++)
 +			for (cg = 0; cg < fsdummy.fs_ncg; cg++)
  				bwrite(&disk, part_ofs + fsbtodb(&fsdummy,
 -				    cgsblock(&fsdummy, i)), chdummy, SBLOCKSIZE);
 +				  cgsblock(&fsdummy, cg)), chdummy, SBLOCKSIZE);
  		}
  	}
  	if (!Nflag)
 @@ -516,11 +551,11 @@ mkfs(struct partition *pp, char *fsys)
  	 * writing out in each cylinder group.
  	 */
  	bcopy((char *)&sblock, iobuf, SBLOCKSIZE);
 -	for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
 -		initcg(cylno, utime);
 +	for (cg = 0; cg < sblock.fs_ncg; cg++) {
 +		initcg(cg, utime);
  		j = snprintf(tmpbuf, sizeof(tmpbuf), " %jd%s",
 -		    (intmax_t)fsbtodb(&sblock, cgsblock(&sblock, cylno)),
 -		    cylno < (sblock.fs_ncg-1) ? "," : "");
 +		    (intmax_t)fsbtodb(&sblock, cgsblock(&sblock, cg)),
 +		    cg < (sblock.fs_ncg-1) ? "," : "");
  		if (j < 0)
  			tmpbuf[j = 0] = '\0';
  		if (i + j >= width) {
 @@ -574,7 +609,8 @@ mkfs(struct partition *pp, char *fsys)
  void
  initcg(int cylno, time_t utime)
  {
 -	long i, j, d, dlower, dupper, blkno, start;
 +	long blkno, start;
 +	uint i, j, d, dlower, dupper;
  	ufs2_daddr_t cbase, dmax;
  	struct ufs1_dinode *dp1;
  	struct ufs2_dinode *dp2;
 @@ -631,7 +667,7 @@ initcg(int cylno, time_t utime)
  		acg.cg_nextfreeoff = acg.cg_clusteroff +
  		    howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT);
  	}
 -	if (acg.cg_nextfreeoff > sblock.fs_cgsize) {
 +	if (acg.cg_nextfreeoff > (unsigned)sblock.fs_cgsize) {
  		printf("Panic: cylinder group too big\n");
  		exit(37);
  	}
 @@ -880,7 +916,8 @@ makedir(struct direct *protodir, int ent
  ufs2_daddr_t
  alloc(int size, int mode)
  {
 -	int i, d, blkno, frag;
 +	int i, blkno, frag;
 +	uint d;
  
  	bread(&disk, part_ofs + fsbtodb(&sblock, cgtod(&sblock, 0)), (char *)&acg,
  	    sblock.fs_cgsize);
 
 Modified: stable/8/sbin/newfs/newfs.c
 ==============================================================================
 --- stable/8/sbin/newfs/newfs.c	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/sbin/newfs/newfs.c	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -79,38 +79,6 @@ __FBSDID("$FreeBSD$");
  
  #include "newfs.h"
  
 -/*
 - * The following two constants set the default block and fragment sizes.
 - * Both constants must be a power of 2 and meet the following constraints:
 - *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
 - *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
 - *	DESBLKSIZE / DESFRAGSIZE <= 8
 - */
 -#define	DFL_FRAGSIZE	2048
 -#define	DFL_BLKSIZE	16384
 -
 -/*
 - * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual
 - * number used depends upon how much information can be stored
 - * in a cylinder group map which must fit in a single file system
 - * block. The default is to use as many as possible blocks per group.
 - */
 -#define	MAXBLKSPERCG	0x7fffffff	/* desired fs_fpg ("infinity") */
 -
 -/*
 - * MAXBLKPG determines the maximum number of data blocks which are
 - * placed in a single cylinder group. The default is one indirect
 - * block worth of data blocks.
 - */
 -#define MAXBLKPG(bsize)	((bsize) / sizeof(ufs2_daddr_t))
 -
 -/*
 - * Each file system has a number of inodes statically allocated.
 - * We allocate one inode slot per NFPI fragments, expecting this
 - * to be far more than we will ever need.
 - */
 -#define	NFPI		4
 -
  int	Eflag;			/* Erase previous disk contents */
  int	Lflag;			/* add a volume label */
  int	Nflag;			/* run without writing file system */
 @@ -387,25 +355,11 @@ main(int argc, char *argv[])
  		fsize = MAX(DFL_FRAGSIZE, sectorsize);
  	if (bsize <= 0)
  		bsize = MIN(DFL_BLKSIZE, 8 * fsize);
 -	if (maxbsize == 0)
 -		maxbsize = bsize;
 -	/*
 -	 * Maxcontig sets the default for the maximum number of blocks
 -	 * that may be allocated sequentially. With file system clustering
 -	 * it is possible to allocate contiguous blocks up to the maximum
 -	 * transfer size permitted by the controller or buffering.
 -	 */
 -	if (maxcontig == 0)
 -		maxcontig = MAX(1, MAXPHYS / bsize);
 -	if (density == 0)
 -		density = NFPI * fsize;
  	if (minfree < MINFREE && opt != FS_OPTSPACE) {
  		fprintf(stderr, "Warning: changing optimization to space ");
  		fprintf(stderr, "because minfree is less than %d%%\n", MINFREE);
  		opt = FS_OPTSPACE;
  	}
 -	if (maxbpg == 0)
 -		maxbpg = MAXBLKPG(bsize);
  	realsectorsize = sectorsize;
  	if (sectorsize != DEV_BSIZE) {		/* XXX */
  		int secperblk = sectorsize / DEV_BSIZE;
 
 Modified: stable/8/sbin/newfs/newfs.h
 ==============================================================================
 --- stable/8/sbin/newfs/newfs.h	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/sbin/newfs/newfs.h	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -41,6 +41,38 @@
  #include <libufs.h>
  
  /*
 + * The following two constants set the default block and fragment sizes.
 + * Both constants must be a power of 2 and meet the following constraints:
 + *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
 + *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
 + *	DESBLKSIZE / DESFRAGSIZE <= 8
 + */
 +#define	DFL_FRAGSIZE	2048
 +#define	DFL_BLKSIZE	16384
 +
 +/*
 + * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual
 + * number used depends upon how much information can be stored
 + * in a cylinder group map which must fit in a single file system
 + * block. The default is to use as many as possible blocks per group.
 + */
 +#define	MAXBLKSPERCG	0x7fffffff	/* desired fs_fpg ("infinity") */
 +
 +/*
 + * MAXBLKPG determines the maximum number of data blocks which are
 + * placed in a single cylinder group. The default is one indirect
 + * block worth of data blocks.
 + */
 +#define MAXBLKPG(bsize)	((bsize) / sizeof(ufs2_daddr_t))
 +
 +/*
 + * Each file system has a number of inodes statically allocated.
 + * We allocate one inode slot per NFPI fragments, expecting this
 + * to be far more than we will ever need.
 + */
 +#define	NFPI		4
 +
 +/*
   * variables set up by front end.
   */
  extern int	Eflag;		/* Erase previous disk contents */
 
 Modified: stable/8/sbin/tunefs/tunefs.c
 ==============================================================================
 --- stable/8/sbin/tunefs/tunefs.c	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/sbin/tunefs/tunefs.c	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -286,7 +286,7 @@ main(int argc, char *argv[])
  	}
  	if (fflag) {
  		name = "average file size";
 -		if (sblock.fs_avgfilesize == fvalue) {
 +		if (sblock.fs_avgfilesize == (unsigned)fvalue) {
  			warnx("%s remains unchanged as %d", name, fvalue);
  		}
  		else {
 @@ -389,7 +389,7 @@ main(int argc, char *argv[])
  	}
  	if (sflag) {
  		name = "expected number of files per directory";
 -		if (sblock.fs_avgfpdir == svalue) {
 +		if (sblock.fs_avgfpdir == (unsigned)svalue) {
  			warnx("%s remains unchanged as %d", name, svalue);
  		}
  		else {
 
 Modified: stable/8/sys/ufs/ffs/ffs_alloc.c
 ==============================================================================
 --- stable/8/sys/ufs/ffs/ffs_alloc.c	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/sys/ufs/ffs/ffs_alloc.c	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -88,24 +88,25 @@ __FBSDID("$FreeBSD$");
  #include <ufs/ffs/fs.h>
  #include <ufs/ffs/ffs_extern.h>
  
 -typedef ufs2_daddr_t allocfcn_t(struct inode *ip, int cg, ufs2_daddr_t bpref,
 +typedef ufs2_daddr_t allocfcn_t(struct inode *ip, u_int cg, ufs2_daddr_t bpref,
  				  int size);
  
 -static ufs2_daddr_t ffs_alloccg(struct inode *, int, ufs2_daddr_t, int);
 +static ufs2_daddr_t ffs_alloccg(struct inode *, u_int, ufs2_daddr_t, int);
  static ufs2_daddr_t
  	      ffs_alloccgblk(struct inode *, struct buf *, ufs2_daddr_t);
  #ifdef INVARIANTS
  static int	ffs_checkblk(struct inode *, ufs2_daddr_t, long);
  #endif
 -static ufs2_daddr_t ffs_clusteralloc(struct inode *, int, ufs2_daddr_t, int);
 +static ufs2_daddr_t ffs_clusteralloc(struct inode *, u_int, ufs2_daddr_t, int);
  static void	ffs_clusteracct(struct ufsmount *, struct fs *, struct cg *,
  		    ufs1_daddr_t, int);
  static ino_t	ffs_dirpref(struct inode *);
 -static ufs2_daddr_t ffs_fragextend(struct inode *, int, ufs2_daddr_t, int, int);
 +static ufs2_daddr_t ffs_fragextend(struct inode *, u_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 ufs2_daddr_t ffs_nodealloccg(struct inode *, int, ufs2_daddr_t, int);
 +		(struct inode *, u_int, ufs2_daddr_t, int, allocfcn_t *);
 +static ufs2_daddr_t ffs_nodealloccg(struct inode *, u_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 *);
 @@ -140,7 +141,7 @@ ffs_alloc(ip, lbn, bpref, size, flags, c
  	struct fs *fs;
  	struct ufsmount *ump;
  	ufs2_daddr_t bno;
 -	int cg, reclaimed;
 +	u_int cg, reclaimed;
  	static struct timeval lastfail;
  	static int curfail;
  	int64_t delta;
 @@ -243,7 +244,8 @@ ffs_realloccg(ip, lbprev, bprev, bpref, 
  	struct fs *fs;
  	struct buf *bp;
  	struct ufsmount *ump;
 -	int cg, request, error, reclaimed;
 +	u_int cg, request, reclaimed;
 +	int error;
  	ufs2_daddr_t bno;
  	static struct timeval lastfail;
  	static int curfail;
 @@ -930,7 +932,8 @@ ffs_valloc(pvp, mode, cred, vpp)
  	struct timespec ts;
  	struct ufsmount *ump;
  	ino_t ino, ipref;
 -	int cg, error, error1;
 +	u_int cg;
 +	int error, error1;
  	static struct timeval lastfail;
  	static int curfail;
  
 @@ -1040,11 +1043,11 @@ ffs_dirpref(pip)
  	struct inode *pip;
  {
  	struct fs *fs;
 -	int cg, prefcg, dirsize, cgsize;
 -	int avgifree, avgbfree, avgndir, curdirsize;
 -	int minifree, minbfree, maxndir;
 -	int mincg, minndir;
 -	int maxcontigdirs;
 +	u_int cg, prefcg, dirsize, cgsize;
 +	u_int avgifree, avgbfree, avgndir, curdirsize;
 +	u_int minifree, minbfree, maxndir;
 +	u_int mincg, minndir;
 +	u_int maxcontigdirs;
  
  	mtx_assert(UFS_MTX(pip->i_ump), MA_OWNED);
  	fs = pip->i_fs;
 @@ -1168,8 +1171,8 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap)
  	ufs1_daddr_t *bap;
  {
  	struct fs *fs;
 -	int cg;
 -	int avgbfree, startcg;
 +	u_int cg;
 +	u_int avgbfree, startcg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  	fs = ip->i_fs;
 @@ -1218,8 +1221,8 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
  	ufs2_daddr_t *bap;
  {
  	struct fs *fs;
 -	int cg;
 -	int avgbfree, startcg;
 +	u_int cg;
 +	u_int avgbfree, startcg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  	fs = ip->i_fs;
 @@ -1272,14 +1275,14 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
  static ufs2_daddr_t
  ffs_hashalloc(ip, cg, pref, size, allocator)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t pref;
  	int size;	/* size for data blocks, mode for inodes */
  	allocfcn_t *allocator;
  {
  	struct fs *fs;
  	ufs2_daddr_t result;
 -	int i, icg = cg;
 +	u_int i, icg = cg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  #ifdef INVARIANTS
 @@ -1330,7 +1333,7 @@ ffs_hashalloc(ip, cg, pref, size, alloca
  static ufs2_daddr_t
  ffs_fragextend(ip, cg, bprev, osize, nsize)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bprev;
  	int osize, nsize;
  {
 @@ -1413,7 +1416,7 @@ fail:
  static ufs2_daddr_t
  ffs_alloccg(ip, cg, bpref, size)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bpref;
  	int size;
  {
 @@ -1583,7 +1586,7 @@ gotit:
  static ufs2_daddr_t
  ffs_clusteralloc(ip, cg, bpref, len)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bpref;
  	int len;
  {
 @@ -1707,7 +1710,7 @@ fail:
  static ufs2_daddr_t
  ffs_nodealloccg(ip, cg, ipref, mode)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t ipref;
  	int mode;
  {
 @@ -1808,7 +1811,7 @@ gotit:
  	bdwrite(bp);
  	if (ibp != NULL)
  		bawrite(ibp);
 -	return (cg * fs->fs_ipg + ipref);
 +	return ((ino_t)(cg * fs->fs_ipg + ipref));
  }
  
  /*
 @@ -1853,7 +1856,8 @@ ffs_blkfree(ump, fs, devvp, bno, size, i
  	struct buf *bp;
  	ufs1_daddr_t fragno, cgbno;
  	ufs2_daddr_t cgblkno;
 -	int i, cg, blk, frags, bbase;
 +	int i, blk, frags, bbase;
 +	u_int cg;
  	u_int8_t *blksfree;
  	struct cdev *dev;
  
 @@ -2051,7 +2055,8 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  	struct cg *cgp;
  	struct buf *bp;
  	ufs2_daddr_t cgbno;
 -	int error, cg;
 +	int error;
 +	u_int cg;
  	u_int8_t *inosused;
  	struct cdev *dev;
  
 @@ -2065,7 +2070,7 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  		dev = devvp->v_rdev;
  		cgbno = fsbtodb(fs, cgtod(fs, cg));
  	}
 -	if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
 +	if (ino >= fs->fs_ipg * fs->fs_ncg)
  		panic("ffs_freefile: range: dev = %s, ino = %lu, fs = %s",
  		    devtoname(dev), (u_long)ino, fs->fs_fsmnt);
  	if ((error = bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp))) {
 @@ -2082,8 +2087,8 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  	inosused = cg_inosused(cgp);
  	ino %= fs->fs_ipg;
  	if (isclr(inosused, ino)) {
 -		printf("dev = %s, ino = %lu, fs = %s\n", devtoname(dev),
 -		    (u_long)ino + cg * fs->fs_ipg, fs->fs_fsmnt);
 +		printf("dev = %s, ino = %u, fs = %s\n", devtoname(dev),
 +		    ino + cg * fs->fs_ipg, fs->fs_fsmnt);
  		if (fs->fs_ronly == 0)
  			panic("ffs_freefile: freeing free inode");
  	}
 @@ -2118,7 +2123,8 @@ ffs_checkfreefile(fs, devvp, ino)
  	struct cg *cgp;
  	struct buf *bp;
  	ufs2_daddr_t cgbno;
 -	int ret, cg;
 +	int ret;
 +	u_int cg;
  	u_int8_t *inosused;
  
  	cg = ino_to_cg(fs, ino);
 @@ -2129,7 +2135,7 @@ ffs_checkfreefile(fs, devvp, ino)
  		/* devvp is a normal disk device */
  		cgbno = fsbtodb(fs, cgtod(fs, cg));
  	}
 -	if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
 +	if (ino >= fs->fs_ipg * fs->fs_ncg)
  		return (1);
  	if (bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp)) {
  		brelse(bp);
 
 Modified: stable/8/sys/ufs/ffs/fs.h
 ==============================================================================
 --- stable/8/sys/ufs/ffs/fs.h	Fri Feb 26 21:26:07 2010	(r204374)
 +++ stable/8/sys/ufs/ffs/fs.h	Fri Feb 26 21:49:11 2010	(r204375)
 @@ -261,7 +261,7 @@ struct fs {
  	int32_t  fs_old_time;		/* last time written */
  	int32_t	 fs_old_size;		/* number of blocks in fs */
  	int32_t	 fs_old_dsize;		/* number of data blocks in fs */
 -	int32_t	 fs_ncg;		/* number of cylinder groups */
 +	u_int32_t fs_ncg;		/* number of cylinder groups */
  	int32_t	 fs_bsize;		/* size of basic blocks in fs */
  	int32_t	 fs_fsize;		/* size of frag blocks in fs */
  	int32_t	 fs_frag;		/* number of frags in a block in fs */
 @@ -301,7 +301,7 @@ struct fs {
  	int32_t  fs_old_spc;		/* sectors per cylinder */
  	int32_t	 fs_old_ncyl;		/* cylinders in filesystem */
  	int32_t	 fs_old_cpg;		/* cylinders per group */
 -	int32_t	 fs_ipg;		/* inodes per group */
 +	u_int32_t fs_ipg;		/* inodes per group */
  	int32_t	 fs_fpg;		/* blocks per group * fs_frag */
  /* this data must be re-computed after crashes */
  	struct	csum fs_old_cstotal;	/* cylinder summary information */
 @@ -332,10 +332,10 @@ struct fs {
  	int64_t	 fs_dsize;		/* number of data blocks in fs */
  	ufs2_daddr_t fs_csaddr;		/* blk addr of cyl grp summary area */
  	int64_t	 fs_pendingblocks;	/* (u) blocks being freed */
 -	int32_t	 fs_pendinginodes;	/* (u) inodes being freed */
 -	int32_t	 fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
 -	int32_t	 fs_avgfilesize;	/* expected average file size */
 -	int32_t	 fs_avgfpdir;		/* expected # of files per directory */
 +	u_int32_t fs_pendinginodes;	/* (u) inodes being freed */
 +	ino_t	 fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
 +	u_int32_t fs_avgfilesize;	/* expected average file size */
 +	u_int32_t fs_avgfpdir;		/* expected # of files per directory */
  	int32_t	 fs_save_cgsize;	/* save real cg size to use fs_bsize */
  	int32_t	 fs_sparecon32[26];	/* reserved for future constants */
  	int32_t  fs_flags;		/* see FS_ flags below */
 @@ -458,26 +458,26 @@ struct cg {
  	int32_t	 cg_firstfield;		/* historic cyl groups linked list */
  	int32_t	 cg_magic;		/* magic number */
  	int32_t  cg_old_time;		/* time last written */
 -	int32_t	 cg_cgx;		/* we are the cgx'th cylinder group */
 +	u_int32_t cg_cgx;		/* we are the cgx'th cylinder group */
  	int16_t	 cg_old_ncyl;		/* number of cyl's this cg */
  	int16_t  cg_old_niblk;		/* number of inode blocks this cg */
 -	int32_t	 cg_ndblk;		/* number of data blocks this cg */
 -	struct	csum cg_cs;		/* cylinder summary information */
 -	int32_t	 cg_rotor;		/* position of last used block */
 -	int32_t	 cg_frotor;		/* position of last used frag */
 -	int32_t	 cg_irotor;		/* position of last used inode */
 -	int32_t	 cg_frsum[MAXFRAG];	/* counts of available frags */
 +	u_int32_t cg_ndblk;		/* number of data blocks this cg */
 +	struct	 csum cg_cs;		/* cylinder summary information */
 +	u_int32_t cg_rotor;		/* position of last used block */
 +	u_int32_t cg_frotor;		/* position of last used frag */
 +	u_int32_t cg_irotor;		/* position of last used inode */
 +	u_int32_t cg_frsum[MAXFRAG];	/* counts of available frags */
  	int32_t	 cg_old_btotoff;	/* (int32) block totals per cylinder */
  	int32_t	 cg_old_boff;		/* (u_int16) free block positions */
 -	int32_t	 cg_iusedoff;		/* (u_int8) used inode map */
 -	int32_t	 cg_freeoff;		/* (u_int8) free block map */
 -	int32_t	 cg_nextfreeoff;	/* (u_int8) next available space */
 -	int32_t	 cg_clustersumoff;	/* (u_int32) counts of avail clusters */
 -	int32_t	 cg_clusteroff;		/* (u_int8) free cluster map */
 -	int32_t	 cg_nclusterblks;	/* number of clusters this cg */
 -	int32_t  cg_niblk;		/* number of inode blocks this cg */
 -	int32_t	 cg_initediblk;		/* last initialized inode */
 -	int32_t	 cg_unrefs;		/* number of unreferenced inodes */
 +	u_int32_t cg_iusedoff;		/* (u_int8) used inode map */
 +	u_int32_t cg_freeoff;		/* (u_int8) free block map */
 +	u_int32_t cg_nextfreeoff;	/* (u_int8) next available space */
 +	u_int32_t cg_clustersumoff;	/* (u_int32) counts of avail clusters */
 +	u_int32_t cg_clusteroff;		/* (u_int8) free cluster map */
 +	u_int32_t cg_nclusterblks;	/* number of clusters this cg */
 +	u_int32_t cg_niblk;		/* number of inode blocks this cg */
 +	u_int32_t cg_initediblk;		/* last initialized inode */
 +	u_int32_t cg_unrefs;		/* number of unreferenced inodes */
  	int32_t	 cg_sparecon32[2];	/* reserved for future use */
  	ufs_time_t cg_time;		/* time last written */
  	int64_t	 cg_sparecon64[3];	/* reserved for future use */
 @@ -524,11 +524,11 @@ struct cg {
   *     inode number to cylinder group number.
   *     inode number to filesystem block address.
   */
 -#define	ino_to_cg(fs, x)	((x) / (fs)->fs_ipg)
 +#define	ino_to_cg(fs, x)	(((ino_t)(x)) / (fs)->fs_ipg)
  #define	ino_to_fsba(fs, x)						\
 -	((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) +			\
 -	    (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
 -#define	ino_to_fsbo(fs, x)	((x) % INOPB(fs))
 +	((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) +		\
 +	    (blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / INOPB(fs))))))
 +#define	ino_to_fsbo(fs, x)	(((ino_t)(x)) % INOPB(fs))
  
  /*
   * Give cylinder group number for a filesystem block.
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133980: commit references a PR
Date: Sat, 27 Feb 2010 17:55:45 +0000 (UTC)

 Author: mckusick
 Date: Sat Feb 27 17:55:29 2010
 New Revision: 204419
 URL: http://svn.freebsd.org/changeset/base/204419
 
 Log:
   MFC of 203763, 203764, 203768, 203769, 203770, 203782, and 203784.
   
   These fixes correct a problem in the file system that treats large
   inode numbers as negative rather than unsigned. For a default
   (16K block) file system, this bug began to show up at a file system
   size above about 16Tb.
   
   These fixes also update newfs to ensure that it will never create a
   filesystem with more than 2^32 inodes.
   
   They also update libufs, tunefs, and growfs so that they properly
   handle inode numbers as unsigned.
   
   Reported by: Scott Burns, John Kilburg, and Bruce Evans
   Followup by: Jeff Roberson
   PR:          133980
 
 Modified:
   stable/7/lib/libufs/cgroup.c
   stable/7/lib/libufs/sblock.c
   stable/7/sbin/growfs/growfs.c
   stable/7/sbin/newfs/mkfs.c
   stable/7/sbin/newfs/newfs.c
   stable/7/sbin/newfs/newfs.h
   stable/7/sbin/tunefs/tunefs.c
   stable/7/sys/ufs/ffs/ffs_alloc.c
   stable/7/sys/ufs/ffs/fs.h
 Directory Properties:
   stable/7/lib/libufs/   (props changed)
   stable/7/sbin/growfs/   (props changed)
   stable/7/sbin/newfs/   (props changed)
   stable/7/sbin/tunefs/   (props changed)
   stable/7/sys/   (props changed)
   stable/7/sys/cddl/contrib/opensolaris/   (props changed)
   stable/7/sys/contrib/dev/acpica/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
 
 Modified: stable/7/lib/libufs/cgroup.c
 ==============================================================================
 --- stable/7/lib/libufs/cgroup.c	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/lib/libufs/cgroup.c	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -59,7 +59,7 @@ cgread1(struct uufsd *disk, int c)
  
  	fs = &disk->d_fs;
  
 -	if (c >= fs->fs_ncg) {
 +	if ((unsigned)c >= fs->fs_ncg) {
  		return (0);
  	}
  	ccg = fsbtodb(fs, cgtod(fs, c)) * disk->d_bsize;
 
 Modified: stable/7/lib/libufs/sblock.c
 ==============================================================================
 --- stable/7/lib/libufs/sblock.c	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/lib/libufs/sblock.c	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -93,7 +93,7 @@ int
  sbwrite(struct uufsd *disk, int all)
  {
  	struct fs *fs;
 -	int i;
 +	unsigned i;
  
  	ERROR(disk, NULL);
  
 
 Modified: stable/7/sbin/growfs/growfs.c
 ==============================================================================
 --- stable/7/sbin/growfs/growfs.c	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/sbin/growfs/growfs.c	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -174,10 +174,9 @@ static void
  growfs(int fsi, int fso, unsigned int Nflag)
  {
  	DBG_FUNC("growfs")
 -	int	i;
 -	int	cylno, j;
  	time_t	utime;
 -	int	width;
 +	uint	cylno;
 +	int	i, j, width;
  	char	tmpbuf[100];
  #ifdef FSIRAND
  	static int	randinit=0;
 @@ -373,11 +372,12 @@ initcg(int cylno, time_t utime, int fso,
  {
  	DBG_FUNC("initcg")
  	static void *iobuf;
 -	long d, dlower, dupper, blkno, start;
 +	long blkno, start;
  	ufs2_daddr_t i, cbase, dmax;
  	struct ufs1_dinode *dp1;
  	struct ufs2_dinode *dp2;
  	struct csum *cs;
 +	uint d, dupper, dlower;
  
  	if (iobuf == NULL && (iobuf = malloc(sblock.fs_bsize)) == NULL) {
  		errx(37, "panic: cannot allocate I/O buffer");
 @@ -432,7 +432,7 @@ initcg(int cylno, time_t utime, int fso,
  		acg.cg_nextfreeoff = acg.cg_clusteroff +
  		    howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT);
  	}
 -	if (acg.cg_nextfreeoff > sblock.fs_cgsize) {
 +	if (acg.cg_nextfreeoff > (unsigned)sblock.fs_cgsize) {
  		/*
  		 * This should never happen as we would have had that panic
  		 * already on file system creation
 @@ -752,7 +752,7 @@ updjcg(int cylno, time_t utime, int fsi,
  	 * needed, update the free space in the superblock.
  	 */
  	acg.cg_time = utime;
 -	if (cylno == sblock.fs_ncg - 1) {
 +	if ((unsigned)cylno == sblock.fs_ncg - 1) {
  		/*
  		 * This is still the last cylinder group.
  		 */
 @@ -946,8 +946,8 @@ updcsloc(time_t utime, int fsi, int fso,
  	int	ocscg, ncscg;
  	int	blocks;
  	ufs2_daddr_t	cbase, dupper, odupper, d, f, g;
 -	int	ind;
 -	int	cylno, inc;
 +	int	ind, inc;
 +	uint	cylno;
  	struct gfs_bpp	*bp;
  	int	i, l;
  	int	lcs=0;
 
 Modified: stable/7/sbin/newfs/mkfs.c
 ==============================================================================
 --- stable/7/sbin/newfs/mkfs.c	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/sbin/newfs/mkfs.c	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -105,10 +105,13 @@ void
  mkfs(struct partition *pp, char *fsys)
  {
  	int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg;
 -	long i, j, cylno, csfrags;
 +	long i, j, csfrags;
 +	uint cg;
  	time_t utime;
  	quad_t sizepb;
  	int width;
 +	ino_t maxinum;
 +	int minfragsperinode;	/* minimum ratio of frags to inodes */
  	char tmpbuf[100];	/* XXX this will break in about 2,500 years */
  	union {
  		struct fs fdummy;
 @@ -161,6 +164,8 @@ mkfs(struct partition *pp, char *fsys)
  	if (sblock.fs_avgfpdir <= 0)
  		printf("illegal expected number of files per directory %d\n",
  		    sblock.fs_avgfpdir), exit(15);
 +
 +restart:
  	/*
  	 * collect and verify the block and fragment sizes
  	 */
 @@ -207,6 +212,8 @@ mkfs(struct partition *pp, char *fsys)
  		    sblock.fs_fsize, MAXFRAG, sblock.fs_bsize / MAXFRAG);
  		sblock.fs_fsize = sblock.fs_bsize / MAXFRAG;
  	}
 +	if (maxbsize == 0)
 +		maxbsize = bsize;
  	if (maxbsize < bsize || !POWEROF2(maxbsize)) {
  		sblock.fs_maxbsize = sblock.fs_bsize;
  		printf("Extent size set to %d\n", sblock.fs_maxbsize);
 @@ -216,6 +223,14 @@ mkfs(struct partition *pp, char *fsys)
  	} else {
  		sblock.fs_maxbsize = maxbsize;
  	}
 +	/*
 +	 * Maxcontig sets the default for the maximum number of blocks
 +	 * that may be allocated sequentially. With file system clustering
 +	 * it is possible to allocate contiguous blocks up to the maximum
 +	 * transfer size permitted by the controller or buffering.
 +	 */
 +	if (maxcontig == 0)
 +		maxcontig = MAX(1, MAXPHYS / bsize);
  	sblock.fs_maxcontig = maxcontig;
  	if (sblock.fs_maxcontig < sblock.fs_maxbsize / sblock.fs_bsize) {
  		sblock.fs_maxcontig = sblock.fs_maxbsize / sblock.fs_bsize;
 @@ -306,9 +321,26 @@ mkfs(struct partition *pp, char *fsys)
  	 * can put into each cylinder group. If this is too big, we reduce
  	 * the density until it fits.
  	 */
 +	maxinum = (((int64_t)(1)) << 32) - INOPB(&sblock);
 +	minfragsperinode = 1 + fssize / maxinum;
 +	if (density == 0) {
 +		density = MAX(NFPI, minfragsperinode) * fsize;
 +	} else if (density < minfragsperinode * fsize) {
 +		origdensity = density;
 +		density = minfragsperinode * fsize;
 +		fprintf(stderr, "density increased from %d to %d\n",
 +		    origdensity, density);
 +	}
  	origdensity = density;
  	for (;;) {
  		fragsperinode = MAX(numfrags(&sblock, density), 1);
 +		if (fragsperinode < minfragsperinode) {
 +			bsize <<= 1;
 +			fsize <<= 1;
 +			printf("Block size too small for a file system %s %d\n",
 +			     "of this size. Increasing blocksize to", bsize);
 +			goto restart;
 +		}
  		minfpg = fragsperinode * INOPB(&sblock);
  		if (minfpg > sblock.fs_size)
  			minfpg = sblock.fs_size;
 @@ -397,7 +429,10 @@ mkfs(struct partition *pp, char *fsys)
  	if (sblock.fs_sbsize > SBLOCKSIZE)
  		sblock.fs_sbsize = SBLOCKSIZE;
  	sblock.fs_minfree = minfree;
 -	sblock.fs_maxbpg = maxbpg;
 +	if (maxbpg == 0)
 +		sblock.fs_maxbpg = MAXBLKPG(sblock.fs_bsize);
 +	else
 +		sblock.fs_maxbpg = maxbpg;
  	sblock.fs_optim = opt;
  	sblock.fs_cgrotor = 0;
  	sblock.fs_pendingblocks = 0;
 @@ -459,9 +494,9 @@ mkfs(struct partition *pp, char *fsys)
  		if (fsdummy.fs_magic == FS_UFS1_MAGIC) {
  			fsdummy.fs_magic = 0;
  			bwrite(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE);
 -			for (i = 0; i < fsdummy.fs_ncg; i++)
 -				bwrite(&disk, fsbtodb(&fsdummy, cgsblock(&fsdummy, i)),
 -	                    chdummy, SBLOCKSIZE);
 +			for (cg = 0; cg < fsdummy.fs_ncg; cg++)
 +				bwrite(&disk, fsbtodb(&fsdummy,
 +				  cgsblock(&fsdummy, cg)), chdummy, SBLOCKSIZE);
  		}
  	}
  	if (!Nflag)
 @@ -500,11 +535,11 @@ mkfs(struct partition *pp, char *fsys)
  	 * writing out in each cylinder group.
  	 */
  	bcopy((char *)&sblock, iobuf, SBLOCKSIZE);
 -	for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
 -		initcg(cylno, utime);
 +	for (cg = 0; cg < sblock.fs_ncg; cg++) {
 +		initcg(cg, utime);
  		j = snprintf(tmpbuf, sizeof(tmpbuf), " %jd%s",
 -		    (intmax_t)fsbtodb(&sblock, cgsblock(&sblock, cylno)),
 -		    cylno < (sblock.fs_ncg-1) ? "," : "");
 +		    (intmax_t)fsbtodb(&sblock, cgsblock(&sblock, cg)),
 +		    cg < (sblock.fs_ncg-1) ? "," : "");
  		if (j < 0)
  			tmpbuf[j = 0] = '\0';
  		if (i + j >= width) {
 @@ -558,7 +593,8 @@ mkfs(struct partition *pp, char *fsys)
  void
  initcg(int cylno, time_t utime)
  {
 -	long i, j, d, dlower, dupper, blkno, start;
 +	long blkno, start;
 +	uint i, j, d, dlower, dupper;
  	ufs2_daddr_t cbase, dmax;
  	struct ufs1_dinode *dp1;
  	struct ufs2_dinode *dp2;
 @@ -615,7 +651,7 @@ initcg(int cylno, time_t utime)
  		acg.cg_nextfreeoff = acg.cg_clusteroff +
  		    howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT);
  	}
 -	if (acg.cg_nextfreeoff > sblock.fs_cgsize) {
 +	if (acg.cg_nextfreeoff > (unsigned)sblock.fs_cgsize) {
  		printf("Panic: cylinder group too big\n");
  		exit(37);
  	}
 @@ -864,7 +900,8 @@ makedir(struct direct *protodir, int ent
  ufs2_daddr_t
  alloc(int size, int mode)
  {
 -	int i, d, blkno, frag;
 +	int i, blkno, frag;
 +	uint d;
  
  	bread(&disk, fsbtodb(&sblock, cgtod(&sblock, 0)), (char *)&acg,
  	    sblock.fs_cgsize);
 
 Modified: stable/7/sbin/newfs/newfs.c
 ==============================================================================
 --- stable/7/sbin/newfs/newfs.c	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/sbin/newfs/newfs.c	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -79,38 +79,6 @@ __FBSDID("$FreeBSD$");
  
  #include "newfs.h"
  
 -/*
 - * The following two constants set the default block and fragment sizes.
 - * Both constants must be a power of 2 and meet the following constraints:
 - *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
 - *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
 - *	DESBLKSIZE / DESFRAGSIZE <= 8
 - */
 -#define	DFL_FRAGSIZE	2048
 -#define	DFL_BLKSIZE	16384
 -
 -/*
 - * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual
 - * number used depends upon how much information can be stored
 - * in a cylinder group map which must fit in a single file system
 - * block. The default is to use as many as possible blocks per group.
 - */
 -#define	MAXBLKSPERCG	0x7fffffff	/* desired fs_fpg ("infinity") */
 -
 -/*
 - * MAXBLKPG determines the maximum number of data blocks which are
 - * placed in a single cylinder group. The default is one indirect
 - * block worth of data blocks.
 - */
 -#define MAXBLKPG(bsize)	((bsize) / sizeof(ufs2_daddr_t))
 -
 -/*
 - * Each file system has a number of inodes statically allocated.
 - * We allocate one inode slot per NFPI fragments, expecting this
 - * to be far more than we will ever need.
 - */
 -#define	NFPI		4
 -
  int	Lflag;			/* add a volume label */
  int	Nflag;			/* run without writing file system */
  int	Oflag = 2;		/* file system format (1 => UFS1, 2 => UFS2) */
 @@ -346,25 +314,11 @@ main(int argc, char *argv[])
  		fsize = MAX(DFL_FRAGSIZE, sectorsize);
  	if (bsize <= 0)
  		bsize = MIN(DFL_BLKSIZE, 8 * fsize);
 -	if (maxbsize == 0)
 -		maxbsize = bsize;
 -	/*
 -	 * Maxcontig sets the default for the maximum number of blocks
 -	 * that may be allocated sequentially. With file system clustering
 -	 * it is possible to allocate contiguous blocks up to the maximum
 -	 * transfer size permitted by the controller or buffering.
 -	 */
 -	if (maxcontig == 0)
 -		maxcontig = MAX(1, MAXPHYS / bsize);
 -	if (density == 0)
 -		density = NFPI * fsize;
  	if (minfree < MINFREE && opt != FS_OPTSPACE) {
  		fprintf(stderr, "Warning: changing optimization to space ");
  		fprintf(stderr, "because minfree is less than %d%%\n", MINFREE);
  		opt = FS_OPTSPACE;
  	}
 -	if (maxbpg == 0)
 -		maxbpg = MAXBLKPG(bsize);
  	realsectorsize = sectorsize;
  	if (sectorsize != DEV_BSIZE) {		/* XXX */
  		int secperblk = sectorsize / DEV_BSIZE;
 
 Modified: stable/7/sbin/newfs/newfs.h
 ==============================================================================
 --- stable/7/sbin/newfs/newfs.h	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/sbin/newfs/newfs.h	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -41,6 +41,38 @@
  #include <libufs.h>
  
  /*
 + * The following two constants set the default block and fragment sizes.
 + * Both constants must be a power of 2 and meet the following constraints:
 + *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
 + *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
 + *	DESBLKSIZE / DESFRAGSIZE <= 8
 + */
 +#define	DFL_FRAGSIZE	2048
 +#define	DFL_BLKSIZE	16384
 +
 +/*
 + * Cylinder groups may have up to MAXBLKSPERCG blocks. The actual
 + * number used depends upon how much information can be stored
 + * in a cylinder group map which must fit in a single file system
 + * block. The default is to use as many as possible blocks per group.
 + */
 +#define	MAXBLKSPERCG	0x7fffffff	/* desired fs_fpg ("infinity") */
 +
 +/*
 + * MAXBLKPG determines the maximum number of data blocks which are
 + * placed in a single cylinder group. The default is one indirect
 + * block worth of data blocks.
 + */
 +#define MAXBLKPG(bsize)	((bsize) / sizeof(ufs2_daddr_t))
 +
 +/*
 + * Each file system has a number of inodes statically allocated.
 + * We allocate one inode slot per NFPI fragments, expecting this
 + * to be far more than we will ever need.
 + */
 +#define	NFPI		4
 +
 +/*
   * variables set up by front end.
   */
  extern int	Lflag;		/* add a volume label */
 
 Modified: stable/7/sbin/tunefs/tunefs.c
 ==============================================================================
 --- stable/7/sbin/tunefs/tunefs.c	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/sbin/tunefs/tunefs.c	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -286,7 +286,7 @@ main(int argc, char *argv[])
  	}
  	if (fflag) {
  		name = "average file size";
 -		if (sblock.fs_avgfilesize == fvalue) {
 +		if (sblock.fs_avgfilesize == (unsigned)fvalue) {
  			warnx("%s remains unchanged as %d", name, fvalue);
  		}
  		else {
 @@ -389,7 +389,7 @@ main(int argc, char *argv[])
  	}
  	if (sflag) {
  		name = "expected number of files per directory";
 -		if (sblock.fs_avgfpdir == svalue) {
 +		if (sblock.fs_avgfpdir == (unsigned)svalue) {
  			warnx("%s remains unchanged as %d", name, svalue);
  		}
  		else {
 
 Modified: stable/7/sys/ufs/ffs/ffs_alloc.c
 ==============================================================================
 --- stable/7/sys/ufs/ffs/ffs_alloc.c	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/sys/ufs/ffs/ffs_alloc.c	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -88,24 +88,25 @@ __FBSDID("$FreeBSD$");
  #include <ufs/ffs/fs.h>
  #include <ufs/ffs/ffs_extern.h>
  
 -typedef ufs2_daddr_t allocfcn_t(struct inode *ip, int cg, ufs2_daddr_t bpref,
 +typedef ufs2_daddr_t allocfcn_t(struct inode *ip, u_int cg, ufs2_daddr_t bpref,
  				  int size);
  
 -static ufs2_daddr_t ffs_alloccg(struct inode *, int, ufs2_daddr_t, int);
 +static ufs2_daddr_t ffs_alloccg(struct inode *, u_int, ufs2_daddr_t, int);
  static ufs2_daddr_t
  	      ffs_alloccgblk(struct inode *, struct buf *, ufs2_daddr_t);
  #ifdef INVARIANTS
  static int	ffs_checkblk(struct inode *, ufs2_daddr_t, long);
  #endif
 -static ufs2_daddr_t ffs_clusteralloc(struct inode *, int, ufs2_daddr_t, int);
 +static ufs2_daddr_t ffs_clusteralloc(struct inode *, u_int, ufs2_daddr_t, int);
  static void	ffs_clusteracct(struct ufsmount *, struct fs *, struct cg *,
  		    ufs1_daddr_t, int);
  static ino_t	ffs_dirpref(struct inode *);
 -static ufs2_daddr_t ffs_fragextend(struct inode *, int, ufs2_daddr_t, int, int);
 +static ufs2_daddr_t ffs_fragextend(struct inode *, u_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 ufs2_daddr_t ffs_nodealloccg(struct inode *, int, ufs2_daddr_t, int);
 +		(struct inode *, u_int, ufs2_daddr_t, int, allocfcn_t *);
 +static ufs2_daddr_t ffs_nodealloccg(struct inode *, u_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 *);
 @@ -140,7 +141,7 @@ ffs_alloc(ip, lbn, bpref, size, flags, c
  	struct fs *fs;
  	struct ufsmount *ump;
  	ufs2_daddr_t bno;
 -	int cg, reclaimed;
 +	u_int cg, reclaimed;
  	static struct timeval lastfail;
  	static int curfail;
  	int64_t delta;
 @@ -243,7 +244,8 @@ ffs_realloccg(ip, lbprev, bprev, bpref, 
  	struct fs *fs;
  	struct buf *bp;
  	struct ufsmount *ump;
 -	int cg, request, error, reclaimed;
 +	u_int cg, request, reclaimed;
 +	int error;
  	ufs2_daddr_t bno;
  	static struct timeval lastfail;
  	static int curfail;
 @@ -932,7 +934,8 @@ ffs_valloc(pvp, mode, cred, vpp)
  	struct timespec ts;
  	struct ufsmount *ump;
  	ino_t ino, ipref;
 -	int cg, error, error1;
 +	u_int cg;
 +	int error, error1;
  	static struct timeval lastfail;
  	static int curfail;
  
 @@ -1042,11 +1045,11 @@ ffs_dirpref(pip)
  	struct inode *pip;
  {
  	struct fs *fs;
 -	int cg, prefcg, dirsize, cgsize;
 -	int avgifree, avgbfree, avgndir, curdirsize;
 -	int minifree, minbfree, maxndir;
 -	int mincg, minndir;
 -	int maxcontigdirs;
 +	u_int cg, prefcg, dirsize, cgsize;
 +	u_int avgifree, avgbfree, avgndir, curdirsize;
 +	u_int minifree, minbfree, maxndir;
 +	u_int mincg, minndir;
 +	u_int maxcontigdirs;
  
  	mtx_assert(UFS_MTX(pip->i_ump), MA_OWNED);
  	fs = pip->i_fs;
 @@ -1170,8 +1173,8 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap)
  	ufs1_daddr_t *bap;
  {
  	struct fs *fs;
 -	int cg;
 -	int avgbfree, startcg;
 +	u_int cg;
 +	u_int avgbfree, startcg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  	fs = ip->i_fs;
 @@ -1220,8 +1223,8 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
  	ufs2_daddr_t *bap;
  {
  	struct fs *fs;
 -	int cg;
 -	int avgbfree, startcg;
 +	u_int cg;
 +	u_int avgbfree, startcg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  	fs = ip->i_fs;
 @@ -1274,14 +1277,14 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap)
  static ufs2_daddr_t
  ffs_hashalloc(ip, cg, pref, size, allocator)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t pref;
  	int size;	/* size for data blocks, mode for inodes */
  	allocfcn_t *allocator;
  {
  	struct fs *fs;
  	ufs2_daddr_t result;
 -	int i, icg = cg;
 +	u_int i, icg = cg;
  
  	mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
  #ifdef INVARIANTS
 @@ -1332,7 +1335,7 @@ ffs_hashalloc(ip, cg, pref, size, alloca
  static ufs2_daddr_t
  ffs_fragextend(ip, cg, bprev, osize, nsize)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bprev;
  	int osize, nsize;
  {
 @@ -1415,7 +1418,7 @@ fail:
  static ufs2_daddr_t
  ffs_alloccg(ip, cg, bpref, size)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bpref;
  	int size;
  {
 @@ -1585,7 +1588,7 @@ gotit:
  static ufs2_daddr_t
  ffs_clusteralloc(ip, cg, bpref, len)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t bpref;
  	int len;
  {
 @@ -1709,7 +1712,7 @@ fail:
  static ufs2_daddr_t
  ffs_nodealloccg(ip, cg, ipref, mode)
  	struct inode *ip;
 -	int cg;
 +	u_int cg;
  	ufs2_daddr_t ipref;
  	int mode;
  {
 @@ -1810,7 +1813,7 @@ gotit:
  	bdwrite(bp);
  	if (ibp != NULL)
  		bawrite(ibp);
 -	return (cg * fs->fs_ipg + ipref);
 +	return ((ino_t)(cg * fs->fs_ipg + ipref));
  }
  
  /*
 @@ -1855,7 +1858,8 @@ ffs_blkfree(ump, fs, devvp, bno, size, i
  	struct buf *bp;
  	ufs1_daddr_t fragno, cgbno;
  	ufs2_daddr_t cgblkno;
 -	int i, cg, blk, frags, bbase;
 +	int i, blk, frags, bbase;
 +	u_int cg;
  	u_int8_t *blksfree;
  	struct cdev *dev;
  
 @@ -2053,7 +2057,8 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  	struct cg *cgp;
  	struct buf *bp;
  	ufs2_daddr_t cgbno;
 -	int error, cg;
 +	int error;
 +	u_int cg;
  	u_int8_t *inosused;
  	struct cdev *dev;
  
 @@ -2067,7 +2072,7 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  		dev = devvp->v_rdev;
  		cgbno = fsbtodb(fs, cgtod(fs, cg));
  	}
 -	if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
 +	if (ino >= fs->fs_ipg * fs->fs_ncg)
  		panic("ffs_freefile: range: dev = %s, ino = %lu, fs = %s",
  		    devtoname(dev), (u_long)ino, fs->fs_fsmnt);
  	if ((error = bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp))) {
 @@ -2084,8 +2089,8 @@ ffs_freefile(ump, fs, devvp, ino, mode)
  	inosused = cg_inosused(cgp);
  	ino %= fs->fs_ipg;
  	if (isclr(inosused, ino)) {
 -		printf("dev = %s, ino = %lu, fs = %s\n", devtoname(dev),
 -		    (u_long)ino + cg * fs->fs_ipg, fs->fs_fsmnt);
 +		printf("dev = %s, ino = %u, fs = %s\n", devtoname(dev),
 +		    ino + cg * fs->fs_ipg, fs->fs_fsmnt);
  		if (fs->fs_ronly == 0)
  			panic("ffs_freefile: freeing free inode");
  	}
 @@ -2120,7 +2125,8 @@ ffs_checkfreefile(fs, devvp, ino)
  	struct cg *cgp;
  	struct buf *bp;
  	ufs2_daddr_t cgbno;
 -	int ret, cg;
 +	int ret;
 +	u_int cg;
  	u_int8_t *inosused;
  
  	cg = ino_to_cg(fs, ino);
 @@ -2131,7 +2137,7 @@ ffs_checkfreefile(fs, devvp, ino)
  		/* devvp is a normal disk device */
  		cgbno = fsbtodb(fs, cgtod(fs, cg));
  	}
 -	if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
 +	if (ino >= fs->fs_ipg * fs->fs_ncg)
  		return (1);
  	if (bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp)) {
  		brelse(bp);
 
 Modified: stable/7/sys/ufs/ffs/fs.h
 ==============================================================================
 --- stable/7/sys/ufs/ffs/fs.h	Sat Feb 27 17:36:13 2010	(r204418)
 +++ stable/7/sys/ufs/ffs/fs.h	Sat Feb 27 17:55:29 2010	(r204419)
 @@ -261,7 +261,7 @@ struct fs {
  	int32_t  fs_old_time;		/* last time written */
  	int32_t	 fs_old_size;		/* number of blocks in fs */
  	int32_t	 fs_old_dsize;		/* number of data blocks in fs */
 -	int32_t	 fs_ncg;		/* number of cylinder groups */
 +	u_int32_t fs_ncg;		/* number of cylinder groups */
  	int32_t	 fs_bsize;		/* size of basic blocks in fs */
  	int32_t	 fs_fsize;		/* size of frag blocks in fs */
  	int32_t	 fs_frag;		/* number of frags in a block in fs */
 @@ -301,7 +301,7 @@ struct fs {
  	int32_t  fs_old_spc;		/* sectors per cylinder */
  	int32_t	 fs_old_ncyl;		/* cylinders in filesystem */
  	int32_t	 fs_old_cpg;		/* cylinders per group */
 -	int32_t	 fs_ipg;		/* inodes per group */
 +	u_int32_t fs_ipg;		/* inodes per group */
  	int32_t	 fs_fpg;		/* blocks per group * fs_frag */
  /* this data must be re-computed after crashes */
  	struct	csum fs_old_cstotal;	/* cylinder summary information */
 @@ -332,10 +332,10 @@ struct fs {
  	int64_t	 fs_dsize;		/* number of data blocks in fs */
  	ufs2_daddr_t fs_csaddr;		/* blk addr of cyl grp summary area */
  	int64_t	 fs_pendingblocks;	/* (u) blocks being freed */
 -	int32_t	 fs_pendinginodes;	/* (u) inodes being freed */
 -	int32_t	 fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
 -	int32_t	 fs_avgfilesize;	/* expected average file size */
 -	int32_t	 fs_avgfpdir;		/* expected # of files per directory */
 +	u_int32_t fs_pendinginodes;	/* (u) inodes being freed */
 +	ino_t	 fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
 +	u_int32_t fs_avgfilesize;	/* expected average file size */
 +	u_int32_t fs_avgfpdir;		/* expected # of files per directory */
  	int32_t	 fs_save_cgsize;	/* save real cg size to use fs_bsize */
  	int32_t	 fs_sparecon32[26];	/* reserved for future constants */
  	int32_t  fs_flags;		/* see FS_ flags below */
 @@ -458,26 +458,26 @@ struct cg {
  	int32_t	 cg_firstfield;		/* historic cyl groups linked list */
  	int32_t	 cg_magic;		/* magic number */
  	int32_t  cg_old_time;		/* time last written */
 -	int32_t	 cg_cgx;		/* we are the cgx'th cylinder group */
 +	u_int32_t cg_cgx;		/* we are the cgx'th cylinder group */
  	int16_t	 cg_old_ncyl;		/* number of cyl's this cg */
  	int16_t  cg_old_niblk;		/* number of inode blocks this cg */
 -	int32_t	 cg_ndblk;		/* number of data blocks this cg */
 -	struct	csum cg_cs;		/* cylinder summary information */
 -	int32_t	 cg_rotor;		/* position of last used block */
 -	int32_t	 cg_frotor;		/* position of last used frag */
 -	int32_t	 cg_irotor;		/* position of last used inode */
 -	int32_t	 cg_frsum[MAXFRAG];	/* counts of available frags */
 +	u_int32_t cg_ndblk;		/* number of data blocks this cg */
 +	struct	 csum cg_cs;		/* cylinder summary information */
 +	u_int32_t cg_rotor;		/* position of last used block */
 +	u_int32_t cg_frotor;		/* position of last used frag */
 +	u_int32_t cg_irotor;		/* position of last used inode */
 +	u_int32_t cg_frsum[MAXFRAG];	/* counts of available frags */
  	int32_t	 cg_old_btotoff;	/* (int32) block totals per cylinder */
  	int32_t	 cg_old_boff;		/* (u_int16) free block positions */
 -	int32_t	 cg_iusedoff;		/* (u_int8) used inode map */
 -	int32_t	 cg_freeoff;		/* (u_int8) free block map */
 -	int32_t	 cg_nextfreeoff;	/* (u_int8) next available space */
 -	int32_t	 cg_clustersumoff;	/* (u_int32) counts of avail clusters */
 -	int32_t	 cg_clusteroff;		/* (u_int8) free cluster map */
 -	int32_t	 cg_nclusterblks;	/* number of clusters this cg */
 -	int32_t  cg_niblk;		/* number of inode blocks this cg */
 -	int32_t	 cg_initediblk;		/* last initialized inode */
 -	int32_t	 cg_unrefs;		/* number of unreferenced inodes */
 +	u_int32_t cg_iusedoff;		/* (u_int8) used inode map */
 +	u_int32_t cg_freeoff;		/* (u_int8) free block map */
 +	u_int32_t cg_nextfreeoff;	/* (u_int8) next available space */
 +	u_int32_t cg_clustersumoff;	/* (u_int32) counts of avail clusters */
 +	u_int32_t cg_clusteroff;		/* (u_int8) free cluster map */
 +	u_int32_t cg_nclusterblks;	/* number of clusters this cg */
 +	u_int32_t cg_niblk;		/* number of inode blocks this cg */
 +	u_int32_t cg_initediblk;		/* last initialized inode */
 +	u_int32_t cg_unrefs;		/* number of unreferenced inodes */
  	int32_t	 cg_sparecon32[2];	/* reserved for future use */
  	ufs_time_t cg_time;		/* time last written */
  	int64_t	 cg_sparecon64[3];	/* reserved for future use */
 @@ -524,11 +524,11 @@ struct cg {
   *     inode number to cylinder group number.
   *     inode number to filesystem block address.
   */
 -#define	ino_to_cg(fs, x)	((x) / (fs)->fs_ipg)
 +#define	ino_to_cg(fs, x)	(((ino_t)(x)) / (fs)->fs_ipg)
  #define	ino_to_fsba(fs, x)						\
 -	((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) +			\
 -	    (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
 -#define	ino_to_fsbo(fs, x)	((x) % INOPB(fs))
 +	((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) +		\
 +	    (blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / INOPB(fs))))))
 +#define	ino_to_fsbo(fs, x)	(((ino_t)(x)) % INOPB(fs))
  
  /*
   * Give cylinder group number for a filesystem block.
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: mckusick 
State-Changed-When: Sun Feb 28 04:57:44 UTC 2010 
State-Changed-Why:  
The fix has been MFC'ed to stable/8 and stable/7. 

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