Subject: kern/28804: quota fails with FFSv2/UFS2
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Malte Dehling <mdehling@math.ruhr-uni-bochum.de>
List: netbsd-bugs
Date: 12/29/2004 17:12:00
>Number:         28804
>Category:       kern
>Synopsis:       quota fails with FFSv2/UFS2
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 29 17:12:00 +0000 2004
>Originator:     Malte Dehling
>Release:        NetBSD 2.0
>Organization:
>Environment:
System: NetBSD 2.0 RELEASE (GENERIC kernel)
Architecture: sparc sgimips i386 (all?)
Machine: /
>Description:

Some days ago I tried setting up quota on my SparcStation 20 running
NetBSD 2.0/sparc. I put the userquota option in `/etc/fstab', set the quota
using `edquota' and then tried to enable quota by putting `quota=YES' in
`/etc/rc.conf' and running `/etc/rc.d/quota start'.

What I got was this:

sparc# /etc/rc.d/quota start
Checking quotas:quotacheck: bad inode number N to nextinode
THE FOLLOWING FILE SYSTEM HAD AN UNEXPECTED INCONSISTENCY:
        ffs: /dev/rsd1a (/export)
 done.

with some number N, which I dont remember :)

The box was in an unusable state afterwards, as every attempt to access the
/export filesystem just hung. I could not disable quota as this would hang
the box aswell.
Finally I had to restart the SparcStation in single user mode and disable quota
in order to be able to use it again...

The same thing happened on two different harddisks, so I think it is software
-related.

I investigated this problem a little further on my Indy, as I needed my
SparcStation for mail/irc/icq and nfs/www server stuff...

I did a clean NetBSD 2.0 install on it twice: (didnt like debian anyway ;)
1) The first time I used FFSv2 as the filesystem. No matter what I did with
	the quota stuff, I kept running into the same trouble as on my SS20.
2) The second time, I used FFSv1 for all filesystems... Here is what happened:
---
[added userquota options]
indy# cat /etc/fstab
/dev/sd0a / ffs rw,softdep 1 1
/dev/sd0b none swap sw 0 0
# /dev/sd0d /mnt ??? rw,noauto 0 0
/dev/sd0e /usr ffs rw,softdep 1 2
/dev/sd0f /var ffs rw,softdep,userquota 1 2
/dev/sd0g /home ffs rw,softdep,userquota 1 2
kernfs /kern kernfs rw
procfs /proc procfs rw,noauto

indy# mount
/dev/sd0a on / type ffs (soft dependencies, local)
/dev/sd0f on /var type ffs (soft dependencies, local)
/dev/sd0e on /usr type ffs (soft dependencies, local)
kernfs on /kern type kernfs (local)
/dev/sd0g on /home type ffs (soft dependencies, local)

indy# useradd -m user

indy# edquota -u -s 32768/4096 -h 65536/8192 user
edquota: Creating quota file /var/quota.user
edquota: Creating quota file /home/quota.user

[this is using FFSv1]
indy# /etc/rc.d/quota start
Checking quotas: done.

indy# /etc/rc.d/quota stop

indy# umount /home

[now try the same thing with FFSv2: `-O 2']
indy# newfs -O 2 -b 8192 -f 1024 /dev/sd0g
/dev/sd0g: 3150.2MB (6451596 sectors) block size 8192, fragment size 1024
        using 69 cylinder groups of 45.66MB, 5844 blks, 10976 inodes.
super-block backups (for fsck -b #) at:
     144,   93648,  187152,  280656,  374160,  467664,  561168,  654672,
  748176,  841680,  935184, 1028688, 1122192, 1215696, 1309200, 1402704,
 1496208, 1589712, 1683216, 1776720, 1870224, 1963728, 2057232, 2150736,
 2244240, 2337744, 2431248, 2524752, 2618256, 2711760, 2805264, 2898768,
 2992272, 3085776, 3179280, 3272784, 3366288, 3459792, 3553296, 3646800,
 3740304, 3833808, 3927312, 4020816, 4114320, 4207824, 4301328, 4394832,
 4488336, 4581840, 4675344, 4768848, 4862352, 4955856, 5049360, 5142864,
 5236368, 5329872, 5423376, 5516880, 5610384, 5703888, 5797392, 5890896,
 5984400, 6077904, 6171408, 6264912, 6358416,

indy# mount /home

indy# edquota -u -s 32768/4096 -h 65536/8192 user
edquota: Creating quota file /home/quota.user

[makes me think it has something todo with FFSv2...]
indy# /etc/rc.d/quota start
Checking quotas:quotacheck: bad inode number 64 to nextinode
THE FOLLOWING FILE SYSTEM HAD AN UNEXPECTED INCONSISTENCY:
        ffs: /dev/rsd0g (/home)
 done.

[this hangs when trying to report status of /home quotas]
indy# repquota -a -v
*** Report for user quotas on /var (/dev/sd0f)
                        Block limits               File limits
User            used    soft    hard  grace      used    soft    hard  grace
root      --     530       0       0               91       0       0       
daemon    --       1       0       0                2       0       0       
games     --      21       0       0               29       0       0       
named     --       1       0       0                1       0       0       
smmsp     --       1       0       0                1       0       0       
uucp      --       3       0       0                4       0       0       
nobody    --       0       0       0                1       0       0       
^Z
Suspended

[searched google: there seem to be some issues with vnlock() deadlocking?]
indy# ps -l
UID PID PPID CPU PRI NI VSZ RSS WCHAN  STAT TT    TIME COMMAND
  0 496  469   0  18  0 304 988 pause  S    p0 0:00.83 -csh 
  0 617  496   1  -2  0 152 772 vnlock D    p0 0:00.23 repquota -a -v 
  0 697  496   1  30  0  92 624 -      R+   p0 0:00.01 ps -l 
  0 427    1   0   3  0 300 948 ttyin  Is+  E0 0:00.95 -csh 
---

All processes that try to access the /home (FFSv2 w quota) filesystem, just hang
with `ps -l' reporting WCHAN: vnlock .

As I got no reply to my mail to the netbsd-users mailinglist
(not even a `works for me') I checked this on one more box (i386).

On the i386 I installed NetBSD with all filesystems FFSv2/UFS2, enabled quota
(set quota=YES, set quota using `edquota,' ran /etc/rc.d/quota start) and I
got exactly the same error and problems as on my SparcStation and Indy.

(btw: I used the softdep options on all filesystems, including those with quota
enabled. Dont know if this has anything to do with it.)

>How-To-Repeat:

Install NetBSD 2.0 on FFSv2/UFS2 filesystem then set `quota=YES' in
`/etc/rc.conf,' add `userquota' to options in `/etc/fstab,' add a user, set
quota for user using `edquota' and try to enable quota by running
`/etc/rc.d/quota start.' You will get an error (see Description.)
If now there is some activity on the affected filesystem, after a very short
period of time all processes accessing this filesystem will hang
(WCHAN: vnlock.) The filesystem (and the entire box) is no longer usable (nor
unmountable.)

>Fix:

To avoid this problem either use FFS1/UFS1 with quota or dont use quota at all.