From: Dmitry Eremin Date: Tue, 2 Jun 2015 17:17:46 +0000 (+0300) Subject: LU-6674 utils: fix of uninitilized lmm structure usage X-Git-Tag: 2.7.57~75 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=486d2797fc0d04e2482ecd4c7100919c55d07277 LU-6674 utils: fix of uninitilized lmm structure usage Fill with "fake" the "use the default" values since the lmm struct is zeroed out at this point and not filled by ioctl. Change-Id: I9df005446c5d03bdf561823842afe98ab8d352c1 Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/15109 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Fan Yong Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index c2dcbda..74ab27f 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -1549,7 +1549,7 @@ static int common_param_init(struct find_param *param, char *path) lum_size = PATH_MAX + 1; param->fp_lum_size = lum_size; - param->fp_lmd = malloc(sizeof(lstat_t) + param->fp_lum_size); + param->fp_lmd = calloc(1, sizeof(lstat_t) + param->fp_lum_size); if (param->fp_lmd == NULL) { llapi_error(LLAPI_MSG_ERROR, -ENOMEM, "error: allocation of %zu bytes for ioctl", @@ -1558,7 +1558,8 @@ static int common_param_init(struct find_param *param, char *path) } param->fp_lmv_stripe_count = 256; - param->fp_lmv_md = malloc(lmv_user_md_size(param->fp_lmv_stripe_count, + param->fp_lmv_md = calloc(1, + lmv_user_md_size(param->fp_lmv_stripe_count, LMV_MAGIC_V1)); if (param->fp_lmv_md == NULL) { llapi_error(LLAPI_MSG_ERROR, -ENOMEM, @@ -3025,6 +3026,22 @@ static int cb_find_init(char *path, DIR *parent, DIR **dirp, if (decision == 0) { ret = get_lmd_info(path, parent, dir, param->fp_lmd, param->fp_lum_size); + if (ret == 0 && param->fp_lmd->lmd_lmm.lmm_magic == 0 && + (param->fp_check_pool || param->fp_check_stripe_count || + param->fp_check_stripe_size || param->fp_check_layout)) { + struct lov_user_md *lmm = ¶m->fp_lmd->lmd_lmm; + + /* We need to "fake" the "use the default" values + * since the lmm struct is zeroed out at this point. */ + lmm->lmm_magic = LOV_USER_MAGIC_V1; + lmm->lmm_pattern = 0xFFFFFFFF; + if (!param->fp_raw) + ostid_set_seq(&lmm->lmm_oi, + FID_SEQ_LOV_DEFAULT); + lmm->lmm_stripe_size = 0; + lmm->lmm_stripe_count = 0; + lmm->lmm_stripe_offset = -1; + } if (ret == 0 && param->fp_mdt_uuid != NULL) { if (dir != NULL) { ret = llapi_file_fget_mdtidx(dirfd(dir),