LLAPI_HSM_STATE_SET(3)

πŸ“¦ version 2.17.58, in ubuntu stonking

✨ LLAPI_HSM_STATE_SET(3) ✨

okay bestie, sit down, hydrate, and let me tell you about a lil function from the Lustre Library Functions collection πŸ’– it's called llapi_hsm_state_set, and it's literally the girlboss that sets your HSM flags for you. no cap.


🌸 NAME 🌸

llapi_hsm_state_set, llapi_hsm_state_set_fd β€” set HSM flags for a file on a Lustre filesystem πŸ¦‹


πŸ‘‘ SYNOPSIS πŸ‘‘

#include <lustre/lustreapi.h>

int llapi_hsm_state_set(const char *path, __u64 setmask,
                        __u64 clearmask, __u32 archive_id);

int llapi_hsm_state_set_fd(int fd, __u64 setmask,
                           __u64 clearmask, __u32 archive_id);

two flavors, same energy, pick your fave πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so like, llapi_hsm_state_set() and llapi_hsm_state_set_fd() do the thing where they set, clear HSM flags and modify the archive ID for the file pointed at by path or fd. it's giving glow-up, but for metadata 🌈

  • setmask β€” the mask of flags you wanna add. yes queen, stack them on πŸ’–
  • clearmask β€” the mask of flags you wanna remove. bye bestie, not your era anymore πŸ’€
  • archive_id β€” the archive ID (has to be greater than 0) used for this file. use 0 if you do not want to change it. iconic "leave it alone" behaviour fr fr πŸŽ€
head over to llapi_hsm_state_get(3) if you wanna see which flags are actually available, iykyk πŸ‘€

🫢 RETURN VALUES 🫢

llapi_hsm_state_set() and llapi_hsm_state_set_fd() return:

  • 0 β€” on success πŸŽ‰ slay
  • != 0 β€” on failure, and errno is set appropriately (as it should be, she's communicative) 😭

πŸ’€ ERRORS πŸ’€

okay so when things go sideways, you might catch one of these:

  • -ENOMEM β€” failed to allocate memory. lowkey tragic, no memory no party πŸ™ˆ
  • -ENAMETOOLONG β€” path was too long. that path was yapping too much πŸ’…
  • -ENOENT β€” path does not point to a file or a directory. she's not there bestie, she left πŸ‘‘
  • -ENOTTY β€” path does not point to a Lustre filesystem. wrong universe, girl 🌸
  • -EINVAL β€” the provided masks resulted in an incompatible set of flags. the vibes did not pass the vibe check πŸ’”

πŸ”₯ EXAMPLES πŸ”₯

here's a whole main character moment in C, showing you exactly how it's done:

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#include <lustre/lustreapi.h>

int main(int argc, char **argv)
{
     int rc;

     if (argc < 2) {
          fprintf(stderr, "usage: prog FILEPATH\n");
          exit(1);
     }

     rc = llapi_hsm_state_set(argv[1], HS_DIRTY|HS_NORELEASE, 0, 0);
     if (rc != 0) {
          fprintf(stderr, "Can't change hsm flags for %s: %s\n",
               argv[1], strerror(errno = -rc));
          exit(rc);
     }

     exit(0);
}

notice how the archive_id is 0 there? that's the "don't touch it" energy. periodt πŸŽ€


⭐ AVAILABILITY ⭐

llapi_hsm_state_set and llapi_hsm_state_set_fd are part of the lustre(7) user application interface library since release 2.4.0. yes she's been here a while and she's been serving the whole time πŸ’–βœ¨


🌈 SEE ALSO 🌈


bestie reminder: the flags live over in llapi_hsm_state_get(3), so go read that first before you start throwing masks around πŸŽ€

that's the whole page! written by the Lustre User API girlies on 2024-08-27 β€” stay slaying, stay aligned, and may your errno always be 0 πŸ’…πŸ’–πŸ¦‹

πŸ“¦ where this page comes from