From: Emoly Liu Date: Thu, 9 Apr 2020 11:30:12 +0000 (+0800) Subject: LU-13425 lfs: support numeric hash type by "lfs migrate -H" X-Git-Tag: 2.13.54~188 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=bf952126b6adf54d164720dc10379478a62a1b2b LU-13425 lfs: support numeric hash type by "lfs migrate -H" 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 Change-Id: I19cda608b2d28e8e392f03db366767b829ed6dc6 Reviewed-on: https://review.whamcloud.com/38182 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Lai Siyao --- diff --git a/lustre/doc/lfs-migrate.1 b/lustre/doc/lfs-migrate.1 index 7ae355b..b4405e3 100644 --- a/lustre/doc/lfs-migrate.1 +++ b/lustre/doc/lfs-migrate.1 @@ -99,21 +99,21 @@ Use 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 -.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 -.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 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a72963a..8e386c7 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -17045,7 +17045,7 @@ test_230d() { 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)) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 44f2653..96ed408 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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" - " 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" @@ -712,8 +712,14 @@ command_t cmdlist[] = { static int check_hashtype(const char *hashtype) { + int type_num = atoi(hashtype); 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;