Whamcloud - gitweb
LU-592 1.8 <-> 2.1 interop: missing LMV on client
authorNiu Yawei <niu@whamcloud.com>
Tue, 16 Aug 2011 09:38:20 +0000 (02:38 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 Aug 2011 16:57:21 +0000 (12:57 -0400)
When the cluster is upgraded from 1.8, client will not have LMV layer,
and the "ll_md_exp" is pointing to MDC directly, so the code which
assuming "ll_md_exp" as LMV need be revised:

- ll_dir_ioctl(LL_IOC_GETOBDCOUNT) should return 1 for MDC case;
- mdc_iocontrol() needs to handle the OBD_IOC_QUOTACTL as well when the
  "ll_md_exp" is MDC;

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Change-Id: I3659a5f8076125c9b2012826521c44540e65a75e
Reviewed-on: http://review.whamcloud.com/1236
Tested-by: Hudson
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd.h
lustre/llite/dir.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c

index 91caaa6..fcee1b0 100644 (file)
@@ -1160,6 +1160,7 @@ enum obd_cleanup_stage {
 #define KEY_REGISTER_TARGET     "register_target"
 #define KEY_REVIMP_UPD          "revimp_update"
 #define KEY_SET_FS              "set_fs"
+#define KEY_TGT_COUNT           "tgt_count"
 /*      KEY_SET_INFO in lustre_idl.h */
 #define KEY_SPTLRPC_CONF        "sptlrpc_conf"
 #define KEY_CONNECT_FLAG        "connect_flags"
index b757927..1db1875 100644 (file)
@@ -1483,19 +1483,20 @@ out_free:
         }
 #endif
         case LL_IOC_GETOBDCOUNT: {
-                int count;
+                int count, vallen;
+                struct obd_export *exp;
 
                 if (cfs_copy_from_user(&count, (int *)arg, sizeof(int)))
                         RETURN(-EFAULT);
 
-                if (!count) {
-                        /* get ost count */
-                        struct lov_obd *lov = &sbi->ll_dt_exp->exp_obd->u.lov;
-                        count = lov->desc.ld_tgt_count;
-                } else {
-                        /* get mdt count */
-                        struct lmv_obd *lmv = &sbi->ll_md_exp->exp_obd->u.lmv;
-                        count = lmv->desc.ld_tgt_count;
+                /* get ost count when count is zero, get mdt count otherwise */
+                exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp;
+                vallen = sizeof(count);
+                rc = obd_get_info(exp, sizeof(KEY_TGT_COUNT), KEY_TGT_COUNT,
+                                  &vallen, &count, NULL);
+                if (rc) {
+                        CERROR("get target count failed: %d\n", rc);
+                        RETURN(rc);
                 }
 
                 if (cfs_copy_to_user((int *)arg, &count, sizeof(int)))
index 6b6885e..e0d896d 100644 (file)
@@ -2707,6 +2707,9 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen,
                         ((struct obd_connect_data *)val)->ocd_connect_flags;
                 }
                 RETURN(rc);
+        } else if (KEY_IS(KEY_TGT_COUNT)) {
+                *((int *)val) = lmv->desc.ld_tgt_count;
+                RETURN(0);
         }
 
         CDEBUG(D_IOCTL, "Invalid key\n");
index 4108530..3f1191f 100644 (file)
@@ -2650,6 +2650,9 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen,
 
                 *((__u64*)val) = tgt->ltd_exp->exp_connect_flags;
                 GOTO(out, rc = 0);
+        } else if (KEY_IS(KEY_TGT_COUNT)) {
+                *((int *)val) = lov->desc.ld_tgt_count;
+                GOTO(out, rc = 0);
         }
 
         rc = -EINVAL;
index 3abdd77..83eb2ae 100644 (file)
@@ -1427,10 +1427,11 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 rc = ptlrpc_obd_ping(obd);
                 GOTO(out, rc);
         /*
-         * Normally IOC_OBD_STATFS iocontrol is handled by LMV instead of MDC.
-         * But when the cluster is upgraded from 1.8, there'd be no LMV layer
-         * thus we might be called here. Eventually this code should be removed.
-         * bz20731.
+         * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by
+         * LMV instead of MDC. But when the cluster is upgraded from 1.8,
+         * there'd be no LMV layer thus we might be called here. Eventually
+         * this code should be removed.
+         * bz20731, LU-592.
          */
         case IOC_OBD_STATFS: {
                 struct obd_statfs stat_buf = {0};
@@ -1457,6 +1458,24 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
                 GOTO(out, rc = 0);
         }
+        case OBD_IOC_QUOTACTL: {
+                struct if_quotactl *qctl = karg;
+                struct obd_quotactl *oqctl;
+
+                OBD_ALLOC_PTR(oqctl);
+                if (!oqctl)
+                        RETURN(-ENOMEM);
+
+                QCTL_COPY(oqctl, qctl);
+                rc = obd_quotactl(exp, oqctl);
+                if (rc == 0) {
+                        QCTL_COPY(qctl, oqctl);
+                        qctl->qc_valid = QC_MDTIDX;
+                        qctl->obd_uuid = obd->u.cli.cl_target_uuid;
+                }
+                OBD_FREE_PTR(oqctl);
+                break;
+        }
         case LL_IOC_GET_CONNECT_FLAGS: {
                 if (cfs_copy_to_user(uarg, &exp->exp_connect_flags,
                                      sizeof(__u64)))
@@ -1695,8 +1714,7 @@ int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key,
                 max_easize = val;
                 *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize;
                 RETURN(0);
-        }
-        if (KEY_IS(KEY_CONN_DATA)) {
+        } else if (KEY_IS(KEY_CONN_DATA)) {
                 struct obd_import *imp = class_exp2cliimp(exp);
                 struct obd_connect_data *data = val;
 
@@ -1705,6 +1723,9 @@ int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key,
 
                 *data = imp->imp_connect_data;
                 RETURN(0);
+        } else if (KEY_IS(KEY_TGT_COUNT)) {
+                *((int *)val) = 1;
+                RETURN(0);
         }
 
         rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val);