Details
-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
-
3
-
9223372036854775807
Description
There's a fair amount of OBD_OCD_VERSION-ed out code in lustre/utils/ and elsewhere which can be removed or made unconditional:
x:lustre-release# git grep 'OBD_OCD_VERSION(2, [0-9],' lustre/llite/dir.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 50, 0) lustre/ofd/ofd_dev.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 8, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0) lustre/utils/lfs.c:#endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) */ lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD _VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0) lustre/utils/lfs.c:#endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) */ lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/lfs.c:#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0) lustre/utils/liblustreapi.c:#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 9, 53, 0) lustre/utils/liblustreapi_util.c:#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 8, 53, 0)
Attachments
Issue Links
Activity
The 2.13.53 conditionals have been removed in patch https://review.whamcloud.com/38106 "LU-8454 Remove struct mgs_send_param and its users" and the ones for the older versions are removed in patch https://review.whamcloud.com/38109 "LU-6179 llite: remove LOCKAHEAD_OLD compatibility" .
Update: As of November 1, 2019, here are all the conditional code based on Lustre version up to 2.14.50:
lustre/ofd/ofd_dev.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 8, 53, 0)
1726 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 8, 53, 0)
1727 struct ofd_thread_info *info = ofd_info(tsi->tsi_env);
1728 struct lu_fid *fid = &info->fti_fid;
1729
1730 /* For compatible purpose, it needs to convert back to
1731 * OST ID before put it on wire. */
1732 *fid = rep_oa->o_oi.oi_fid;
1733 fid_to_ostid(fid, &rep_oa->o_oi);
1734 #endif
lustre/utils/liblustreapi_util.c:#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 8, 53, 0)
164 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 8, 53, 0) 165 static bool printed; 166 if (!printed) { 167 fprintf(stderr, 168 "%s deprecated, use llapi_get_version_string()\n", 169 __func__); 170 printed = true; 171 } 172 #endif
lustre/llite/dir.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 50, 0)
1427 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 50, 0) 1428 mode = data->ioc_type != 0 ? data->ioc_type : S_IRWXUGO; 1429 #else 1430 mode = data->ioc_type; 1431 #endif
lustre/utils/liblustreapi.c:#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 9, 59, 0)
5076 int llapi_mv(char *path, struct find_param *param) 5077 { 5078 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 9, 59, 0) 5079 static bool printed; 5080 5081 if (!printed) { 5082 llapi_error(LLAPI_MSG_ERROR, -ESTALE, 5083 "llapi_mv() is deprecated, use llapi_migrate_mdt()\n"); 5084 printed = true; 5085 } 5086 #endif 5087 return llapi_migrate_mdt(path, param); 5088 }
lustre/utils/mount_lustre.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0)
61 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0) 62 /* 63 * LU-1783 64 * We only #include a kernel level include file here because 65 * important MS_ flag #defines are missing from the SLES version 66 * of sys/mount.h 67 * In the future if SLES updates sys/mount.h to have a more complete 68 * set of flag #defines we should stop including linux/fs.h 69 */ 70 #if !defined(MS_RDONLY) 71 #include <linux/fs.h> 72 #endif 73 #endif
lustre/llite/llite_lib.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 12, 50, 0)
464 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 12, 50, 0)
465 data->ocd_connect_flags |= OBD_CONNECT_LOCKAHEAD_OLD;
466 #endif
lustre/llite/dir.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
414 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 415 static int ll_send_mgc_param(struct obd_export *mgc, char *string) 416 { 417 struct mgs_send_param *msp; 418 int rc = 0; 419 420 OBD_ALLOC_PTR(msp); 421 if (!msp) 422 return -ENOMEM; 423 424 strlcpy(msp->mgs_param, string, sizeof(msp->mgs_param)); 425 rc = obd_set_info_async(NULL, mgc, sizeof(KEY_SET_INFO), KEY_SET_INFO, 426 sizeof(struct mgs_send_param), msp, NULL); 427 if (rc) 428 CERROR("Failed to set parameter: %d\n", rc); 429 OBD_FREE_PTR(msp); 430 431 return rc; 432 } 433 #endif
lustre/llite/dir.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
561 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
562 struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
563 struct obd_device *mgc = lsi->lsi_mgc;
564 #endif
lustre/llite/dir.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
626 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 627 /* 628 * 2.9 server has stored filesystem default stripe in ROOT xattr, 629 * and it's stored into system config for backward compatibility. 630 * 631 * In the following we use the fact that LOV_USER_MAGIC_V1 and 632 * LOV_USER_MAGIC_V3 have the same initial fields so we do not 633 * need the make the distiction between the 2 versions 634 */ 635 if (set_default && mgc->u.cli.cl_mgc_mgsexp && 636 (lump == NULL || 637 le32_to_cpu(lump->lmm_magic) == LOV_USER_MAGIC_V1 || 638 le32_to_cpu(lump->lmm_magic) == LOV_USER_MAGIC_V3)) { 639 char *param = NULL; 640 char *buf; 641 642 OBD_ALLOC(param, MGS_PARAM_MAXLEN); 643 if (param == NULL) 644 GOTO(end, rc = -ENOMEM); 645 646 buf = param; 647 /* Get fsname and assume devname to be -MDT0000. */ 648 snprintf(buf, MGS_PARAM_MAXLEN, "%s-MDT0000.lov", 649 sbi->ll_fsname); 650 buf += strlen(buf); 651 652 /* Set root stripesize */ 653 snprintf(buf, MGS_PARAM_MAXLEN, ".stripesize=%u", 654 lump ? le32_to_cpu(lump->lmm_stripe_size) : 0); 655 rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param); 656 if (rc) 657 GOTO(end, rc); 658 659 /* Set root stripecount */ 660 snprintf(buf, MGS_PARAM_MAXLEN, ".stripecount=%hd", 661 lump ? le16_to_cpu(lump->lmm_stripe_count) : 0); 662 rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param); 663 if (rc) 664 GOTO(end, rc); 665 666 /* Set root stripeoffset */ 667 snprintf(buf, MGS_PARAM_MAXLEN, ".stripeoffset=%hd", 668 lump ? le16_to_cpu(lump->lmm_stripe_offset) : 669 (typeof(lump->lmm_stripe_offset))(-1)); 670 rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param); 671 672 end: 673 if (param != NULL) 674 OBD_FREE(param, MGS_PARAM_MAXLEN); 675 } 676 #endif
lustre/mgc/mgc_request.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
1067 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 1068 /* Send parameter to MGS*/ 1069 static int mgc_set_mgs_param(struct obd_export *exp, 1070 struct mgs_send_param *msp) 1071 { 1072 struct ptlrpc_request *req; 1073 struct mgs_send_param *req_msp, *rep_msp; 1074 int rc; 1075 ENTRY; 1076 1077 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), 1078 &RQF_MGS_SET_INFO, LUSTRE_MGS_VERSION, 1079 MGS_SET_INFO); 1080 if (!req) 1081 RETURN(-ENOMEM); 1082 1083 req_msp = req_capsule_client_get(&req->rq_pill, &RMF_MGS_SEND_PARAM); 1084 if (!req_msp) { 1085 ptlrpc_req_finished(req); 1086 RETURN(-ENOMEM); 1087 } 1088 1089 memcpy(req_msp, msp, sizeof(*req_msp)); 1090 ptlrpc_request_set_replen(req); 1091 1092 /* Limit how long we will wait for the enqueue to complete */ 1093 req->rq_delay_limit = MGC_SEND_PARAM_LIMIT; 1094 rc = ptlrpc_queue_wait(req); 1095 if (!rc) { 1096 rep_msp = req_capsule_server_get(&req->rq_pill, &RMF_MGS_SEND_PARAM); 1097 memcpy(msp, rep_msp, sizeof(*rep_msp)); 1098 } 1099 1100 ptlrpc_req_finished(req); 1101 1102 RETURN(rc); 1103 } 1104 #endif
lustre/mgc/mgc_request.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
1280 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 1281 if (KEY_IS(KEY_SET_INFO)) { 1282 struct mgs_send_param *msp; 1283 1284 msp = (struct mgs_send_param *)val; 1285 rc = mgc_set_mgs_param(exp, msp); 1286 RETURN(rc); 1287 } 1288 #endif
lustre/mgs/mgs_handler.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
99 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 100 static int mgs_set_info(struct tgt_session_info *tsi) 101 { 102 struct mgs_thread_info *mgi; 103 struct mgs_send_param *msp, *rep_msp; 104 struct lustre_cfg *lcfg; 105 size_t param_len; 106 char *s; 107 int rc; 108 109 ENTRY; 110 111 mgi = mgs_env_info(tsi->tsi_env); 112 if (IS_ERR(mgi)) 113 RETURN(err_serious(PTR_ERR(mgi))); 114 115 msp = req_capsule_client_get(tsi->tsi_pill, &RMF_MGS_SEND_PARAM); 116 if (msp == NULL) 117 RETURN(err_serious(-EFAULT)); 118 119 param_len = strnlen(msp->mgs_param, sizeof(msp->mgs_param)); 120 if (param_len == 0 || param_len == sizeof(msp->mgs_param)) 121 RETURN(-EINVAL); 122 123 /* We only allow '*.lov.stripe{size,count,offset}=*' from an RPC. */ 124 s = strchr(msp->mgs_param, '.'); 125 if (s == NULL) 126 RETURN(-EINVAL); 127 128 if (!str_starts_with(s + 1, "lov.stripesize=") && 129 !str_starts_with(s + 1, "lov.stripecount=") && 130 !str_starts_with(s + 1, "lov.stripeoffset=")) 131 RETURN(-EINVAL); 132 133 /* Construct lustre_cfg structure to pass to function mgs_set_param */ 134 lustre_cfg_bufs_reset(&mgi->mgi_bufs, NULL); 135 lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 1, msp->mgs_param); 136 OBD_ALLOC(lcfg, lustre_cfg_len(mgi->mgi_bufs.lcfg_bufcount, 137 mgi->mgi_bufs.lcfg_buflen)); 138 if (!lcfg) 139 RETURN(-ENOMEM); 140 lustre_cfg_init(lcfg, LCFG_PARAM, &mgi->mgi_bufs); 141 142 rc = mgs_set_param(tsi->tsi_env, exp2mgs_dev(tsi->tsi_exp), lcfg); 143 if (rc) { 144 LCONSOLE_WARN("%s: Unable to set parameter %s: %d\n", 145 tgt_name(tsi->tsi_tgt), msp->mgs_param, rc); 146 GOTO(out_cfg, rc); 147 } 148 149 /* send back the whole msp in the reply */ 150 rep_msp = req_capsule_server_get(tsi->tsi_pill, &RMF_MGS_SEND_PARAM); 151 *rep_msp = *msp; 152 EXIT; 153 out_cfg: 154 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); 155 return rc; 156 } 157 #endif
lustre/mgs/mgs_handler.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
1205 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
1206 TGT_MGS_HDL(HAS_REPLY | IS_MUTABLE, MGS_SET_INFO, mgs_set_info),
1207 #endif
1208 TGT_MGS_HDL(HAS_REPLY | IS_MUTABLE, MGS_TARGET_REG, mgs_target_reg),
lustre/ptlrpc/layout.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
74 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 75 static const struct req_msg_field *mgs_set_info[] = { 76 &RMF_PTLRPC_BODY, 77 &RMF_MGS_SEND_PARAM 78 }; 79 #endif
lustre/ptlrpc/layout.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
760 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
761 &RQF_MGS_SET_INFO,
762 #endif
lustre/ptlrpc/layout.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
905 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 906 struct req_msg_field RMF_MGS_SEND_PARAM = 907 DEFINE_MSGF("mgs_send_param", 0, 908 sizeof(struct mgs_send_param), 909 NULL, NULL); 910 EXPORT_SYMBOL(RMF_MGS_SEND_PARAM); 911 #endif
lustre/ptlrpc/layout.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
1350 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 1351 struct req_format RQF_MGS_SET_INFO = 1352 DEFINE_REQ_FMT0("MGS_SET_INFO", mgs_set_info, 1353 mgs_set_info); 1354 EXPORT_SYMBOL(RQF_MGS_SET_INFO); 1355 #endif
lustre/utils/wirecheck.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
1613 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 1614 static void 1615 check_mgs_send_param(void) 1616 { 1617 BLANK_LINE(); 1618 CHECK_STRUCT(mgs_send_param); 1619 CHECK_CVALUE(MGS_PARAM_MAXLEN); 1620 CHECK_MEMBER(mgs_send_param, mgs_param[MGS_PARAM_MAXLEN]); 1621 } 1622 #endif
lustre/utils/wirecheck.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
2896 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
2897 check_mgs_send_param();
2898 #endif
lustre/include/uapi/linux/lustre/lustre_idl.h:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
2560 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0) 2561 #define MGS_PARAM_MAXLEN 1024 2562 #define KEY_SET_INFO "set_info" 2563 2564 struct mgs_send_param { 2565 char mgs_param[MGS_PARAM_MAXLEN]; 2566 }; 2567 #endif
As of today, Lustre 2.10.58+ still has the following version checks for version 2.x with x <=11:
lustre/ofd/ofd_dev.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 8, 53, 0)
1779 out_nolock: 1780 if (rc == 0) { 1781 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 8, 53, 0) 1782 struct ofd_thread_info *info = ofd_info(tsi->tsi_env); 1783 struct lu_fid *fid = &info->fti_fid; 1784 1785 /* For compatible purpose, it needs to convert back to 1786 * OST ID before put it on wire. */ 1787 *fid = rep_oa->o_oi.oi_fid; 1788 fid_to_ostid(fid, &rep_oa->o_oi); 1789 #endif 1790 rep_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP; 1791 }
lustre/utils/liblustreapi_util.c:#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 8, 53, 0)
160 int llapi_get_version(char *buffer, int buffer_size, char **version) 161 { 162 int rc; 163 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 8, 53, 0) 164 static bool printed; 165 if (!printed) { 166 fprintf(stderr, 167 "%s deprecated, use llapi_get_version_string()\n", 168 __func__); 169 printed = true; 170 } 171 #endif 172
lustre/llite/dir.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 50, 0)
1260 1261 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 50, 0) 1262 mode = data->ioc_type != 0 ? data->ioc_type : S_IRWXUGO; 1263 #else 1264 mode = data->ioc_type; 1265 #endif 1266 rc = ll_dir_setdirstripe(dentry, lum, lumlen, filename, mode);
lustre/utils/liblustreapi.c:#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 9, 59, 0)
4395 int llapi_mv(char *path, struct find_param *param) 4396 { 4397 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 9, 59, 0) 4398 static bool printed; 4399 4400 if (!printed) { 4401 llapi_error(LLAPI_MSG_ERROR, -ESTALE, 4402 "llapi_mv() is deprecated, use llapi_migrate_mdt()\n"); 4403 printed = true; 4404 } 4405 #endif 4406 return llapi_migrate_mdt(path, param); 4407 }
lustre/utils/mount_lustre.c:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0)
61 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0) 62 /* 63 * LU-1783 64 * We only #include a kernel level include file here because 65 * important MS_ flag #defines are missing from the SLES version 66 * of sys/mount.h 67 * In the future if SLES updates sys/mount.h to have a more complete 68 * set of flag #defines we should stop including linux/fs.h 69 */ 70 #if !defined(MS_RDONLY) 71 #include <linux/fs.h> 72 #endif 73 #endif
lustre/include/uapi/linux/lustre/lustre_idl.h:#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 11, 56, 0)
2106 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 11, 56, 0) 2107 /* Since lustre 2.8, this flag will not be needed, instead this DEAD 2108 * and orphan flags will be stored in LMA (see LMAI_ORPHAN) 2109 * Keep this flag just for LFSCK, because it still might meet such 2110 * flag when it checks the old FS */ 2111 #define LMV_HASH_FLAG_DEAD 0x40000000 2112 #endif
Hi Steve,
Can you please have a look at this one?
Thanks.
Joe
> It can't be guaranteed that the tools will be running against a lustre kernel version it was built again.
I agree but when it comes to utilities the version is (mostly) not being used in that way (i.e. to manage ABI compatibility). Instead it's being used to manage deprecation and removal of the utility features, options, etc.
I was pondering if lustre_ver.h really needs to be exposed to user land the other day. It can't be guaranteed that the tools will be running against a lustre kernel version it was built again.
Bring this back since upstream its considered bad to do ifdef with OBD_OCD_VERSION. The better solution would be to use BUILD_BIUG_ON. Also we need to re-examine all the cases if this Lustre version ends up becoming 3.0