Whamcloud - gitweb
LU-13425 lfs: support numeric hash type by "lfs migrate -H" 82/38182/8
authorEmoly Liu <emoly@whamcloud.com>
Thu, 9 Apr 2020 11:30:12 +0000 (19:30 +0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 19 Apr 2020 08:45:10 +0000 (08:45 +0000)
This patch allows "lfs migrate -H" to use numertic hash type in case
of any error message returned by the server in such a form, e.g.
"run 'lfs migrate -m 1 -c 1 -H 3 dir1' to finish migration".

sanity.sh test_230d is modifed a little to verify this patch and
lfs-migrate.1 and lfs migrate usage is updated to reflect this change.

Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I19cda608b2d28e8e392f03db366767b829ed6dc6
Reviewed-on: https://review.whamcloud.com/38182
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
lustre/doc/lfs-migrate.1
lustre/tests/sanity.sh
lustre/utils/lfs.c

index 7ae355b..b4405e3 100644 (file)
@@ -99,21 +99,21 @@ Use
 for the new layout.
 .RS 1.2i
 .TP
 for the new layout.
 .RS 1.2i
 .TP
-.B crush
-CRUSH hash algorithm.  This is a consistent hash
-algorithm, so minimum sub files need to relocate
-during directory restripe.
+.B all_char (type 1)
+Sum of ASCII characters modulo number of MDTs. This
+provides weak hashing of the filename, and is suitable
+for only testing or when the input is known to have
+perfectly uniform distribution (e.g. sequential numbers).
 .TP
 .TP
-.B fnv_1a_64
+.B fnv_1a_64 (type 2)
 Fowler-Noll-Vo (FNV-1a) hash algorithm.  This provides
 reasonably uniform, but not cryptographically strong,
 hashing of the filename. (default)
 .TP
 Fowler-Noll-Vo (FNV-1a) hash algorithm.  This provides
 reasonably uniform, but not cryptographically strong,
 hashing of the filename. (default)
 .TP
-.B all_char
-Sum of ASCII characters modulo number of MDTs. This
-provides weak hashing of the filename, and is suitable
-for only testing or when the input is known to have
-perfectly uniform distribution (e.g. sequential numbers).
+.B crush (type 3)
+CRUSH hash algorithm.  This is a consistent hash
+algorithm, so minimum sub files need to relocate
+during directory restripe.
 .RE
 .P
 Only the root user can migrate directories.  Files that have been archived by
 .RE
 .P
 Only the root user can migrate directories.  Files that have been archived by
index a72963a..8e386c7 100755 (executable)
@@ -17045,7 +17045,7 @@ test_230d() {
        old_count=$((MDSCOUNT - old_index))
        new_index=$((RANDOM % MDSCOUNT))
        new_count=$((MDSCOUNT - new_index))
        old_count=$((MDSCOUNT - old_index))
        new_index=$((RANDOM % MDSCOUNT))
        new_count=$((MDSCOUNT - new_index))
-       new_hash="all_char"
+       new_hash=1 # for all_char
 
        [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
        [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
 
        [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
        [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
index 44f2653..96ed408 100644 (file)
@@ -628,9 +628,9 @@ command_t cmdlist[] = {
         "                      it's the MDT index of first stripe\n"
         "\tmdt_count:  number of MDTs to stripe a directory over\n"
         "\tmdt_hash:   hash type of the striped directory. mdt types:\n"
         "                      it's the MDT index of first stripe\n"
         "\tmdt_count:  number of MDTs to stripe a directory over\n"
         "\tmdt_hash:   hash type of the striped directory. mdt types:\n"
-        "                      crush     CRUSH hash algorithm (default)\n"
-        "                      fnv_1a_64 FNV-1a hash algorithm\n"
-        "                      all_char  sum of characters % MDT_COUNT\n"
+        "              all_char  (type 1)sum of characters % MDT_COUNT\n"
+        "              fnv_1a_64 (type 2)FNV-1a hash algorithm (default)\n"
+        "              crush     (type 3)CRUSH hash algorithm\n"
         "\n"
         "migrate file objects from one OST "
         "layout\nto another (may be not safe with concurent writes).\n"
         "\n"
         "migrate file objects from one OST "
         "layout\nto another (may be not safe with concurent writes).\n"
@@ -712,8 +712,14 @@ command_t cmdlist[] = {
 
 static int check_hashtype(const char *hashtype)
 {
 
 static int check_hashtype(const char *hashtype)
 {
+       int type_num = atoi(hashtype);
        int i;
 
        int i;
 
+       /* numeric hash type */
+       if (hashtype && strlen(hashtype) == 1 &&
+           (type_num > 0 && type_num < LMV_HASH_TYPE_MAX))
+               return type_num;
+       /* string hash type */
        for (i = LMV_HASH_TYPE_ALL_CHARS; i < LMV_HASH_TYPE_MAX; i++)
                if (strcmp(hashtype, mdt_hash_name[i]) == 0)
                        return i;
        for (i = LMV_HASH_TYPE_ALL_CHARS; i < LMV_HASH_TYPE_MAX; i++)
                if (strcmp(hashtype, mdt_hash_name[i]) == 0)
                        return i;