xfs: replace xfs_sb_version checks with feature flag checks
[linux-2.6-microblaze.git] / fs / xfs / libxfs / xfs_dquot_buf.c
index 5a2db00..edd0f41 100644 (file)
@@ -69,6 +69,13 @@ xfs_dquot_verify(
            ddq_type != XFS_DQTYPE_GROUP)
                return __this_address;
 
+       if ((ddq->d_type & XFS_DQTYPE_BIGTIME) &&
+           !xfs_sb_version_hasbigtime(&mp->m_sb))
+               return __this_address;
+
+       if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && !ddq->d_id)
+               return __this_address;
+
        if (id != -1 && id != be32_to_cpu(ddq->d_id))
                return __this_address;
 
@@ -99,7 +106,7 @@ xfs_dqblk_verify(
        struct xfs_dqblk        *dqb,
        xfs_dqid_t              id)     /* used only during quotacheck */
 {
-       if (xfs_sb_version_hascrc(&mp->m_sb) &&
+       if (xfs_has_crc(mp) &&
            !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid))
                return __this_address;
 
@@ -127,7 +134,7 @@ xfs_dqblk_repair(
        dqb->dd_diskdq.d_type = type;
        dqb->dd_diskdq.d_id = cpu_to_be32(id);
 
-       if (xfs_sb_version_hascrc(&mp->m_sb)) {
+       if (xfs_has_crc(mp)) {
                uuid_copy(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid);
                xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
                                 XFS_DQUOT_CRC_OFF);
@@ -144,7 +151,7 @@ xfs_dquot_buf_verify_crc(
        int                     ndquots;
        int                     i;
 
-       if (!xfs_sb_version_hascrc(&mp->m_sb))
+       if (!xfs_has_crc(mp))
                return true;
 
        /*
@@ -288,3 +295,31 @@ const struct xfs_buf_ops xfs_dquot_buf_ra_ops = {
        .verify_read = xfs_dquot_buf_readahead_verify,
        .verify_write = xfs_dquot_buf_write_verify,
 };
+
+/* Convert an on-disk timer value into an incore timer value. */
+time64_t
+xfs_dquot_from_disk_ts(
+       struct xfs_disk_dquot   *ddq,
+       __be32                  dtimer)
+{
+       uint32_t                t = be32_to_cpu(dtimer);
+
+       if (t != 0 && (ddq->d_type & XFS_DQTYPE_BIGTIME))
+               return xfs_dq_bigtime_to_unix(t);
+
+       return t;
+}
+
+/* Convert an incore timer value into an on-disk timer value. */
+__be32
+xfs_dquot_to_disk_ts(
+       struct xfs_dquot        *dqp,
+       time64_t                timer)
+{
+       uint32_t                t = timer;
+
+       if (timer != 0 && (dqp->q_type & XFS_DQTYPE_BIGTIME))
+               t = xfs_dq_unix_to_bigtime(timer);
+
+       return cpu_to_be32(t);
+}