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>
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).
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
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=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))
" 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"
static int check_hashtype(const char *hashtype)
{
static int check_hashtype(const char *hashtype)
{
+ int type_num = atoi(hashtype);
+ /* 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;