From 5e26fcd890bb580231c6229b254ea77b1c8357af Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Wed, 24 Jun 2020 20:01:08 +0800 Subject: [PATCH] LU-13709 utils: 'lfs mkdir -i -1' doesn't work 'lfs mkdir -i -1 -c...' is to create directory on MDTs by space usage, when stripe count is more than 1, the target MDT list is not correctly initialized, which will cause command fail. Signed-off-by: Lai Siyao Change-Id: Id4584940cec390a9245e888c96c7873f5afa209e Reviewed-on: https://review.whamcloud.com/39165 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/utils/lfs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 2fee1c1..715215b 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -5356,9 +5356,9 @@ static int lfs_setdirstripe(int argc, char **argv) } if (auto_distributed) { - int r; int nr = MAX(param->lsp_stripe_count, lsb->sb_count / 2); + int r; /* don't use server whose usage is above 90% */ while (nr != param->lsp_stripe_count && @@ -5374,11 +5374,15 @@ static int lfs_setdirstripe(int argc, char **argv) lsb->sb_buf[r].sd_index; if (param->lsp_stripe_count > 1) { int i = 0; + int j; param->lsp_is_specific = true; - for (; i < param->lsp_stripe_count; i++) - param->lsp_tgts[(i + r) % nr] = - lsb->sb_buf[i].sd_index; + for (; i < param->lsp_stripe_count; + i++) { + j = (i + r) % nr; + param->lsp_tgts[i] = + lsb->sb_buf[j].sd_index; + } } } -- 1.8.3.1