Whamcloud - gitweb
LU-882 quota: Quota code compares unsigned < 0
authorNiu Yawei <niu@whamcloud.com>
Mon, 19 Dec 2011 10:01:36 +0000 (02:01 -0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 4 Jan 2012 14:10:54 +0000 (09:10 -0500)
Port from b23858.

In check_cur_qunit(), it checks "if (limit + record < 0)", however,
the limit is unsigned, so this check will be always false, and when
limit is smaller than -record, following "limit += record" will make
limit a unreasonable large value.

This patch also fixed a similar defect in dqacq_handler().

Signed-off-by: Vladimir Saveliev <vladimir.saveliev@oracle.com>
Signed-off-by: Niu Yawei <niu@whamcloud.com>
Change-Id: Iea02143dae5542f1a9f9cc823a684a18031b8a03
Reviewed-on: http://review.whamcloud.com/1889
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/quota/quota_context.c
lustre/quota/quota_interface.c
lustre/quota/quota_master.c

index 05179ec..f1be4f8 100644 (file)
@@ -325,7 +325,7 @@ check_cur_qunit(struct obd_device *obd,
         limit_org = limit;
         /* when a releasing quota req is sent, before it returned
            limit is assigned a small value. limit will overflow */
-        if (limit + record < 0)
+        if (record < 0)
                 usage -= record;
         else
                 limit += record;
index fbf6ee5..01dc6ac 100644 (file)
@@ -333,6 +333,8 @@ static int quota_check_common(struct obd_device *obd, const unsigned int id[],
                                         else
                                                 pending[i] += mb;
                                 }
+                                LASSERTF(pending[i] >= 0, "pending is not valid"
+                                         ", count=%d, mb=%d\n", count, mb);
                                 lqs->lqs_bwrite_pending += pending[i];
                         } else {
                                 pending[i] = count;
index eac45d3..05a8dac 100644 (file)
@@ -454,7 +454,7 @@ int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc)
         case QUOTA_DQREL:
                 /* The usage in administrative file might be incorrect before
                  * recovery done */
-                if (*usage - qdata->qd_count < 0)
+                if (*usage < qdata->qd_count)
                         *usage = 0;
                 else
                         *usage -= qdata->qd_count;