@@ -1169,14 +1169,22 @@ int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
!(oqctl->qc_dqblk.dqb_valid & QIF_SPACE) &&
!oqctl->qc_dqblk.dqb_curspace) {
struct obd_quotactl *oqctl_tmp;
+ int qctl_len = sizeof(*oqctl_tmp) + LOV_MAXPOOLNAME + 1;
- oqctl_tmp = kzalloc(sizeof(*oqctl_tmp), GFP_NOFS);
+ oqctl_tmp = kzalloc(qctl_len, GFP_NOFS);
if (!oqctl_tmp) {
rc = -ENOMEM;
goto out;
}
- oqctl_tmp->qc_cmd = Q_GETOQUOTA;
+ if (cmd == LUSTRE_Q_GETQUOTAPOOL) {
+ oqctl_tmp->qc_cmd = LUSTRE_Q_GETQUOTAPOOL;
+ memcpy(oqctl_tmp->qc_poolname,
+ qctl->qc_poolname,
+ LOV_MAXPOOLNAME + 1);
+ } else {
+ oqctl_tmp->qc_cmd = Q_GETOQUOTA;
+ }
oqctl_tmp->qc_id = oqctl->qc_id;
oqctl_tmp->qc_type = oqctl->qc_type;
@@ -1190,6 +1198,7 @@ int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
}
/* collect space & inode usage from MDTs */
+ oqctl_tmp->qc_cmd = Q_GETOQUOTA;
oqctl_tmp->qc_dqblk.dqb_curspace = 0;
oqctl_tmp->qc_dqblk.dqb_curinodes = 0;
rc = obd_quotactl(sbi->ll_md_exp, oqctl_tmp);
@@ -379,4 +379,7 @@ static inline void lov_lsm2layout(struct lov_stripe_md *lsm,
ol->ol_comp_id = 0;
}
}
+
+extern const struct rhashtable_params pools_hash_params;
+extern void lov_pool_putref(struct pool_desc *pool);
#endif
@@ -1220,14 +1220,34 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
{
struct lov_obd *lov = &obd->u.lov;
struct lov_tgt_desc *tgt;
+ struct pool_desc *pool = NULL;
u64 curspace = 0;
u64 bhardlimit = 0;
int i, rc = 0;
if (oqctl->qc_cmd != Q_GETOQUOTA &&
- oqctl->qc_cmd != LUSTRE_Q_SETQUOTA) {
- CERROR("bad quota opc %x for lov obd\n", oqctl->qc_cmd);
- return -EFAULT;
+ oqctl->qc_cmd != LUSTRE_Q_SETQUOTA &&
+ oqctl->qc_cmd != LUSTRE_Q_GETQUOTAPOOL) {
+ rc = -EFAULT;
+ CERROR("%s: bad quota opc %x for lov obd: rc = %d\n",
+ obd->obd_name, oqctl->qc_cmd, rc);
+ return rc;
+ }
+
+ if (oqctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL) {
+ rcu_read_lock();
+ pool = rhashtable_lookup(&lov->lov_pools_hash_body,
+ oqctl->qc_poolname,
+ pools_hash_params);
+ if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
+ pool = NULL;
+ rcu_read_unlock();
+ if (!pool)
+ return -ENOENT;
+ /* Set Q_GETOQUOTA back as targets report it's own
+ * usage and doesn't care about pools
+ */
+ oqctl->qc_cmd = Q_GETOQUOTA;
}
/* for lov tgt */
@@ -1240,11 +1260,16 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
if (!tgt)
continue;
+ if (pool &&
+ tgt_check_index(tgt->ltd_index, &pool->pool_obds))
+ continue;
+
if (!tgt->ltd_active || tgt->ltd_reap) {
if (oqctl->qc_cmd == Q_GETOQUOTA &&
lov->lov_tgts[i]->ltd_activate) {
- rc = -EREMOTEIO;
- CERROR("ost %d is inactive\n", i);
+ rc = -ENETDOWN;
+ CERROR("%s: ost %d is inactive: rc = %d\n",
+ obd->obd_name, i, rc);
} else {
CDEBUG(D_HA, "ost %d is inactive\n", i);
}
@@ -1264,6 +1289,8 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
}
}
lov_tgts_putref(obd);
+ if (pool)
+ lov_pool_putref(pool);
if (oqctl->qc_cmd == Q_GETOQUOTA) {
oqctl->qc_dqblk.dqb_curspace = curspace;
@@ -63,7 +63,7 @@ static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
return strcmp(pool_name, pool->pool_name);
}
-static const struct rhashtable_params pools_hash_params = {
+const struct rhashtable_params pools_hash_params = {
.key_len = 1, /* actually variable */
.key_offset = offsetof(struct pool_desc, pool_name),
.head_offset = offsetof(struct pool_desc, pool_hash),