LLAPI_HSM_STATE_GET(3)
π LLAPI_HSM_STATE_GET(3) π
okay bestie, welcome to the Lustre Library Functions section of the manual, and today's main character is llapi_hsm_state_get β she's the one who tells you what's going on with a file's HSM state, no cap π¦
β¨ NAME β¨
llapi_hsm_state_get, llapi_hsm_state_get_fd β get HSM state information for a file on a Lustre filesystem
β¨ SYNOPSIS β¨
#include <lustre/lustreapi.h>
int llapi_hsm_state_get(const char *path, struct hsm_user_state *hus);
int llapi_hsm_state_get_fd(int fd, struct hsm_user_state *hus);
πΈ DESCRIPTION πΈ
So basically, these functions hand you the HSM state flags and the HSM archive ID for whichever file you're pointing at β either by path or by fd, your choice, we don't gatekeep π
The tea gets poured into the hus argument, and heads up: you gotta have that memory already allocated yourself. She's not malloc-ing for you, that's your job, periodt.
struct hsm_user_state {
__u32 hus_states;
__u32 hus_archive_id;
};
the struct fields, explained (affectionately)
hus_archive_idβ the External HSM archive ID associated with this file π₯hus_statesβ a flag mask for all the different HSM states and policy hints. It's giving bitfield energy, iykyk.
the state flags π
the value of hus_states is literally built by bitwise or'ing all the following possible states together, so like, stack 'em up:
HS_EXISTSβ the file has been assigned to an archive and provided to the backend for archiving. Partial copies may exist in the HSM archive and will need to be deleted when the file is removed. she exists, she's archived-ish, tread carefully π«ΆHS_DIRTYβ the file content is not in sync with the HSM archive. This flag gets set automatically when a file withHS_EXISTSset is changed, and a user can also set it explicitly. messy on purpose πHS_RELEASEDβ the file content is not present in Lustre, and must be restored from the HSM archive before the file can be accessed. Also the file must beHS_ARCHIVEDstate and notHS_DIRTY. so many requirements, honestly iconic πHS_ARCHIVEDβ a complete copy of the file content exists in the HSM archive. slay πHS_NORELEASEβ this flag says the file content should never be released. file content will stay in Lustre even if a copy exists in HSM backend. a user can set this one. she's staying put, no takebacks β¨HS_NOARCHIVEβ the file will not be archived. might be used for a large temporary file, for example. a user can set this. yeah she's not getting archived bestie πHS_LOSTβ the file content in the archive is not available, and the file can not be restored. If this file is alsoHS_RELEASED, then attempts to access the file will fail. An administrator can set this flag. πππ
π RETURN VALUES π
llapi_hsm_state_get() and llapi_hsm_state_get_fd() return:
0β on success π-errnoβ on failure π
π ERRORS π
-ENOMEMβ failed to allocate memory.-ENAMETOOLONGβpathwas too long.-ENOENTβpathdoes not point to a file or a directory.-ENOTTYβpathdoes not point to a Lustre filesystem.
π¦ EXAMPLES π¦
ngl this example is so cute, it just prints out the flags that are set:
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <lustre/lustreapi.h>
int main(int argc, char **argv)
{
struct hsm_user_state hus;
int rc;
if (argc < 2) {
fprintf(stderr, "usage: prog FILEPATH\n");
exit(1);
}
rc = llapi_hsm_state_get(argv[1], &hus);
if (rc) {
fprintf(stderr, "can't get hsm state for %s: %s\n",
argv[1], strerror(-rc));
exit(rc);
}
if (hus.hus_states & HS_RELEASED)
printf(" released");
if (hus.hus_states & HS_EXISTS)
printf(" exists");
if (hus.hus_states & HS_ARCHIVED)
printf(" archived");
/* Display settable flags */
if (hus.hus_states & HS_NORELEASE)
printf(" never_release");
if (hus.hus_states & HS_NOARCHIVE)
printf(" never_archive");
if (hus.hus_states & HS_DIRTY)
printf(" dirty");
if (hus.hus_states & HS_LOST)
printf(" lost_from_hsm");
if (hus.hus_archive_id != 0)
printf(", archive_id:%d", hus.hus_archive_id);
printf("\n");
exit(0);
}
π AVAILABILITY π
llapi_hsm_state_get() and llapi_hsm_state_get_fd() are part of the lustre(7) user application interface library since release 2.4.0 β
π«Ά SEE ALSO π«Ά
lfs-hsm(1), llapi_hsm_state_set(3), llapi_hsm_state_set_fd(3), lustre(7), lustreapi(7)
okay that's the whole page bestie, you're officially HSM-state-literate π
β¨ this was brought to you by the Lustre User API, dated 2024-08-27, under the very important heading LLAPI_HSM_STATE_GET(3) β go forth and state_get responsibly ππ¦π
π¦ where this page comes from
- ubuntu stonking: lustre-client-utils 2.17.58+dfsg-0ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms