Whamcloud - gitweb
LU-13709 utils: 'lfs mkdir -i -1' doesn't work 65/39165/3
authorLai Siyao <lai.siyao@whamcloud.com>
Wed, 24 Jun 2020 12:01:08 +0000 (20:01 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 Jul 2020 07:29:11 +0000 (07:29 +0000)
'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 <lai.siyao@whamcloud.com>
Change-Id: Id4584940cec390a9245e888c96c7873f5afa209e
Reviewed-on: https://review.whamcloud.com/39165
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/lfs.c

index 2fee1c1..715215b 100644 (file)
@@ -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;
+                                       }
                                }
                        }