[XFS] Unwrap AIL_LOCK
[safe/jmp/linux-2.6] / fs / xfs / quota / xfs_qm_syscalls.c
index 365a054..ad5579d 100644 (file)
@@ -1,70 +1,54 @@
 /*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation.
  *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.         Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <linux/capability.h>
+
 #include "xfs.h"
 #include "xfs_fs.h"
-#include "xfs_inum.h"
+#include "xfs_bit.h"
 #include "xfs_log.h"
+#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
-#include "xfs_dir.h"
+#include "xfs_ag.h"
 #include "xfs_dir2.h"
 #include "xfs_alloc.h"
 #include "xfs_dmapi.h"
 #include "xfs_quota.h"
 #include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
 #include "xfs_bmap_btree.h"
+#include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
+#include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
+#include "xfs_ialloc.h"
+#include "xfs_itable.h"
 #include "xfs_bmap.h"
-#include "xfs_bit.h"
+#include "xfs_btree.h"
 #include "xfs_rtalloc.h"
 #include "xfs_error.h"
-#include "xfs_itable.h"
 #include "xfs_rw.h"
 #include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
 #include "xfs_attr.h"
 #include "xfs_buf_item.h"
 #include "xfs_utils.h"
-
 #include "xfs_qm.h"
 
 #ifdef DEBUG
@@ -97,22 +81,14 @@ STATIC void xfs_qm_export_dquot(xfs_mount_t *, xfs_disk_dquot_t *,
  */
 int
 xfs_qm_quotactl(
-       struct bhv_desc *bdp,
+       xfs_mount_t     *mp,
        int             cmd,
        int             id,
        xfs_caddr_t     addr)
 {
-       xfs_mount_t     *mp;
        int             error;
-       struct vfs      *vfsp;
-
-       vfsp = bhvtovfs(bdp);
-       mp = XFS_VFSTOM(vfsp);
 
-       if (addr == NULL && cmd != Q_SYNC)
-               return XFS_ERROR(EINVAL);
-       if (id < 0 && cmd != Q_SYNC)
-               return XFS_ERROR(EINVAL);
+       ASSERT(addr != NULL || cmd == Q_XQUOTASYNC);
 
        /*
         * The following commands are valid even when quotaoff.
@@ -122,9 +98,9 @@ xfs_qm_quotactl(
                /*
                 * Truncate quota files. quota must be off.
                 */
-               if (XFS_IS_QUOTA_ON(mp) || addr == NULL)
+               if (XFS_IS_QUOTA_ON(mp))
                        return XFS_ERROR(EINVAL);
-               if (vfsp->vfs_flag & VFS_RDONLY)
+               if (mp->m_flags & XFS_MOUNT_RDONLY)
                        return XFS_ERROR(EROFS);
                return (xfs_qm_scall_trunc_qfiles(mp,
                               xfs_qm_import_qtype_flags(*(uint *)addr)));
@@ -140,18 +116,19 @@ xfs_qm_quotactl(
                 * QUOTAON - enabling quota enforcement.
                 * Quota accounting must be turned on at mount time.
                 */
-               if (addr == NULL)
-                       return XFS_ERROR(EINVAL);
-               if (vfsp->vfs_flag & VFS_RDONLY)
+               if (mp->m_flags & XFS_MOUNT_RDONLY)
                        return XFS_ERROR(EROFS);
                return (xfs_qm_scall_quotaon(mp,
                                          xfs_qm_import_flags(*(uint *)addr)));
 
        case Q_XQUOTAOFF:
-               if (vfsp->vfs_flag & VFS_RDONLY)
+               if (mp->m_flags & XFS_MOUNT_RDONLY)
                        return XFS_ERROR(EROFS);
                break;
 
+       case Q_XQUOTASYNC:
+               return (xfs_sync_inodes(mp, SYNC_DELWRI, NULL));
+
        default:
                break;
        }
@@ -161,7 +138,7 @@ xfs_qm_quotactl(
 
        switch (cmd) {
        case Q_XQUOTAOFF:
-               if (vfsp->vfs_flag & VFS_RDONLY)
+               if (mp->m_flags & XFS_MOUNT_RDONLY)
                        return XFS_ERROR(EROFS);
                error = xfs_qm_scall_quotaoff(mp,
                                            xfs_qm_import_flags(*(uint *)addr),
@@ -182,19 +159,19 @@ xfs_qm_quotactl(
                break;
 
        case Q_XSETQLIM:
-               if (vfsp->vfs_flag & VFS_RDONLY)
+               if (mp->m_flags & XFS_MOUNT_RDONLY)
                        return XFS_ERROR(EROFS);
                error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_USER,
                                             (fs_disk_quota_t *)addr);
                break;
        case Q_XSETGQLIM:
-               if (vfsp->vfs_flag & VFS_RDONLY)
+               if (mp->m_flags & XFS_MOUNT_RDONLY)
                        return XFS_ERROR(EROFS);
                error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_GROUP,
                                             (fs_disk_quota_t *)addr);
                break;
        case Q_XSETPQLIM:
-               if (vfsp->vfs_flag & VFS_RDONLY)
+               if (mp->m_flags & XFS_MOUNT_RDONLY)
                        return XFS_ERROR(EROFS);
                error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_PROJ,
                                             (fs_disk_quota_t *)addr);
@@ -250,7 +227,7 @@ xfs_qm_scall_quotaoff(
         */
        ASSERT(mp->m_quotainfo);
        if (mp->m_quotainfo)
-               mutex_lock(&(XFS_QI_QOFFLOCK(mp)), PINOD);
+               mutex_lock(&(XFS_QI_QOFFLOCK(mp)));
 
        ASSERT(mp->m_quotainfo);
 
@@ -474,9 +451,7 @@ xfs_qm_scall_quotaon(
            ||
            ((flags & XFS_PQUOTA_ACCT) == 0 &&
            (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 &&
-           (flags & XFS_OQUOTA_ENFD))
-           ||
-           ((flags & XFS_GQUOTA_ACCT) == 0 &&
+           (flags & XFS_GQUOTA_ACCT) == 0 &&
            (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 &&
            (flags & XFS_OQUOTA_ENFD))) {
                qdprintk("Can't enforce without acct, flags=%x sbflags=%x\n",
@@ -525,7 +500,7 @@ xfs_qm_scall_quotaon(
        /*
         * Switch on quota enforcement in core.
         */
-       mutex_lock(&(XFS_QI_QOFFLOCK(mp)), PINOD);
+       mutex_lock(&(XFS_QI_QOFFLOCK(mp)));
        mp->m_qflags |= (flags & XFS_ALL_QUOTA_ENFD);
        mutex_unlock(&(XFS_QI_QOFFLOCK(mp)));
 
@@ -617,7 +592,8 @@ xfs_qm_scall_setqlim(
        if (!capable(CAP_SYS_ADMIN))
                return XFS_ERROR(EPERM);
 
-       if ((newlim->d_fieldmask & (FS_DQ_LIMIT_MASK|FS_DQ_TIMER_MASK)) == 0)
+       if ((newlim->d_fieldmask &
+           (FS_DQ_LIMIT_MASK|FS_DQ_TIMER_MASK|FS_DQ_WARNS_MASK)) == 0)
                return (0);
 
        tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM);
@@ -633,7 +609,7 @@ xfs_qm_scall_setqlim(
         * a quotaoff from happening). (XXXThis doesn't currently happen
         * because we take the vfslock before calling xfs_qm_sysent).
         */
-       mutex_lock(&(XFS_QI_QOFFLOCK(mp)), PINOD);
+       mutex_lock(&(XFS_QI_QOFFLOCK(mp)));
 
        /*
         * Get the dquot (locked), and join it to the transaction.
@@ -654,13 +630,13 @@ xfs_qm_scall_setqlim(
         */
        hard = (newlim->d_fieldmask & FS_DQ_BHARD) ?
                (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) :
-                       INT_GET(ddq->d_blk_hardlimit, ARCH_CONVERT);
+                       be64_to_cpu(ddq->d_blk_hardlimit);
        soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ?
                (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) :
-                       INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT);
+                       be64_to_cpu(ddq->d_blk_softlimit);
        if (hard == 0 || hard >= soft) {
-               INT_SET(ddq->d_blk_hardlimit, ARCH_CONVERT, hard);
-               INT_SET(ddq->d_blk_softlimit, ARCH_CONVERT, soft);
+               ddq->d_blk_hardlimit = cpu_to_be64(hard);
+               ddq->d_blk_softlimit = cpu_to_be64(soft);
                if (id == 0) {
                        mp->m_quotainfo->qi_bhardlimit = hard;
                        mp->m_quotainfo->qi_bsoftlimit = soft;
@@ -670,13 +646,13 @@ xfs_qm_scall_setqlim(
        }
        hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ?
                (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) :
-                       INT_GET(ddq->d_rtb_hardlimit, ARCH_CONVERT);
+                       be64_to_cpu(ddq->d_rtb_hardlimit);
        soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ?
                (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) :
-                       INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT);
+                       be64_to_cpu(ddq->d_rtb_softlimit);
        if (hard == 0 || hard >= soft) {
-               INT_SET(ddq->d_rtb_hardlimit, ARCH_CONVERT, hard);
-               INT_SET(ddq->d_rtb_softlimit, ARCH_CONVERT, soft);
+               ddq->d_rtb_hardlimit = cpu_to_be64(hard);
+               ddq->d_rtb_softlimit = cpu_to_be64(soft);
                if (id == 0) {
                        mp->m_quotainfo->qi_rtbhardlimit = hard;
                        mp->m_quotainfo->qi_rtbsoftlimit = soft;
@@ -687,13 +663,13 @@ xfs_qm_scall_setqlim(
 
        hard = (newlim->d_fieldmask & FS_DQ_IHARD) ?
                (xfs_qcnt_t) newlim->d_ino_hardlimit :
-                       INT_GET(ddq->d_ino_hardlimit, ARCH_CONVERT);
+                       be64_to_cpu(ddq->d_ino_hardlimit);
        soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ?
                (xfs_qcnt_t) newlim->d_ino_softlimit :
-                       INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT);
+                       be64_to_cpu(ddq->d_ino_softlimit);
        if (hard == 0 || hard >= soft) {
-               INT_SET(ddq->d_ino_hardlimit, ARCH_CONVERT, hard);
-               INT_SET(ddq->d_ino_softlimit, ARCH_CONVERT, soft);
+               ddq->d_ino_hardlimit = cpu_to_be64(hard);
+               ddq->d_ino_softlimit = cpu_to_be64(soft);
                if (id == 0) {
                        mp->m_quotainfo->qi_ihardlimit = hard;
                        mp->m_quotainfo->qi_isoftlimit = soft;
@@ -702,26 +678,43 @@ xfs_qm_scall_setqlim(
                qdprintk("ihard %Ld < isoft %Ld\n", hard, soft);
        }
 
+       /*
+        * Update warnings counter(s) if requested
+        */
+       if (newlim->d_fieldmask & FS_DQ_BWARNS)
+               ddq->d_bwarns = cpu_to_be16(newlim->d_bwarns);
+       if (newlim->d_fieldmask & FS_DQ_IWARNS)
+               ddq->d_iwarns = cpu_to_be16(newlim->d_iwarns);
+       if (newlim->d_fieldmask & FS_DQ_RTBWARNS)
+               ddq->d_rtbwarns = cpu_to_be16(newlim->d_rtbwarns);
+
        if (id == 0) {
                /*
                 * Timelimits for the super user set the relative time
                 * the other users can be over quota for this file system.
                 * If it is zero a default is used.  Ditto for the default
-                * soft and hard limit values (already done, above).
+                * soft and hard limit values (already done, above), and
+                * for warnings.
                 */
                if (newlim->d_fieldmask & FS_DQ_BTIMER) {
                        mp->m_quotainfo->qi_btimelimit = newlim->d_btimer;
-                       INT_SET(ddq->d_btimer, ARCH_CONVERT, newlim->d_btimer);
+                       ddq->d_btimer = cpu_to_be32(newlim->d_btimer);
                }
                if (newlim->d_fieldmask & FS_DQ_ITIMER) {
                        mp->m_quotainfo->qi_itimelimit = newlim->d_itimer;
-                       INT_SET(ddq->d_itimer, ARCH_CONVERT, newlim->d_itimer);
+                       ddq->d_itimer = cpu_to_be32(newlim->d_itimer);
                }
                if (newlim->d_fieldmask & FS_DQ_RTBTIMER) {
                        mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer;
-                       INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, newlim->d_rtbtimer);
+                       ddq->d_rtbtimer = cpu_to_be32(newlim->d_rtbtimer);
                }
-       } else /* if (XFS_IS_QUOTA_ENFORCED(mp)) */ {
+               if (newlim->d_fieldmask & FS_DQ_BWARNS)
+                       mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns;
+               if (newlim->d_fieldmask & FS_DQ_IWARNS)
+                       mp->m_quotainfo->qi_iwarnlimit = newlim->d_iwarns;
+               if (newlim->d_fieldmask & FS_DQ_RTBWARNS)
+                       mp->m_quotainfo->qi_rtbwarnlimit = newlim->d_rtbwarns;
+       } else {
                /*
                 * If the user is now over quota, start the timelimit.
                 * The user will not be 'warned'.
@@ -735,7 +728,7 @@ xfs_qm_scall_setqlim(
        xfs_trans_log_dquot(tp, dqp);
 
        xfs_dqtrace_entry(dqp, "Q_SETQLIM: COMMIT");
-       xfs_trans_commit(tp, 0, NULL);
+       xfs_trans_commit(tp, 0);
        xfs_qm_dqprint(dqp);
        xfs_qm_dqrele(dqp);
        mutex_unlock(&(XFS_QI_QOFFLOCK(mp)));
@@ -809,7 +802,7 @@ xfs_qm_log_quotaoff_end(
         * We don't care about quotoff's performance.
         */
        xfs_trans_set_sync(tp);
-       error = xfs_trans_commit(tp, 0, NULL);
+       error = xfs_trans_commit(tp, 0);
        return (error);
 }
 
@@ -852,7 +845,7 @@ xfs_qm_log_quotaoff(
         * We don't care about quotoff's performance.
         */
        xfs_trans_set_sync(tp);
-       error = xfs_trans_commit(tp, 0, NULL);
+       error = xfs_trans_commit(tp, 0);
 
 error0:
        if (error) {
@@ -884,47 +877,46 @@ xfs_qm_export_dquot(
 {
        memset(dst, 0, sizeof(*dst));
        dst->d_version = FS_DQUOT_VERSION;  /* different from src->d_version */
-       dst->d_flags =
-               xfs_qm_export_qtype_flags(INT_GET(src->d_flags, ARCH_CONVERT));
-       dst->d_id = INT_GET(src->d_id, ARCH_CONVERT);
-       dst->d_blk_hardlimit = (__uint64_t)
-               XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_hardlimit, ARCH_CONVERT));
-       dst->d_blk_softlimit = (__uint64_t)
-               XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_softlimit, ARCH_CONVERT));
-       dst->d_ino_hardlimit = (__uint64_t)
-               INT_GET(src->d_ino_hardlimit, ARCH_CONVERT);
-       dst->d_ino_softlimit = (__uint64_t)
-               INT_GET(src->d_ino_softlimit, ARCH_CONVERT);
-       dst->d_bcount = (__uint64_t)
-               XFS_FSB_TO_BB(mp, INT_GET(src->d_bcount, ARCH_CONVERT));
-       dst->d_icount = (__uint64_t) INT_GET(src->d_icount, ARCH_CONVERT);
-       dst->d_btimer = (__uint32_t) INT_GET(src->d_btimer, ARCH_CONVERT);
-       dst->d_itimer = (__uint32_t) INT_GET(src->d_itimer, ARCH_CONVERT);
-       dst->d_iwarns = INT_GET(src->d_iwarns, ARCH_CONVERT);
-       dst->d_bwarns = INT_GET(src->d_bwarns, ARCH_CONVERT);
-
-       dst->d_rtb_hardlimit = (__uint64_t)
-               XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_hardlimit, ARCH_CONVERT));
-       dst->d_rtb_softlimit = (__uint64_t)
-               XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_softlimit, ARCH_CONVERT));
-       dst->d_rtbcount = (__uint64_t)
-               XFS_FSB_TO_BB(mp, INT_GET(src->d_rtbcount, ARCH_CONVERT));
-       dst->d_rtbtimer = (__uint32_t) INT_GET(src->d_rtbtimer, ARCH_CONVERT);
-       dst->d_rtbwarns = INT_GET(src->d_rtbwarns, ARCH_CONVERT);
+       dst->d_flags = xfs_qm_export_qtype_flags(src->d_flags);
+       dst->d_id = be32_to_cpu(src->d_id);
+       dst->d_blk_hardlimit =
+               XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_hardlimit));
+       dst->d_blk_softlimit =
+               XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_softlimit));
+       dst->d_ino_hardlimit = be64_to_cpu(src->d_ino_hardlimit);
+       dst->d_ino_softlimit = be64_to_cpu(src->d_ino_softlimit);
+       dst->d_bcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_bcount));
+       dst->d_icount = be64_to_cpu(src->d_icount);
+       dst->d_btimer = be32_to_cpu(src->d_btimer);
+       dst->d_itimer = be32_to_cpu(src->d_itimer);
+       dst->d_iwarns = be16_to_cpu(src->d_iwarns);
+       dst->d_bwarns = be16_to_cpu(src->d_bwarns);
+       dst->d_rtb_hardlimit =
+               XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_hardlimit));
+       dst->d_rtb_softlimit =
+               XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_softlimit));
+       dst->d_rtbcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtbcount));
+       dst->d_rtbtimer = be32_to_cpu(src->d_rtbtimer);
+       dst->d_rtbwarns = be16_to_cpu(src->d_rtbwarns);
 
        /*
         * Internally, we don't reset all the timers when quota enforcement
-        * gets turned off. No need to confuse the userlevel code,
+        * gets turned off. No need to confuse the user level code,
         * so return zeroes in that case.
         */
