From b7a894819868636e8212b1948cc486a2f43e9c7c Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Fri, 21 Oct 2011 01:30:46 -0700 Subject: [PATCH] LU-847 quota: client retrieve quota usage directly Current 'lfs quota' sends getquota RPC to MDS, and MDS is responsible for retrieving disk usage from all targets, this scheme will be changed to client retrieving disk usage from all targets directly. This patch addresses the compatibility issue as well: If the getquota returned by MDS has QIF_SPACE, client just trust the disk usage returned by MDS, otherwise, client has to issue RPCs to collect disk usage by itself. Signed-off-by: Niu Yawei Signed-off-by: Johann Lombardi Change-Id: I35526c453033809d2f23b1806b4783f5011e3fa2 Reviewed-on: http://review.whamcloud.com/1570 Tested-by: Hudson Tested-by: Maloo --- lustre/llite/dir.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index fef415d..4e94c2a 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1623,6 +1623,47 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, obd_quotactl(sbi->ll_mdc_exp, oqctl); } + /* If QIF_SPACE is not set, client should collect the + * space usage from OSSs by itself */ + if (cmd == Q_GETQUOTA && + !(oqctl->qc_dqblk.dqb_valid & QIF_SPACE) && + !oqctl->qc_dqblk.dqb_curspace) { + struct obd_quotactl *oqctl_tmp; + + OBD_ALLOC_PTR(oqctl_tmp); + if (oqctl_tmp == NULL) + GOTO(out_quotactl, rc = -ENOMEM); + + oqctl_tmp->qc_cmd = Q_GETOQUOTA; + oqctl_tmp->qc_id = oqctl->qc_id; + oqctl_tmp->qc_type = oqctl->qc_type; + + /* collect space usage from OSTs */ + oqctl_tmp->qc_dqblk.dqb_curspace = 0; + rc = obd_quotactl(sbi->ll_osc_exp, oqctl_tmp); + if (!rc || rc == -EREMOTEIO) { + oqctl->qc_dqblk.dqb_curspace = + oqctl_tmp->qc_dqblk.dqb_curspace; + oqctl->qc_dqblk.dqb_valid |= QIF_SPACE; + } + + /* collect space & inode usage from MDTs */ + oqctl_tmp->qc_dqblk.dqb_curspace = 0; + oqctl_tmp->qc_dqblk.dqb_curinodes = 0; + rc = obd_quotactl(sbi->ll_mdc_exp, oqctl_tmp); + if (!rc || rc == -EREMOTEIO) { + oqctl->qc_dqblk.dqb_curspace += + oqctl_tmp->qc_dqblk.dqb_curspace; + oqctl->qc_dqblk.dqb_curinodes = + oqctl_tmp->qc_dqblk.dqb_curinodes; + oqctl->qc_dqblk.dqb_valid |= QIF_INODES; + } else { + oqctl->qc_dqblk.dqb_valid &= ~QIF_SPACE; + } + + OBD_FREE_PTR(oqctl_tmp); + } + QCTL_COPY(qctl, oqctl); if (copy_to_user((void *)arg, qctl, sizeof(*qctl))) -- 1.8.3.1