From 122480498d7407311474e700feed5fa588cf78a6 Mon Sep 17 00:00:00 2001 From: tianzy Date: Tue, 19 May 2009 10:23:23 +0000 Subject: [PATCH] Branch b_release_1_6_7 This patch fixes: 1. I checked quota_check_common(). This function will check quota for user and group, but only send one return via "pending". In most cases, the pendings should be same. But that is not always the case. 2. if quotaoff runs between lquota_chkquota() and lquota_pending_commit(), the same thing will happen too. That is why it comes: - if (!ll_sb_any_quota_active(qctxt->lqc_sb)) - RETURN(0); 3. change some format of quota log, based upon https://bugzilla.lustre.org/show_bug.cgi?id=18574#c65 b=19495 i=johann i=panda --- lustre/include/lustre_quota.h | 10 +++---- lustre/mds/mds_open.c | 8 +++--- lustre/mds/mds_reint.c | 8 +++--- lustre/obdfilter/filter_io_26.c | 8 +++--- lustre/quota/quota_interface.c | 64 ++++++++++++++++++++--------------------- 5 files changed, 48 insertions(+), 50 deletions(-) diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index 43a0d31..75010a3 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -376,12 +376,12 @@ typedef struct { * can finish a block_write or inode_create rpc. It updates the pending * record of block and inode, acquires quota if necessary */ int (*quota_chkquota) (struct obd_device *, unsigned int, unsigned int, - int, int *, quota_acquire, + int, int [], quota_acquire, struct obd_trans_info *, struct inode *, int); /* For quota client, the actions after the pending write is committed */ int (*quota_pending_commit) (struct obd_device *, unsigned int, - unsigned int, int); + unsigned int, int []); #endif /* For quota client, poll if the quota check done */ int (*quota_poll_check) (struct obd_export *, struct if_quotacheck *); @@ -593,7 +593,7 @@ static inline int lquota_acquire(quota_interface_t *interface, static inline int lquota_chkquota(quota_interface_t *interface, struct obd_device *obd, unsigned int uid, unsigned int gid, int count, - int *flag, struct obd_trans_info *oti, + int pending[2], struct obd_trans_info *oti, struct inode *inode, int frags) { int rc; @@ -601,7 +601,7 @@ static inline int lquota_chkquota(quota_interface_t *interface, QUOTA_CHECK_OP(interface, chkquota); QUOTA_CHECK_OP(interface, acquire); - rc = QUOTA_OP(interface, chkquota)(obd, uid, gid, count, flag, + rc = QUOTA_OP(interface, chkquota)(obd, uid, gid, count, pending, QUOTA_OP(interface, acquire), oti, inode, frags); RETURN(rc); @@ -610,7 +610,7 @@ static inline int lquota_chkquota(quota_interface_t *interface, static inline int lquota_pending_commit(quota_interface_t *interface, struct obd_device *obd, unsigned int uid, unsigned int gid, - int pending) + int pending[2]) { int rc; ENTRY; diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index d4391d7..4457db0 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -936,7 +936,7 @@ int mds_open(struct mds_update_record *rec, int offset, /* Always returning LOOKUP lock if open succesful to guard dentry on client. */ int lock_flags = 0; - int rec_pending = 0; + int quota_pending[2] = {0, 0}; int use_parent, need_open_lock; unsigned int gid = current->fsgid; ENTRY; @@ -1104,7 +1104,7 @@ int mds_open(struct mds_update_record *rec, int offset, * FIXME: after CMD is used, pointer to obd_trans_info* couldn't * be NULL, b=14840 */ lquota_chkquota(mds_quota_interface_ref, obd, - current->fsuid, gid, 1, &rec_pending, + current->fsuid, gid, 1, quota_pending, NULL, NULL, 0); ldlm_reply_set_disposition(rep, DISP_OPEN_CREATE); @@ -1277,9 +1277,9 @@ found_child: req, rc, rep ? rep->lock_policy_res1 : 0, 0); cleanup_no_trans: - if (rec_pending) + if (quota_pending[0] || quota_pending[1]) lquota_pending_commit(mds_quota_interface_ref, obd, - current->fsuid, gid, rec_pending); + current->fsuid, gid, quota_pending); switch (cleanup_phase) { case 2: if (rc && created) { diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 4921f93..0ec2764 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -830,7 +830,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, unsigned int qcids[MAXQUOTAS] = { current->fsuid, current->fsgid }; unsigned int qpids[MAXQUOTAS] = { 0, 0 }; struct lvfs_dentry_params dp = LVFS_DENTRY_PARAMS_INIT; - int rec_pending = 0; + int quota_pending[2] = {0, 0}; unsigned int gid = current->fsgid; ENTRY; @@ -901,7 +901,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, * FIXME: after CMD is used, pointer to obd_trans_info* couldn't * be NULL, b=14840 */ lquota_chkquota(mds_quota_interface_ref, obd, - current->fsuid, gid, 1, &rec_pending, NULL, NULL, 0); + current->fsuid, gid, 1, quota_pending, NULL, NULL, 0); switch (type) { case S_IFREG:{ @@ -1027,9 +1027,9 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, cleanup: err = mds_finish_transno(mds, dir, handle, req, rc, 0, 0); - if (rec_pending) + if (quota_pending[0] || quota_pending[1]) lquota_pending_commit(mds_quota_interface_ref, obd, - current->fsuid, gid, rec_pending); + current->fsuid, gid, quota_pending); if (rc && created) { /* Destroy the file we just created. This should not need diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c index eea1c8e..8afe460 100644 --- a/lustre/obdfilter/filter_io_26.c +++ b/lustre/obdfilter/filter_io_26.c @@ -648,7 +648,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, struct obd_device *obd = exp->exp_obd; void *wait_handle; int total_size = 0; - int rec_pending = 0; + int quota_pending[2] = {0, 0}; unsigned int qcids[MAXQUOTAS] = {0, 0}; ENTRY; @@ -662,7 +662,7 @@ 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, - niocount, &rec_pending, oti, inode, obj->ioo_bufcnt); + niocount, quota_pending, oti, inode, obj->ioo_bufcnt); iobuf = filter_iobuf_get(&obd->u.filter, oti); if (IS_ERR(iobuf)) @@ -792,9 +792,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_pending[0] || quota_pending[1]) lquota_pending_commit(filter_quota_interface_ref, obd, oa->o_uid, - oa->o_gid, rec_pending); + oa->o_gid, quota_pending); filter_grant_commit(exp, niocount, res); diff --git a/lustre/quota/quota_interface.c b/lustre/quota/quota_interface.c index 7aa638c..bc105e2 100644 --- a/lustre/quota/quota_interface.c +++ b/lustre/quota/quota_interface.c @@ -248,7 +248,7 @@ static int filter_quota_acquire(struct obd_device *obd, unsigned int uid, * or inode_create rpc. When need to acquire quota, return QUOTA_RET_ACQUOTA */ static int quota_check_common(struct obd_device *obd, unsigned int uid, unsigned int gid, int count, int cycle, int isblk, - struct inode *inode, int frags, int *pending) + struct inode *inode, int frags, int pending[2]) { struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt; int i; @@ -290,29 +290,29 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid, spin_lock(&lqs->lqs_lock); if (!cycle) { if (isblk) { - *pending = count * CFS_PAGE_SIZE; + pending[i] = count * CFS_PAGE_SIZE; /* in order to complete this write, we need extra * meta blocks. This function can get it through * data needed to be written b=16542 */ - mb = *pending; + mb = pending[i]; LASSERT(inode && frags > 0); if (fsfilt_get_mblk(obd, qctxt->lqc_sb, &mb, inode, frags) < 0) CDEBUG(D_ERROR, "can't get extra meta blocks.\n"); else - *pending += mb; - lqs->lqs_bwrite_pending += *pending; + pending[i] += mb; + lqs->lqs_bwrite_pending += pending[i]; } else { - *pending = count; - lqs->lqs_iwrite_pending += *pending; + pending[i] = count; + lqs->lqs_iwrite_pending += pending[i]; } } - CDEBUG(D_QUOTA, "count: %d, lqs pending: %lu, qd_count: "LPU64 - ", metablocks: %d, isblk: %d, pending: %d.\n", count, + CDEBUG(D_QUOTA, "count=%d lqs_pending=%lu qd_count="LPU64 + " isblk=%d mb=%d pending[%d]=%d\n", count, isblk ? lqs->lqs_bwrite_pending : lqs->lqs_iwrite_pending, - qdata[i].qd_count, mb, isblk, *pending); + qdata[i].qd_count, isblk, mb, i, pending[i]); if (rc2[i] == QUOTA_RET_OK) { if (isblk && qdata[i].qd_count < lqs->lqs_bwrite_pending) rc2[i] = QUOTA_RET_ACQUOTA; @@ -340,7 +340,7 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid, } static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid, - unsigned int gid, int count, int *pending, + unsigned int gid, int count, int pending[2], int isblk, quota_acquire acquire, struct obd_trans_info *oti, struct inode *inode, int frags) @@ -444,7 +444,7 @@ static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid, } static int filter_quota_check(struct obd_device *obd, unsigned int uid, - unsigned int gid, int npage, int *pending, + unsigned int gid, int npage, int pending[2], quota_acquire acquire, struct obd_trans_info *oti, struct inode *inode, int frags) { @@ -455,7 +455,7 @@ static int filter_quota_check(struct obd_device *obd, unsigned int uid, /* when a block_write or inode_create rpc is finished, adjust the record for * pending blocks and inodes*/ static int quota_pending_commit(struct obd_device *obd, unsigned int uid, - unsigned int gid, int pending, int isblk) + unsigned int gid, int pending[2], int isblk) { struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt; struct timeval work_start; @@ -466,10 +466,8 @@ static int quota_pending_commit(struct obd_device *obd, unsigned int uid, struct qunit_data qdata[MAXQUOTAS]; ENTRY; - CDEBUG(D_QUOTA, "commit pending quota for %s\n", obd->obd_name); + CDEBUG(D_QUOTA, "%s: commit pending quota\n", obd->obd_name); CLASSERT(MAXQUOTAS < 4); - if (!sb_any_quota_enabled(qctxt->lqc_sb)) - RETURN(0); do_gettimeofday(&work_start); for (i = 0; i < MAXQUOTAS; i++) { @@ -489,26 +487,26 @@ static int quota_pending_commit(struct obd_device *obd, unsigned int uid, int flag = 0; spin_lock(&lqs->lqs_lock); if (isblk) { - if (lqs->lqs_bwrite_pending >= pending) { - lqs->lqs_bwrite_pending -= pending; + if (lqs->lqs_bwrite_pending >= pending[i]) { + lqs->lqs_bwrite_pending -= pending[i]; flag = 1; } else { - CDEBUG(D_ERROR, - "there are too many blocks!\n"); + CERROR("%s: there are too many blocks!\n", + obd->obd_name); } } else { - if (lqs->lqs_iwrite_pending >= pending) { - lqs->lqs_iwrite_pending -= pending; + if (lqs->lqs_iwrite_pending >= pending[i]) { + lqs->lqs_iwrite_pending -= pending[i]; flag = 1; } else { - CDEBUG(D_ERROR, - "there are too many files!\n"); + CERROR("%s: there are too many files!\n", + obd->obd_name); } } - CDEBUG(D_QUOTA, "lqs pending: %lu, pending: %d, " - "isblk: %d.\n", - isblk ? lqs->lqs_bwrite_pending : - lqs->lqs_iwrite_pending, pending, isblk); + CDEBUG(D_QUOTA, "%s: lqs_pending=%lu pending[%d]=%d isblk=%d\n", + obd->obd_name, + isblk ? lqs->lqs_bwrite_pending : lqs->lqs_iwrite_pending, + i, pending[i], isblk); spin_unlock(&lqs->lqs_lock); lqs_putref(lqs); @@ -529,9 +527,9 @@ static int quota_pending_commit(struct obd_device *obd, unsigned int uid, } static int filter_quota_pending_commit(struct obd_device *obd, unsigned int uid, - unsigned int gid, int blocks) + unsigned int gid, int pending[2]) { - return quota_pending_commit(obd, uid, gid, blocks, LQUOTA_FLAGS_BLK); + return quota_pending_commit(obd, uid, gid, pending, LQUOTA_FLAGS_BLK); } static int mds_quota_init(void) @@ -591,7 +589,7 @@ static int mds_quota_fs_cleanup(struct obd_device *obd) } static int mds_quota_check(struct obd_device *obd, unsigned int uid, - unsigned int gid, int inodes, int *pending, + unsigned int gid, int inodes, int pending[2], quota_acquire acquire, struct obd_trans_info *oti, struct inode *inode, int frags) { @@ -611,9 +609,9 @@ static int mds_quota_acquire(struct obd_device *obd, unsigned int uid, } static int mds_quota_pending_commit(struct obd_device *obd, unsigned int uid, - unsigned int gid, int inodes) + unsigned int gid, int pending[2]) { - return quota_pending_commit(obd, uid, gid, inodes, 0); + return quota_pending_commit(obd, uid, gid, pending, 0); } #endif /* HAVE_QUOTA_SUPPORT */ #endif /* __KERNEL__ */ -- 1.8.3.1