Whamcloud - gitweb
Branch HEAD
authortianzy <tianzy>
Thu, 4 Jun 2009 03:52:16 +0000 (03:52 +0000)
committertianzy <tianzy>
Thu, 4 Jun 2009 03:52:16 +0000 (03:52 +0000)
lquota won't count for overwrites
b=15059
i=shadow
i=tianzy

lustre/obdfilter/filter_io_26.c

index a45d9da..2fac726 100644 (file)
@@ -572,7 +572,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         void *wait_handle;
         int total_size = 0;
         unsigned int qcids[MAXQUOTAS] = { oa->o_uid, oa->o_gid };
-        int rec_pending[MAXQUOTAS] = { 0, 0 };
+        int rec_pending[MAXQUOTAS] = { 0, 0 }, quota_pages = 0;
         ENTRY;
 
         LASSERT(oti != NULL);
@@ -582,12 +582,6 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         if (rc != 0)
                 GOTO(cleanup, rc);
 
-        /* we try to get enough quota to write here, and let ldiskfs
-         * decide if it is out of quota or not b=14783 */
-        lquota_chkquota(filter_quota_interface_ref, obd, qcids, rec_pending,
-                        niocount, oti, LQUOTA_FLAGS_BLK, (void *)inode,
-                        obj->ioo_bufcnt);
-
         iobuf = filter_iobuf_get(&obd->u.filter, oti);
         if (IS_ERR(iobuf))
                 GOTO(cleanup, rc = PTR_ERR(iobuf));
@@ -601,10 +595,14 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
                 loff_t this_size;
                 __u32 flags = lnb->flags;
 
-                /* If overwriting an existing block, we don't need a grant */
-                if (!(flags & OBD_BRW_GRANTED) && lnb->rc == -ENOSPC &&
-                    filter_range_is_mapped(inode, lnb->offset, lnb->len))
-                        lnb->rc = 0;
+                if (filter_range_is_mapped(inode, lnb->offset, lnb->len)) {
+                        /* If overwriting an existing block,
+                         * we don't need a grant */
+                        if (!(flags & OBD_BRW_GRANTED) && lnb->rc == -ENOSPC)
+                                lnb->rc = 0;
+                } else {
+                        quota_pages++;
+                }
 
                 if (lnb->rc) { /* ENOSPC, network RPC error, etc. */
                         CDEBUG(D_INODE, "Skipping [%d] == %d\n", i, lnb->rc);
@@ -644,6 +642,13 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
                         iobuf->dr_ignore_quota = 1;
         }
 
+        /* we try to get enough quota to write here, and let ldiskfs
+         * decide if it is out of quota or not b=14783 */
+        lquota_chkquota(filter_quota_interface_ref, obd, qcids, rec_pending,
+                        quota_pages, oti, LQUOTA_FLAGS_BLK, (void *)inode,
+                        obj->ioo_bufcnt);
+
+
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         cleanup_phase = 2;