Whamcloud - gitweb
LU-4843 mdt: disallow old clients access striped dir
[fs/lustre-release.git] / lustre / mdt / mdt_handler.c
index 6b0c683..8ae3794 100644 (file)
@@ -785,9 +785,9 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
 
        if (mdt_object_remote(o)) {
                /* This object is located on remote node.*/
-               /* Return -EIO for old client */
+               /* Return -ENOTSUPP for old client */
                if (!mdt_is_dne_client(req->rq_export))
-                       GOTO(out, rc = -EIO);
+                       GOTO(out, rc = -ENOTSUPP);
 
                repbody->fid1 = *mdt_object_fid(o);
                repbody->valid = OBD_MD_FLID | OBD_MD_MDS;
@@ -897,12 +897,19 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
                         mdt_dump_lmm(D_INFO, ma->ma_lmm, repbody->valid);
                 }
                if (ma->ma_valid & MA_LMV) {
+                       /* Return -ENOTSUPP for old client */
+                       if (!mdt_is_striped_client(req->rq_export))
+                               RETURN(-ENOTSUPP);
+
                        LASSERT(S_ISDIR(la->la_mode));
                        mdt_dump_lmv(D_INFO, ma->ma_lmv);
                        repbody->eadatasize = ma->ma_lmv_size;
                        repbody->valid |= (OBD_MD_FLDIREA|OBD_MD_MEA);
                }
                if (ma->ma_valid & MA_LMV_DEF) {
+                       /* Return -ENOTSUPP for old client */
+                       if (!mdt_is_striped_client(req->rq_export))
+                               RETURN(-ENOTSUPP);
                        LASSERT(S_ISDIR(la->la_mode));
                        repbody->eadatasize = ma->ma_lmv_size;
                        repbody->valid |= (OBD_MD_FLDIREA|OBD_MD_DEFAULT_MEA);
@@ -4666,7 +4673,6 @@ static int mdt_process_config(const struct lu_env *env,
 
        switch (cfg->lcfg_command) {
        case LCFG_PARAM: {
-               struct lprocfs_static_vars  lvars;
                struct obd_device          *obd = d->ld_obd;
 
                /* For interoperability */
@@ -4701,14 +4707,13 @@ static int mdt_process_config(const struct lu_env *env,
                        }
                }
 
-               lprocfs_mdt_init_vars(&lvars);
-               rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars,
-                                             cfg, obd);
+               rc = class_process_proc_seq_param(PARAM_MDT, obd->obd_vars,
+                                                       cfg, obd);
                if (rc > 0 || rc == -ENOSYS) {
                        /* is it an HSM var ? */
-                       rc = class_process_proc_param(PARAM_HSM,
-                                                     hsm_cdt_get_proc_vars(),
-                                                     cfg, obd);
+                       rc = class_process_proc_seq_param(PARAM_HSM,
+                                                       hsm_cdt_get_proc_vars(),
+                                                       cfg, obd);
                        if (rc > 0 || rc == -ENOSYS)
                                /* we don't understand; pass it on */
                                rc = next->ld_ops->ldo_process_config(env, next,
@@ -5340,19 +5345,46 @@ static int mdt_path_current(struct mdt_thread_info *info,
        --ptr;
        pli->pli_fidcount = 0;
        pli->pli_fids[0] = *(struct lu_fid *)mdt_object_fid(pli->pli_mdt_obj);
-
+       *tmpfid = pli->pli_fids[0];
        /* root FID only exists on MDT0, and fid2path should also ends at MDT0,
         * so checking root_fid can only happen on MDT0. */
        while (!lu_fid_eq(&mdt->mdt_md_root_fid,
                          &pli->pli_fids[pli->pli_fidcount])) {
-               mdt_obj = mdt_object_find(info->mti_env, mdt,
-                                         &pli->pli_fids[pli->pli_fidcount]);
+               struct lu_buf           lmv_buf;
+
+               mdt_obj = mdt_object_find(info->mti_env, mdt, tmpfid);
                if (IS_ERR(mdt_obj))
                        GOTO(out, rc = PTR_ERR(mdt_obj));
+
                if (mdt_object_remote(mdt_obj)) {
                        mdt_object_put(info->mti_env, mdt_obj);
                        GOTO(remote_out, rc = -EREMOTE);
                }
+
+               lmv_buf.lb_buf = info->mti_xattr_buf;
+               lmv_buf.lb_len = sizeof(info->mti_xattr_buf);
+
+               /* Check if it is slave stripes */
+               rc = mo_xattr_get(info->mti_env, mdt_object_child(mdt_obj),
+                                 &lmv_buf, XATTR_NAME_LMV);
+               if (rc > 0) {
+                       union lmv_mds_md *lmm = lmv_buf.lb_buf;
+
+                       /* For slave stripes, get its master */
+                       if (le32_to_cpu(lmm->lmv_magic) == LMV_MAGIC_STRIPE) {
+                               struct lmv_mds_md_v1 *lmm1 = &lmm->lmv_md_v1;
+
+                               fid_le_to_cpu(tmpfid, &lmm1->lmv_master_fid);
+                               if (!fid_is_sane(tmpfid)) {
+                                       mdt_object_put(info->mti_env, mdt_obj);
+                                       GOTO(out, rc = -EINVAL);
+                               }
+                               mdt_object_put(info->mti_env, mdt_obj);
+                               pli->pli_fids[pli->pli_fidcount] = *tmpfid;
+                               continue;
+                       }
+               }
+
                if (!mdt_object_exists(mdt_obj)) {
                        mdt_object_put(info->mti_env, mdt_obj);
                        GOTO(out, rc = -ENOENT);
@@ -5905,7 +5937,6 @@ static struct lu_device_type mdt_device_type = {
 
 static int __init mdt_mod_init(void)
 {
-       struct lprocfs_static_vars lvars;
        int rc;
 
        CLASSERT(sizeof("0x0123456789ABCDEF:0x01234567:0x01234567") ==
@@ -5920,10 +5951,9 @@ static int __init mdt_mod_init(void)
        if (rc)
                GOTO(lu_fini, rc);
 
-       lprocfs_mdt_init_vars(&lvars);
        rc = class_register_type(&mdt_obd_device_ops, NULL, true, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                                lvars.module_vars,
+                                NULL,
 #endif
                                 LUSTRE_MDT_NAME, &mdt_device_type);
        if (rc)