* 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 *);
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;
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);
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;
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;
* 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:{
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
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;
/* 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,
+ quota_pages, quota_pending, oti, inode,
obj->ioo_bufcnt);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
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);
* 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;
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];
}
}
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;
}
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)
}
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)
{
/* 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;
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++) {
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);
}
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)
}
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)
{
}
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__ */