LLAPI_HSM_COPYTOOL_RECV(3)
π LLAPI_HSM_COPYTOOL_REGISTER(3) β Lustre Library Functions π
okay bestie, so this is a section 3 manpage from the Lustre Library Functions manual, and it's basically the group chat for copytool management. If you've ever needed a copytool to talk to a Lustre filesystem about HSM stuff, this is your page. Sit down, hydrate, let's go π«Ά
β¨ NAME β¨
llapi_hsm_copytool_register, llapi_hsm_copytool_unregister, llapi_hsm_copytool_get_fd, llapi_hsm_copytool_recv, hai_first, hai_next β Lustre API copytool management. that's the whole squad, together, iconic.
πΈ SYNOPSIS πΈ
#include <lustre/lustreapi.h>
int llapi_hsm_copytool_register(struct hsm_copytool_private **priv,
const char *mnt, int archive_count,
int *archives, int rfd_flags);
int llapi_hsm_copytool_unregister(struct hsm_copytool_private **priv);
int llapi_hsm_copytool_get_fd(struct hsm_copytool_private *ct);
int llapi_hsm_copytool_recv(struct hsm_copytool_private *priv,
struct hsm_action_list **hal,
int *msgsize);
struct hsm_action_item *hai_first(struct hsm_action_list *hal);
struct hsm_action_item *hai_next(struct hsm_action_item *hai);
π¦ DESCRIPTION π¦
so. if your copytool app wants to receive HSM requests from a Lustre filesystem, it literally has to register with Lustre first, and that's a call to llapi_hsm_copytool_register(). no registration, no requests. periodt π
mntβ the mountpoint of the Lustre filesystem you're monitoring, bestie. that's the one you're watching.archivesβ an array with up to 32 elements, and each one says which archive IDs to register for. every element is a number from 1 to 32.archive_countβ the number of valid elements in that archive array. like, don't count the garbage at the end, ok?- if any element in
archivesis 0, or ifarchive_countis 0, then all archives will be monitored. (yup, zero means everything, the way that works out π) rfd_flagsβ decides whetherllapi_hsm_copytool_recvis blocking, with0, or non-blocking, withO_NONBLOCK.
llapi_hsm_copytool_register hands you back priv, an opaque pointer that you have to use with all the other functions. it's giving β¨main character handleβ¨ β you don't look inside it, you just carry it around.
llapi_hsm_copytool_unregister unregisters a copytool. priv here is that same opaque handle that llapi_hsm_copytool_register returned. bye bestie, we're done here π
llapi_hsm_copytool_get_fd returns the file descriptor the library uses to communicate with the kernel. heads up: this descriptor is only intended to be used with select(2) or poll(2). that's it. don't get creative. and rfd_flags should have been set to O_NONBLOCK. no cap.
to actually receive the requests, your app has to call llapi_hsm_copytool_recv. when it returns 0, there's a message available in hal, and its size in bytes comes back in msgsize. hal points to a buffer allocated by the Lustre library β allocated by them, not you, so don't you dare free it π β and it contains one or more HSM requests. this buffer is valid until the next call to llapi_hsm_copytool_recv. so use it now or lose it, fr fr.
hal is made of a header of type struct hsm_action_list followed by one or several HSM requests of type struct hsm_action_item:
struct hsm_action_list {
__u32 hal_version;
__u32 hal_count; /* number of hai's to follow */
__u64 hal_compound_id; /* obsolete and may be ignored */
__u64 hal_flags;
__u32 hal_archive_id; /* which archive backend */
__u32 padding1;
char hal_fsname[]; /* null-terminated name of filesystem */
};
struct hsm_action_item {
__u32 hai_len; /* valid size of this struct */
__u32 hai_action; /* hsm_copytool_action, but use known size */
struct lu_fid hai_fid; /* Lustre FID to operated on */
struct lu_fid hai_dfid; /* fid used for data access */
struct hsm_extent hai_extent; /* byte range to operate on */
__u64 hai_cookie; /* action cookie from coordinator */
__u64 hai_gid; /* grouplock id */
char hai_data[]; /* variable length */
};
and to iterate through all those requests? use hai_first to grab the first one, then keep calling hai_next. that's the lil scroll of doom, but manageable π§
π RETURN VALUE π
llapi_hsm_copytool_register and llapi_hsm_copytool_unregister return 0 on success. on error, a negative errno is returned. (negative errno is the vibe check failing, basically.)
llapi_hsm_copytool_get_fd
- returns the file descriptor associated with the registered copytool. on error, a negative errno is returned.
llapi_hsm_copytool_recv returns 0 when a message is available. if the copytool was set to non-blocking operation, -EAGAIN is immediately returned when no message is available. on error, a negative errno is returned.
π ERRORS π
-EINVALβ an invalid value was passed, the copytool is not registered,...-ESHUTDOWNβ the transport endpoint shutdown. π-EPROTOβ Lustre protocol error.-EAGAINβ no HSM message is available, and the copytool was set to not block on receives.
yes bestie, that...in-EINVALis literally in the original. we don't make the rules, we just report them.
π AUTHORS π
Frank Zago β shoutout to the icon who wrote this π
π AVAILABILITY π
llapi_hsm_copytool_register(), llapi_hsm_copytool_unregister(), llapi_hsm_copytool_get_fd() and llapi_hsm_copytool_recv() are part of the lustre(7) user application interface library since release 2.4.0.
hai_first() and hai_next() are part of the lustre(7) user application interface library.
hai_firstwas added in release 2.5.0.hai_nextwas added in release 2.0.0.
(the way they dropped in different releases and still ended up in the same friend group β¨)
π SEE ALSO π
llapi_hsm_action_begin(3)llapi_hsm_action_end(3)llapi_hsm_action_get_dfid(3)llapi_hsm_action_get_fd(3)llapi_hsm_action_progress(3)lustreapi(7)
also, real talk: see lhsmtool_posix.c in the Lustre sources for a use case of this API. iykyk π
and that's the page bestie!! π₯³ this was Lustre User API, dated 2024-08-27 β drink some water, go write that copytool, and slay β¨ππΊ
π¦ 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