Whamcloud - gitweb
- ll_obd_statfs() call lov/lmv instead of osc/mdc to get target info.
authortappro <tappro>
Wed, 20 Feb 2008 09:26:12 +0000 (09:26 +0000)
committertappro <tappro>
Wed, 20 Feb 2008 09:26:12 +0000 (09:26 +0000)
  b=13997
  i=umka, h.huang

lustre/llite/llite_lib.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c

index 1c58f0e..11b4805 100644 (file)
@@ -2079,12 +2079,10 @@ struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
 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)))
@@ -2100,42 +2098,16 @@ int ll_obd_statfs(struct inode *inode, void *arg)
                 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);
index 0db253c..0d6a088 100644 (file)
@@ -702,27 +702,62 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
         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);
 }
 
index 430d6ac..f15ede2 100644 (file)
@@ -2232,6 +2232,39 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
         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;