Giant-less UFS with quotas for FreeBSD

As of 23-02-2006, FreeBSD marks ufs filesystems as not needing Giant,
unless quotas support is compiled into the kernel. Proposed patch against 7-CURRENT
aims to properly lock quota code and adds MNTK_MPSAFE flag to ufs mounts
unconditionally.

the style of manipulation of struct dquot flags, especially DQ_LOCK, DQ_MOD and DQ_WANT

assignment of the dquot structure pointer to i_dquot array of the inode

One global mutex (dqhlock) is used to protect dqhash, dqfreelist
and dq_cnt, because they all manage busy/free/lookup operations for
dquot'as.

Also, each dquot got individual mutex dq_lock to protect
dq_flags. I.e., to safely access and manipulate dquot, the protocol
shall be followed, where the operation starts by acquiring dq_lock mutex
ownership. Then, thread shall wait in msleep(9) until DQ_LOCK flag is cleared
by current owner. After that it is allowed to perform quick manipulations with dquot
while dq_lock is held, or, if sleeping is possible, DQ_LOCK flag
shall be set and mutex freed. For example,

inode' i_dquot array is protected by lockmgr' vnode lock. As
consequence, getinoquota(9) shall be called with exclusive lock on the
vnode (except the case of NULLVP). The only caller that did not follow
this (new) rule I found was ufs_access(), that could call
getinoquota() with only shared lock held. I request upgrade of the
vnode lock in ufs_access() before calling getinoquota() and downgrade
lock after, if appropriate.

Fix the bug noted by Tor Egge.
Aquire/release the Giant as needed when manipulating quotas file.
Change was tested by placing quota file
on the nfs-exported fs and artificially making the nfs client mp-unsafe.