int ll_obd_statfs(struct inode *inode, void *arg)
{
struct ll_sb_info *sbi = NULL;
- struct obd_device *client_obd = NULL, *lov_obd = NULL;
- struct lov_obd *lov = NULL;
- struct obd_statfs stat_buf = {0};
+ struct obd_export *exp;
char *buf = NULL;
struct obd_ioctl_data *data = NULL;
- __u32 type, index;
+ __u32 type;
int len = 0, rc;
if (!inode || !(sbi = ll_i2sbi(inode)))
GOTO(out_statfs, rc = -EINVAL);
memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
- memcpy(&index, data->ioc_inlbuf2, sizeof(__u32));
-
- if (type == LL_STATFS_MDC) {
- if (index > 0)
- GOTO(out_statfs, rc = -ENODEV);
- client_obd = class_exp2obd(sbi->ll_md_exp);
- } else if (type == LL_STATFS_LOV) {
- lov_obd = class_exp2obd(sbi->ll_dt_exp);
- lov = &lov_obd->u.lov;
-
- if ((index >= lov->desc.ld_tgt_count))
- GOTO(out_statfs, rc = -ENODEV);
- if (!lov->lov_tgts[index])
- /* Try again with the next index */
- GOTO(out_statfs, rc = -EAGAIN);
-
- client_obd = class_exp2obd(lov->lov_tgts[index]->ltd_exp);
- if (!lov->lov_tgts[index]->ltd_active)
- GOTO(out_uuid, rc = -ENODATA);
- }
-
- if (!client_obd)
- GOTO(out_statfs, rc = -EINVAL);
-
- rc = obd_statfs(client_obd, &stat_buf, cfs_time_current_64() - 1);
+ if (type == LL_STATFS_MDC)
+ exp = sbi->ll_md_exp;
+ else if (type == LL_STATFS_LOV)
+ exp = sbi->ll_dt_exp;
+ else
+ GOTO(out_statfs, rc = -ENODEV);
+
+ rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL);
if (rc)
GOTO(out_statfs, rc);
-
- if (copy_to_user(data->ioc_pbuf1, &stat_buf, data->ioc_plen1))
- GOTO(out_statfs, rc = -EFAULT);
-
-out_uuid:
- if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(client_obd),
- data->ioc_plen2))
- rc = -EFAULT;
-
out_statfs:
if (buf)
obd_ioctl_freedata(buf, len);
if (lmv->desc.ld_tgt_count == 0)
RETURN(-ENOTTY);
- for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
- int err;
+ switch (cmd) {
+ case IOC_OBD_STATFS: {
+ struct obd_ioctl_data *data = karg;
+ struct obd_device *mdc_obd;
+ struct obd_statfs stat_buf = {0};
+ __u32 index;
- if (lmv->tgts[i].ltd_exp == NULL)
- continue;
+ memcpy(&index, data->ioc_inlbuf2, sizeof(__u32));
+ LASSERT(data->ioc_plen1 == sizeof(struct obd_statfs));
- err = obd_iocontrol(cmd, lmv->tgts[i].ltd_exp, len, karg, uarg);
- if (err) {
- if (lmv->tgts[i].ltd_active) {
- CERROR("error: iocontrol MDC %s on MDT"
- "idx %d: err = %d\n",
- lmv->tgts[i].ltd_uuid.uuid, i, err);
- if (!rc)
- rc = err;
- }
- } else
- set = 1;
+ if ((index >= lmv->desc.ld_tgt_count))
+ RETURN(-ENODEV);
+
+ if (!lmv->tgts[index].ltd_active)
+ RETURN(-ENODATA);
+
+ mdc_obd = class_exp2obd(lmv->tgts[index].ltd_exp);
+ if (!mdc_obd)
+ RETURN(-EINVAL);
+
+ /* got statfs data */
+ rc = obd_statfs(mdc_obd, &stat_buf, cfs_time_current_64() - 1);
+ if (rc)
+ RETURN(rc);
+ if (copy_to_user(data->ioc_pbuf1, &stat_buf, data->ioc_plen1))
+ RETURN(rc);
+ /* copy UUID */
+ rc = copy_to_user(data->ioc_pbuf2, obd2cli_tgt(mdc_obd),
+ data->ioc_plen2);
+ break;
}
- if (!set && !rc)
- rc = -EIO;
+ default : {
+ for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+ int err;
+ if (lmv->tgts[i].ltd_exp == NULL)
+ continue;
+
+ err = obd_iocontrol(cmd, lmv->tgts[i].ltd_exp, len,
+ karg, uarg);
+ if (err) {
+ if (lmv->tgts[i].ltd_active) {
+ CERROR("error: iocontrol MDC %s on MDT"
+ "idx %d cmd %x: err = %d\n",
+ lmv->tgts[i].ltd_uuid.uuid,
+ i, cmd, err);
+ if (!rc)
+ rc = err;
+ }
+ } else
+ set = 1;
+ }
+ if (!set && !rc)
+ rc = -EIO;
+ }
+ }
RETURN(rc);
}
ENTRY;
switch (cmd) {
+ case IOC_OBD_STATFS: {
+ struct obd_ioctl_data *data = karg;
+ struct obd_device *osc_obd;
+ struct obd_statfs stat_buf = {0};
+ __u32 index;
+
+ memcpy(&index, data->ioc_inlbuf2, sizeof(__u32));
+ LASSERT(data->ioc_plen1 == sizeof(struct obd_statfs));
+
+ if ((index >= count))
+ RETURN(-ENODEV);
+
+ if (!lov->lov_tgts[index])
+ /* Try again with the next index */
+ RETURN(-EAGAIN);
+ if (!lov->lov_tgts[index]->ltd_active)
+ RETURN(-ENODATA);
+
+ osc_obd = class_exp2obd(lov->lov_tgts[index]->ltd_exp);
+ if (!osc_obd)
+ RETURN(-EINVAL);
+
+ /* got statfs data */
+ rc = obd_statfs(osc_obd, &stat_buf, cfs_time_current_64() - 1);
+ if (rc)
+ RETURN(rc);
+ if (copy_to_user(data->ioc_pbuf1, &stat_buf, data->ioc_plen1))
+ RETURN(rc);
+ /* copy UUID */
+ rc = copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd),
+ data->ioc_plen2);
+ break;
+ }
case OBD_IOC_LOV_GET_CONFIG: {
struct obd_ioctl_data *data;
struct lov_desc *desc;