From b538826f2bdb39b5dda5bd1131b5b715c51d0bcd Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Tue, 19 Jan 2021 12:06:06 +0800 Subject: [PATCH] LU-14337 lov: return stripe_count=1 instead of 0 for DoM files Return stripe_count=1 instead of 0 for DoM files to avoid divide-by-zero for older userspace that calls this ioctl, e.g. lustre ADIO driver. Signed-off-by: Emoly Liu Change-Id: I43c5e01bdee834f9a05a669a3e6f3d5cd926cb87 Reviewed-on: https://review.whamcloud.com/41265 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lov/lov_pack.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index 77127d5..528f067 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -469,6 +469,14 @@ int lov_getstripe(const struct lu_env *env, struct lov_object *obj, lmm = lmmk; lmm_size = lmmk_size; } + + /** + * Return stripe_count=1 instead of 0 for DoM files to avoid + * divide-by-zero for older userspace that calls this ioctl, + * e.g. lustre ADIO driver. + */ + if ((lum.lmm_stripe_count == 0) && (lum.lmm_pattern & LOV_PATTERN_MDT)) + lum.lmm_stripe_count = 1; /** * User specified limited buffer size, usually the buffer is * from ll_lov_setstripe(), and the buffer can only hold basic -- 1.8.3.1