@@ -1215,10 +1215,9 @@ int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl)
break;
}
+ qctl->qc_cmd = cmd;
if (rc)
return rc;
-
- qctl->qc_cmd = cmd;
} else {
struct obd_quotactl *oqctl;
int oqctl_len = sizeof(*oqctl);
@@ -2009,10 +2008,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
}
rc = quotactl_ioctl(inode->i_sb, qctl);
- if (rc == 0 && copy_to_user((void __user *)arg, qctl,
- sizeof(*qctl)))
+ if ((rc == 0 || rc == -ENODATA) &&
+ copy_to_user((void __user *)arg, qctl, sizeof(*qctl)))
rc = -EFAULT;
-
out_quotactl:
kfree(qctl);
return rc;
@@ -845,6 +845,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
case OBD_IOC_QUOTACTL: {
struct if_quotactl *qctl = karg;
struct obd_quotactl *oqctl;
+ struct obd_import *imp;
if (qctl->qc_valid == QC_MDTIDX) {
tgt = lmv_tgt(lmv, qctl->qc_idx);
@@ -863,9 +864,19 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
return -EINVAL;
}
- if (!tgt || !tgt->ltd_exp)
+ if (!tgt)
+ return -ENODEV;
+
+ if (!tgt->ltd_exp)
return -EINVAL;
+ imp = class_exp2cliimp(tgt->ltd_exp);
+ if (!tgt->ltd_active && imp->imp_state != LUSTRE_IMP_IDLE) {
+ qctl->qc_valid = QC_MDTIDX;
+ qctl->obd_uuid = tgt->ltd_uuid;
+ return -ENODATA;
+ }
+
oqctl = kzalloc(sizeof(*oqctl), GFP_KERNEL);
if (!oqctl)
return -ENOMEM;
@@ -3122,7 +3133,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
exp->exp_connect_data = *(struct obd_connect_data *)val;
return rc;
} else if (KEY_IS(KEY_TGT_COUNT)) {
- *((int *)val) = lmv->lmv_mdt_descs.ltd_lmv_desc.ld_tgt_count;
+ *((int *)val) = lmv->lmv_mdt_descs.ltd_tgts_size;
return 0;
}
@@ -1021,13 +1021,17 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
struct if_quotactl *qctl = karg;
struct lov_tgt_desc *tgt = NULL;
struct obd_quotactl *oqctl;
+ struct obd_import *imp;
if (qctl->qc_valid == QC_OSTIDX) {
if (count <= qctl->qc_idx)
return -EINVAL;
tgt = lov->lov_tgts[qctl->qc_idx];
- if (!tgt || !tgt->ltd_exp)
+ if (!tgt)
+ return -ENODEV;
+
+ if (!tgt->ltd_exp)
return -EINVAL;
} else if (qctl->qc_valid == QC_UUID) {
for (i = 0; i < count; i++) {
@@ -1050,6 +1054,13 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
return -EAGAIN;
LASSERT(tgt && tgt->ltd_exp);
+ imp = class_exp2cliimp(tgt->ltd_exp);
+ if (!tgt->ltd_active && imp->imp_state != LUSTRE_IMP_IDLE) {
+ qctl->qc_valid = QC_OSTIDX;
+ qctl->obd_uuid = tgt->ltd_uuid;
+ return -ENODATA;
+ }
+
oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl)
return -ENOMEM;