xfs: cleanup quota check on disk blocks and inodes reservations
authorMitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Mon, 6 Feb 2012 12:51:05 +0000 (12:51 +0000)
committerBen Myers <bpm@sgi.com>
Thu, 23 Feb 2012 03:47:52 +0000 (21:47 -0600)
This patch is a cleanup of quota check on disk blocks and inodes
reservations, and changes it as follows.

(1) add a total_count variable to store the total number of
    current usages and new reservations for disk blocks and inodes,
    respectively.

(2) make it more readable to check if the local variables softlimit
    and hardlimit are positive. It has been changed as follows.
    if (softlimit > 0ULL) -> if (softlimit)
    if (hardlimit > 0ULL) -> if (hardlimit)
    This is because they are defined as xfs_qcnt_t which is unsigned.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Ben Myers <bpm@sgi.com>
Cc: Alex Elder <elder@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_trans_dquot.c

index c4ba366d24e65c8fde43fa7a6ca32b4735bce331..877fe6367d2dcfead98bff97c15e794ab75065e7 100644 (file)
@@ -605,7 +605,7 @@ xfs_trans_dqresv(
        time_t          timer;
        xfs_qwarncnt_t  warns;
        xfs_qwarncnt_t  warnlimit;
-       xfs_qcnt_t      count;
+       xfs_qcnt_t      total_count;
        xfs_qcnt_t      *resbcountp;
        xfs_quotainfo_t *q = mp->m_quotainfo;
 
@@ -648,13 +648,12 @@ xfs_trans_dqresv(
                         * hardlimit or exceed the timelimit if we allocate
                         * nblks.
                         */
-                       if (hardlimit > 0ULL &&
-                           hardlimit < nblks + *resbcountp) {
+                       total_count = *resbcountp + nblks;
+                       if (hardlimit && total_count > hardlimit) {
                                xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN);
                                goto error_return;
                        }
-                       if (softlimit > 0ULL &&
-                           softlimit < nblks + *resbcountp) {
+                       if (softlimit && total_count > softlimit) {
                                if ((timer != 0 && get_seconds() > timer) ||
                                    (warns != 0 && warns >= warnlimit)) {
                                        xfs_quota_warn(mp, dqp,
@@ -666,7 +665,7 @@ xfs_trans_dqresv(
                        }
                }
                if (ninos > 0) {
-                       count = be64_to_cpu(dqp->q_core.d_icount);
+                       total_count = be64_to_cpu(dqp->q_core.d_icount) + ninos;
                        timer = be32_to_cpu(dqp->q_core.d_itimer);
                        warns = be16_to_cpu(dqp->q_core.d_iwarns);
                        warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit;
@@ -677,13 +676,11 @@ xfs_trans_dqresv(
                        if (!softlimit)
                                softlimit = q->qi_isoftlimit;
 
-                       if (hardlimit > 0ULL &&
-                           hardlimit < ninos + count) {
+                       if (hardlimit && total_count > hardlimit) {
                                xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN);
                                goto error_return;
                        }
-                       if (softlimit > 0ULL &&
-                           softlimit < ninos + count) {
+                       if (softlimit && total_count > softlimit) {
                                if  ((timer != 0 && get_seconds() > timer) ||
                                     (warns != 0 && warns >= warnlimit)) {
                                        xfs_quota_warn(mp, dqp,