-       if (! XFS_IS_QUOTA_ENFORCED(mp)) {
+       if ((!XFS_IS_UQUOTA_ENFORCED(mp) && src->d_flags == XFS_DQ_USER) ||
+           (!XFS_IS_OQUOTA_ENFORCED(mp) &&
+                       (src->d_flags & (XFS_DQ_PROJ | XFS_DQ_GROUP)))) {
                dst->d_btimer = 0;
                dst->d_itimer = 0;
                dst->d_rtbtimer = 0;
        }
 
 #ifdef DEBUG
-       if (XFS_IS_QUOTA_ENFORCED(mp) && dst->d_id != 0) {
+       if (((XFS_IS_UQUOTA_ENFORCED(mp) && dst->d_flags == XFS_USER_QUOTA) ||
+            (XFS_IS_OQUOTA_ENFORCED(mp) &&
+                       (dst->d_flags & (XFS_PROJ_QUOTA | XFS_GROUP_QUOTA)))) &&
+           dst->d_id != 0) {
                if (((int) dst->d_bcount >= (int) dst->d_blk_softlimit) &&
                    (dst->d_blk_softlimit > 0)) {
                        ASSERT(dst->d_btimer != 0);
@@ -1035,16 +1027,15 @@ xfs_qm_dqrele_all_inodes(
        struct xfs_mount *mp,
        uint             flags)
 {
-       vmap_t          vmap;
        xfs_inode_t     *ip, *topino;
        uint            ireclaims;
-       vnode_t         *vp;
+       bhv_vnode_t     *vp;
        boolean_t       vnode_refd;
 
        ASSERT(mp->m_quotainfo);
 
-again:
        XFS_MOUNT_ILOCK(mp);
+again:
        ip = mp->m_inodes;
        if (ip == NULL) {
                XFS_MOUNT_IUNLOCK(mp);
@@ -1072,18 +1063,14 @@ again:
                }
                vnode_refd = B_FALSE;
                if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
-                       /*
-                        * Sample vp mapping while holding the mplock, lest
-                        * we come across a non-existent vnode.
-                        */
-                       VMAP(vp, vmap);
                        ireclaims = mp->m_ireclaims;
                        topino = mp->m_inodes;
-                       XFS_MOUNT_IUNLOCK(mp);
+                       vp = vn_grab(vp);
+                       if (!vp)
+                               goto again;
 
+                       XFS_MOUNT_IUNLOCK(mp);
                        /* XXX restart limit ? */
-                       if ( ! (vp = vn_get(vp, &vmap)))
-                               goto again;
                        xfs_ilock(ip, XFS_ILOCK_EXCL);
                        vnode_refd = B_TRUE;
                } else {
@@ -1119,7 +1106,6 @@ again:
                 */
                if (topino != mp->m_inodes || mp->m_ireclaims != ireclaims) {
                        /* XXX use a sentinel */
-                       XFS_MOUNT_IUNLOCK(mp);
                        goto again;
                }
                ip = ip->i_mnext;
@@ -1210,10 +1196,10 @@ xfs_qm_dqtest_failed(
        qmtest_nfails++;
        if (error)
                cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s",
-                      INT_GET(d->d_id, ARCH_CONVERT), error, reason);
+                      d->d_id, error, reason);
        else
                cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]",
-                      INT_GET(d->d_id, ARCH_CONVERT), reason, (int)a, (int)b);
+                      d->d_id, reason, (int)a, (int)b);
        xfs_qm_dqtest_print(d);
        if (dqp)
                xfs_qm_dqprint(dqp);
@@ -1225,21 +1211,21 @@ xfs_dqtest_cmp2(
        xfs_dquot_t     *dqp)
 {
        int err = 0;
-       if (INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) != d->d_icount) {
+       if (be64_to_cpu(dqp->q_core.d_icount) != d->d_icount) {
                xfs_qm_dqtest_failed(d, dqp, "icount mismatch",
-                       INT_GET(dqp->q_core.d_icount, ARCH_CONVERT),
+                       be64_to_cpu(dqp->q_core.d_icount),
                        d->d_icount, 0);
                err++;
        }
-       if (INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) != d->d_bcount) {
+       if (be64_to_cpu(dqp->q_core.d_bcount) != d->d_bcount) {
                xfs_qm_dqtest_failed(d, dqp, "bcount mismatch",
-                       INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT),
+                       be64_to_cpu(dqp->q_core.d_bcount),
                        d->d_bcount, 0);
                err++;
        }
-       if (INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT) &&
-           INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) >=
-           INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT)) {
+       if (dqp->q_core.d_blk_softlimit &&
+           be64_to_cpu(dqp->q_core.d_bcount) >=
+           be64_to_cpu(dqp->q_core.d_blk_softlimit)) {
                if (!dqp->q_core.d_btimer && dqp->q_core.d_id) {
                        cmn_err(CE_DEBUG,
                                "%d [%s] [0x%p] BLK TIMER NOT STARTED",
@@ -1247,9 +1233,9 @@ xfs_dqtest_cmp2(
                        err++;
                }
        }
-       if (INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT) &&
-           INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) >=
-           INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT)) {
+       if (dqp->q_core.d_ino_softlimit &&
+           be64_to_cpu(dqp->q_core.d_icount) >=
+           be64_to_cpu(dqp->q_core.d_ino_softlimit)) {
                if (!dqp->q_core.d_itimer && dqp->q_core.d_id) {
                        cmn_err(CE_DEBUG,
                                "%d [%s] [0x%p] INO TIMER NOT STARTED",
@@ -1437,7 +1423,7 @@ xfs_qm_internalqcheck(
        xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE | XFS_LOG_SYNC);
        XFS_bflush(mp->m_ddev_targp);
 
-       mutex_lock(&qcheck_lock, PINOD);
+       mutex_lock(&qcheck_lock);
        /* There should be absolutely no quota activity while this
           is going on. */
        qmtest_udqtab = kmem_zalloc(qmtest_hashmask *