LLAPI_FILE_OPEN(3)
π llapi_file_open, llapi_file_create β Lustre Library Functions (section 3) π
okay bestie so picture this: you're on a Lustre filesystem and you need to open a file β or make one β and you want to control exactly how it gets striped across OSTs. that's literally what these two functions are for. this comes from the Lustre Library Functions manual, section 3, and it's giving main character energy for your whole storage setup. π¦
β¨ NAME β¨
llapi_file_open, llapi_file_create β open and possibly create a file or a device on a Lustre filesystem
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <lustre/lustreapi.h>
int llapi_file_open(const char *name, int flags, int mode,
unsigned long long stripe_size, int stripe_offset,
int stripe_count, int stripe_pattern);
int llapi_file_create(const char *name, unsigned long long stripe_size,
int stripe_offset, int stripe_count,
int stripe_pattern);
π DESCRIPTION π
kay so first things first, the cute shortcut: llapi_file_create() is literally equivalent to calling llapi_file_open with flags equal to O_CREAT|O_WRONLY and mode equal to 0644, and then closing the file. that's it. that's the whole trick. slay. β¨
and llapi_file_open()? it opens a file with a given name on a Lustre filesystem. no cap.
the args, one by one, because we love clarity:
flagsβ a combo platter of any of these bad boys:O_RDONLY,O_WRONLY,O_RDWR,O_CREAT,O_EXCL,O_NOCTTY,O_TRUNC,O_APPEND,O_NONBLOCK,O_SYNC,FASYNC,O_DIRECT,O_LARGEFILE,O_DIRECTORY,O_NOFOLLOW,O_NOATIME. for the whole detailed breakdown, go read theopen(2)man page, she's iconic for that.modeβ the permission bits that get used for a new file whenO_CREATis in play. again,open(2)man page has the full tea on this one. π«stripe_sizeβ stripe size in bytes, and it should be a multiple of 64 KiB and must not exceed 4 GiB. no exceptions bestie, math is math.stripe_offsetβ an OST index telling the file where to start. pass-1to just use the default setting. easy.stripe_countβ how many OSTs to stripe the file across.-1again means "default setting, pls."stripe_patternβ the striping pattern. in this Lustre version, onlyLOV_PATTERN_RAID0is available, and0means use the default setting.
π RETURN VALUES π
both llapi_file_open() and llapi_file_create() come back with:
>=0β success!! and forllapi_file_openspecifically, that return value is a file descriptor. π<0β failure. and the absolute value of it? that's your error code. take the abs value, girl, it's valid.
π ERRORS π
EINVALβstripe_sizeorstripe_offsetorstripe_countorstripe_patternis invalid. something in there is not giving what it's supposed to give.EEXISTβ two possible reasons, bestie: striping information has already been set and cannot be altered, ornamealready exists. either way, already taken. πEALREADYβ striping information has already been set and cannot be altered.ENOTTYβnamemay not point to a Lustre filesystem. wrong vibe check, friend.
π EXAMPLES π
here's a whole little program doing the thing, verbatim, copy-paste blessed:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <lustre/lustreapi.h>
int main(int argc, char *argv[])
{
int rc;
if (argc != 2)
return -1;
rc = llapi_file_create(argv[1], 1048576, 0, 2, LOV_PATTERN_RAID0);
if (rc < 0) {
fprintf(stderr, "file creation has failed, %s\n", strerror(-rc));
return -1;
}
printf("%s with stripe size 1048576, striped across 2 OSTs,"
" has been created!\n", argv[1]);
return 0;
}
π§ AVAILABILITY π§
llapi_file_open() and llapi_file_create() are part of the lustre(7) user application interface library since release 2.4.0. been here, been slaying. π
π SEE ALSO π
okay that's the whole page bestie, you're fully caught up. this was Lustre User API, dated 2024-08-23 β and yes, this is LLAPI_FILE_OPEN(3), periodt. go stripe something gorgeous. π₯ππΈ
π¦ 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