diff mbox series

[9/9] lustre: lov: return stripe_count=1 instead of 0 for DoM files

Message ID 1612832067-1449-10-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series Sync to OpenSFS as of Feb 8, 2021 | expand

Commit Message

James Simmons Feb. 9, 2021, 12:54 a.m. UTC
From: Emoly Liu <emoly@whamcloud.com>

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14337
Lustre-commit: b538826f2bdb39b ("LU-14337 lov: return stripe_count=1 instead of 0 for DoM files")
Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41265
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/lov/lov_pack.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/fs/lustre/lov/lov_pack.c b/fs/lustre/lov/lov_pack.c
index d200a62..ffe9687 100644
--- a/fs/lustre/lov/lov_pack.c
+++ b/fs/lustre/lov/lov_pack.c
@@ -456,6 +456,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