Whamcloud - gitweb
Branch b_release_1_8_1
authortianzy <tianzy>
Tue, 19 May 2009 10:23:42 +0000 (10:23 +0000)
committertianzy <tianzy>
Tue, 19 May 2009 10:23:42 +0000 (10:23 +0000)
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
lustre/mds/mds_open.c
lustre/mds/mds_reint.c
lustre/obdfilter/filter_io_26.c
lustre/quota/quota_interface.c

index 7609909..cfec87c 100644 (file)
@@ -420,12 +420,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 *);
@@ -637,7 +637,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;
@@ -645,7 +645,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);
@@ -654,7 +654,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;
index 43c1793..2ccdc6e 100644 (file)
@@ -1021,7 +1021,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;
@@ -1209,7 +1209,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);
@@ -1389,9 +1389,9 @@ found_child:
                                 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) {
index cb47f81..a095846 100644 (file)
@@ -977,7 +977,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;
 
@@ -1059,7 +1059,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:{
@@ -1195,9 +1195,9 @@ cleanup:
         err = mds_finish_transno(mds, inodes, handle, req, rc, 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);
 
         if (rc && created) {
                 /* Destroy the file we just created.  This should not need
index 52ea03c..0eeed02 100644 (file)
@@ -580,7 +580,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 quota_rec_pending = 0, quota_pages = 0;
+        int quota_pending[2] = {0, 0}, quota_pages = 0;
         unsigned int qcids[MAXQUOTAS] = {0, 0};
         int sync_journal_commit = obd->u.filter.fo_syncjournal;
         ENTRY;
@@ -657,7 +657,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,
-                        quota_pages, &quota_rec_pending, oti, inode,
+                        quota_pages, quota_pending, oti, inode,
                         obj->ioo_bufcnt);
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
@@ -752,9 +752,9 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         fsfilt_check_slow(obd, now, "commitrw commit");
 
 cleanup:
-        if (quota_rec_pending)
+        if (quota_pending[0] || quota_pending[1])
                 lquota_pending_commit(filter_quota_interface_ref, obd,
-                                      oa->o_uid, oa->o_gid, quota_rec_pending);
+                                      oa->o_uid, oa->o_gid, quota_pending);
 
         filter_grant_commit(exp, niocount, res);
 
index 8109e88..f62e6fa 100644 (file)
@@ -250,7 +250,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;
@@ -288,22 +288,22 @@ 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];
                         }
                 }
 
@@ -324,10 +324,10 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid,
                                 qdata[i].qd_count += lqs->lqs_ino_rec;
                 }
 
-                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;
@@ -360,7 +360,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)
@@ -489,7 +489,7 @@ int quota_is_set(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)
 {
@@ -502,7 +502,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;
@@ -513,10 +513,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 (!ll_sb_any_quota_active(qctxt->lqc_sb))
-                RETURN(0);
 
         do_gettimeofday(&work_start);
         for (i = 0; i < MAXQUOTAS; i++) {
@@ -538,23 +536,26 @@ static int quota_pending_commit(struct obd_device *obd, unsigned int uid,
 
                 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);
@@ -574,9 +575,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)
@@ -636,7 +637,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)
 {
@@ -657,9 +658,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__ */