io_uring: don't keep looping for more events if we can't flush overflow
[linux-2.6-microblaze.git] / fs / xfs / xfs_dquot.c
index 1d95ed3..bd8379b 100644 (file)
@@ -314,8 +314,14 @@ xfs_dquot_disk_alloc(
                return -ESRCH;
        }
 
-       /* Create the block mapping. */
        xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
+
+       error = xfs_iext_count_may_overflow(quotip, XFS_DATA_FORK,
+                       XFS_IEXT_ADD_NOSPLIT_CNT);
+       if (error)
+               return error;
+
+       /* Create the block mapping. */
        error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset,
                        XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA, 0, &map,
                        &nmaps);
@@ -500,6 +506,42 @@ xfs_dquot_alloc(
        return dqp;
 }
 
+/* Check the ondisk dquot's id and type match what the incore dquot expects. */
+static bool
+xfs_dquot_check_type(
+       struct xfs_dquot        *dqp,
+       struct xfs_disk_dquot   *ddqp)
+{
+       uint8_t                 ddqp_type;
+       uint8_t                 dqp_type;
+
+       ddqp_type = ddqp->d_type & XFS_DQTYPE_REC_MASK;
+       dqp_type = xfs_dquot_type(dqp);
+
+       if (be32_to_cpu(ddqp->d_id) != dqp->q_id)
+               return false;
+
+       /*
+        * V5 filesystems always expect an exact type match.  V4 filesystems
+        * expect an exact match for user dquots and for non-root group and
+        * project dquots.
+        */
+       if (xfs_sb_version_hascrc(&dqp->q_mount->m_sb) ||
+           dqp_type == XFS_DQTYPE_USER || dqp->q_id != 0)
+               return ddqp_type == dqp_type;
+
+       /*
+        * V4 filesystems support either group or project quotas, but not both
+        * at the same time.  The non-user quota file can be switched between
+        * group and project quota uses depending on the mount options, which
+        * means that we can encounter the other type when we try to load quota
+        * defaults.  Quotacheck will soon reset the the entire quota file
+        * (including the root dquot) anyway, but don't log scary corruption
+        * reports to dmesg.
+        */
+       return ddqp_type == XFS_DQTYPE_GROUP || ddqp_type == XFS_DQTYPE_PROJ;
+}
+
 /* Copy the in-core quota fields in from the on-disk buffer. */
 STATIC int
 xfs_dquot_from_disk(
@@ -512,8 +554,7 @@ xfs_dquot_from_disk(
         * Ensure that we got the type and ID we were looking for.
         * Everything else was checked by the dquot buffer verifier.
         */
-       if ((ddqp->d_type & XFS_DQTYPE_REC_MASK) != xfs_dquot_type(dqp) ||
-           be32_to_cpu(ddqp->d_id) != dqp->q_id) {
+       if (!xfs_dquot_check_type(dqp, ddqp)) {
                xfs_alert_tag(bp->b_mount, XFS_PTAG_VERIFIER_ERROR,
                          "Metadata corruption detected at %pS, quota %u",
                          __this_address, dqp->q_id);