From b88f2410f2b3e57b9f0b8d76543f277854166c6f Mon Sep 17 00:00:00 2001 From: tianzy Date: Tue, 24 Mar 2009 07:49:20 +0000 Subject: [PATCH] Branch b1_8 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 6c6b021..4e2c505 100644 --- a/lustre/obdfilter/filter_io_26.c +++ b/lustre/obdfilter/filter_io_26.c @@ -574,7 +574,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, struct filter_obd *fo = &obd->u.filter; 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; @@ -586,11 +586,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)); @@ -603,10 +598,16 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, for (i = 0, lnb = res; i < niocount; 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); @@ -647,6 +648,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; @@ -739,9 +746,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_uid, oa->o_gid, quota_rec_pending); filter_grant_commit(exp, niocount, res); -- 1.8.3.1