From a4ef4a8b522b5eaa58642b5624a61a1b4ef9d220 Mon Sep 17 00:00:00 2001 From: tianzy Date: Tue, 24 Mar 2009 07:49:16 +0000 Subject: [PATCH] Branch b1_6 lquota won't count for overwrites b=15059 i=shadow i=tianzy --- lustre/obdfilter/filter_io_26.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c index 7e0bc8e..2bbbcaa 100644 --- a/lustre/obdfilter/filter_io_26.c +++ b/lustre/obdfilter/filter_io_26.c @@ -667,7 +667,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, struct obd_device *obd = exp->exp_obd; void *wait_handle = NULL; int total_size = 0; - int rec_pending = 0; + int quota_rec_pending = 0, quota_pages = 0; unsigned int qcids[MAXQUOTAS] = {0, 0}; int sync_journal_commit = obd->u.filter.fo_syncjournal; ENTRY; @@ -679,11 +679,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, oa->o_uid, oa->o_gid, - niocount, &rec_pending, oti, inode, obj->ioo_bufcnt); - iobuf = filter_iobuf_get(&obd->u.filter, oti); if (IS_ERR(iobuf)) GOTO(cleanup, rc = PTR_ERR(iobuf)); @@ -696,10 +691,16 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, for (i = 0, lnb = res; i < obj->ioo_bufcnt; i++, lnb++) { loff_t this_size; - /* If overwriting an existing block, we don't need a grant */ - if (!(lnb->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 (!(lnb->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); @@ -729,6 +730,12 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, } } + /* 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, oa->o_uid, oa->o_gid, + quota_pages, "a_rec_pending, oti, inode, + obj->ioo_bufcnt); + push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); cleanup_phase = 2; @@ -821,9 +828,9 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, fsfilt_check_slow(obd, now, "commitrw commit"); cleanup: - if (rec_pending) + if (quota_rec_pending) lquota_pending_commit(filter_quota_interface_ref, obd, oa->o_uid, - oa->o_gid, rec_pending); + oa->o_gid, quota_rec_pending); filter_grant_commit(exp, niocount, res); -- 1.8.3.1