-.TH lfs-hsm 1 "November 9, 2012" Lustre "Lustre/HSM binding utility"
+.TH lfs-hsm 1 "November 20, 2017" Lustre "Lustre/HSM binding utility"
.SH NAME
.Blfs hsm_command
lfs commands used to interact with HSM features
.RB [ --exists ]
.RB [ --archived ]
.RB [ --lost ]
+.RB [ --archive-id ]
.RB <FILE> ...
.br
.SH DESCRIPTION
.TP
.B \\--lost
File copy in HSM backend is not usable anymore and file could not be restored. It should be archived again. (root only)
+.TP
+.B \\--archive-id
+Set archive number identifier in hsm_set command. If archive-id is 0 or option is not provided, then default identifier 0 is used and means no identifier change.
.SH EXAMPLES
.TP
.B Display current HSM flag for foo:
st=$($LFS hsm_state $f)
[[ $? == 0 ]] || error "$LFS hsm_state $f failed"
- local ar=$(echo $st | grep "archive_id" | cut -f5 -d" " |
- cut -f2 -d:)
+ local ar=$(echo $st | grep -oP '(?<=archive_id:).*')
echo $ar
}
}
run_test 1b "Archive, Release & Restore composite file"
+test_1c() {
+ mkdir -p $DIR/$tdir
+ chmod 777 $DIR/$tdir
+
+ local f=$DIR/$tdir/$tfile
+ $RUNAS touch $f
+
+ # Test whether we can set the maximum archive number.
+ local LOCAL_HSM_ARCHIVE_NUMBER=32
+ $LFS hsm_set --exists --archive-id $LOCAL_HSM_ARCHIVE_NUMBER $f ||
+ error "root could not change hsm flags"
+ check_hsm_flags_user $f "0x00000001"
+ echo "verifying archive number is $LOCAL_HSM_ARCHIVE_NUMBER"
+ local st=$(get_hsm_archive_id $f)
+ [[ $st == $LOCAL_HSM_ARCHIVE_NUMBER ]] ||
+ error "wrong archive number, $st != $LOCAL_HSM_ARCHIVE_NUMBER"
+
+ # Test whether setting archive number 0 results in no change.
+ $LFS hsm_set --exists --archive-id 0 $f ||
+ error "root could not change hsm flags"
+ check_hsm_flags_user $f "0x00000001"
+ echo "verifying archive number is still $LOCAL_HSM_ARCHIVE_NUMBER"
+ st=$(get_hsm_archive_id $f)
+ [[ $st == $LOCAL_HSM_ARCHIVE_NUMBER ]] ||
+ error "wrong archive number, $st != $LOCAL_HSM_ARCHIVE_NUMBER"
+
+ # Test whether setting archive number > 32 results in error.
+ $LFS hsm_set --exists --archive-id 33 $f &&
+ error "archive number is larger than 32"
+ check_hsm_flags_user $f "0x00000001"
+
+ # Test whether setting archive number 16 and archived flag.
+ LOCAL_HSM_ARCHIVE_NUMBER=16
+ $LFS hsm_set --exists --archived \
+ --archive-id $LOCAL_HSM_ARCHIVE_NUMBER $f ||
+ error "root could not change hsm flags"
+ check_hsm_flags_user $f "0x00000009"
+ echo "verifying archive number is $LOCAL_HSM_ARCHIVE_NUMBER"
+ st=$(get_hsm_archive_id $f)
+ [[ $st == $LOCAL_HSM_ARCHIVE_NUMBER ]] ||
+ error "wrong archive number, $st != $LOCAL_HSM_ARCHIVE_NUMBER"
+}
+run_test 1c "Check setting archive-id in lfs hsm_set"
+
test_2() {
local f=$DIR/$tdir/$tfile
"undergoing actions) for given files.\n usage: hsm_state <file> ..."},
{"hsm_set", lfs_hsm_set, 0, "Set HSM user flag on specified files.\n"
"usage: hsm_set [--norelease] [--noarchive] [--dirty] [--exists] "
- "[--archived] [--lost] <file> ..."},
+ "[--archived] [--lost] [--archive-id NUM] <file> ..."},
{"hsm_clear", lfs_hsm_clear, 0, "Clear HSM user flag on specified "
"files.\n"
"usage: hsm_clear [--norelease] [--noarchive] [--dirty] [--exists] "
{ .val = 'e', .name = "exists", .has_arg = no_argument },
{ .val = 'l', .name = "lost", .has_arg = no_argument },
{ .val = 'r', .name = "norelease", .has_arg = no_argument },
+ { .val = 'i', .name = "archive-id", .has_arg = required_argument },
{ .name = NULL } };
- char short_opts[] = "lraAde";
+ char short_opts[] = "lraAdei:";
__u64 mask = 0;
int c, rc;
char *path;
+ __u32 archive_id = 0;
+ char *end = NULL;
if (argc < 3)
return CMD_HELP;
case 'e':
mask |= HS_EXISTS;
break;
+ case 'i':
+ archive_id = strtol(optarg, &end, 10);
+ if (*end != '\0') {
+ fprintf(stderr, "invalid archive_id: '%s'\n",
+ end);
+ return CMD_HELP;
+ }
+ break;
case '?':
return CMD_HELP;
default:
/* If mode == 0, this means we apply the mask. */
if (mode == LFS_HSM_SET)
- rc = llapi_hsm_state_set(path, mask, 0, 0);
+ rc = llapi_hsm_state_set(path, mask, 0, archive_id);
else
rc = llapi_hsm_state_set(path, 0, mask, 0);