Whamcloud - gitweb
LU-6179 llite: remove LOCKAHEAD_OLD compatibility
[fs/lustre-release.git] / lustre / llite / dir.c
index 7138a04..4f54260 100644 (file)
@@ -412,27 +412,6 @@ out:
        RETURN(rc);
 }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
-static int ll_send_mgc_param(struct obd_export *mgc, char *string)
-{
-        struct mgs_send_param *msp;
-        int rc = 0;
-
-        OBD_ALLOC_PTR(msp);
-        if (!msp)
-                return -ENOMEM;
-
-       strlcpy(msp->mgs_param, string, sizeof(msp->mgs_param));
-        rc = obd_set_info_async(NULL, mgc, sizeof(KEY_SET_INFO), KEY_SET_INFO,
-                                sizeof(struct mgs_send_param), msp, NULL);
-        if (rc)
-                CERROR("Failed to set parameter: %d\n", rc);
-        OBD_FREE_PTR(msp);
-
-        return rc;
-}
-#endif
-
 /**
  * Create striped directory with specified stripe(@lump)
  *
@@ -464,7 +443,7 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
        int err;
        ENTRY;
 
-       if (unlikely(!lmv_magic_supported(lump->lum_magic)))
+       if (unlikely(!lmv_user_magic_supported(lump->lum_magic)))
                RETURN(-EINVAL);
 
        if (lump->lum_magic != LMV_MAGIC_FOREIGN) {
@@ -489,7 +468,26 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
            !OBD_FAIL_CHECK(OBD_FAIL_LLITE_NO_CHECK_DEAD))
                RETURN(-ENOENT);
 
-       if (unlikely(!lmv_magic_supported(cpu_to_le32(lump->lum_magic))))
+       if (!(exp_connect_flags2(sbi->ll_md_exp) & OBD_CONNECT2_CRUSH)) {
+               if ((lump->lum_hash_type & LMV_HASH_TYPE_MASK) ==
+                    LMV_HASH_TYPE_CRUSH) {
+                       /* if server doesn't support 'crush' hash type,
+                        * switch to fnv_1a_64.
+                        */
+                       lump->lum_hash_type &= ~LMV_HASH_TYPE_MASK;
+                       lump->lum_hash_type |= LMV_HASH_TYPE_FNV_1A_64;
+               } else if ((lump->lum_hash_type & LMV_HASH_TYPE_MASK) ==
+                    LMV_HASH_TYPE_UNKNOWN) {
+                       /* from 2.14 MDT will choose default hash type if client
+                        * doesn't set a valid one, while old server doesn't
+                        * handle it.
+                        */
+                       lump->lum_hash_type &= ~LMV_HASH_TYPE_MASK;
+                       lump->lum_hash_type |= LMV_HASH_TYPE_DEFAULT;
+               }
+       }
+
+       if (unlikely(!lmv_user_magic_supported(cpu_to_le32(lump->lum_magic))))
                lustre_swab_lmv_user_md(lump);
 
        if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent)))
@@ -559,10 +557,6 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
        struct md_op_data *op_data;
        struct ptlrpc_request *req = NULL;
        int rc = 0;
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
-       struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
-       struct obd_device *mgc = lsi->lsi_mgc;
-#endif
        int lum_size;
        ENTRY;
 
@@ -624,57 +618,6 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
        if (rc)
                RETURN(rc);
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
-       /*
-        * 2.9 server has stored filesystem default stripe in ROOT xattr,
-        * and it's stored into system config for backward compatibility.
-        *
-        * In the following we use the fact that LOV_USER_MAGIC_V1 and
-        * LOV_USER_MAGIC_V3 have the same initial fields so we do not
-        * need the make the distiction between the 2 versions
-        */
-       if (set_default && mgc->u.cli.cl_mgc_mgsexp &&
-           (lump == NULL ||
-            le32_to_cpu(lump->lmm_magic) == LOV_USER_MAGIC_V1 ||
-            le32_to_cpu(lump->lmm_magic) == LOV_USER_MAGIC_V3)) {
-               char *param = NULL;
-               char *buf;
-
-               OBD_ALLOC(param, MGS_PARAM_MAXLEN);
-               if (param == NULL)
-                       GOTO(end, rc = -ENOMEM);
-
-               buf = param;
-               /* Get fsname and assume devname to be -MDT0000. */
-               snprintf(buf, MGS_PARAM_MAXLEN, "%s-MDT0000.lov",
-                        sbi->ll_fsname);
-               buf += strlen(buf);
-
-               /* Set root stripesize */
-               snprintf(buf, MGS_PARAM_MAXLEN, ".stripesize=%u",
-                        lump ? le32_to_cpu(lump->lmm_stripe_size) : 0);
-               rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
-               if (rc)
-                       GOTO(end, rc);
-
-               /* Set root stripecount */
-               snprintf(buf, MGS_PARAM_MAXLEN, ".stripecount=%hd",
-                        lump ? le16_to_cpu(lump->lmm_stripe_count) : 0);
-               rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
-               if (rc)
-                       GOTO(end, rc);
-
-               /* Set root stripeoffset */
-               snprintf(buf, MGS_PARAM_MAXLEN, ".stripeoffset=%hd",
-                        lump ? le16_to_cpu(lump->lmm_stripe_offset) :
-                               (typeof(lump->lmm_stripe_offset))(-1));
-               rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
-
-end:
-               if (param != NULL)
-                       OBD_FREE(param, MGS_PARAM_MAXLEN);
-       }
-#endif
        RETURN(rc);
 }
 
@@ -1473,7 +1416,7 @@ out_free:
                lum = (struct lmv_user_md *)data->ioc_inlbuf2;
                lumlen = data->ioc_inllen2;
 
-               if (!lmv_magic_supported(lum->lum_magic)) {
+               if (!lmv_user_magic_supported(lum->lum_magic)) {
                        CERROR("%s: wrong lum magic %x : rc = %d\n", filename,
                               lum->lum_magic, -EINVAL);
                        GOTO(lmv_out_free, rc = -EINVAL);
@@ -1494,11 +1437,7 @@ out_free:
                        GOTO(lmv_out_free, rc = -EINVAL);
                }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 50, 0)
-               mode = data->ioc_type != 0 ? data->ioc_type : S_IRWXUGO;
-#else
                mode = data->ioc_type;
-#endif
                rc = ll_dir_setdirstripe(dentry, lum, lumlen, filename, mode);
 lmv_out_free:
                OBD_FREE_LARGE(buf, len);