| C H A P T E R 30 |
|
Setting Lustre Properties (man3) |
This chapter describes how to use llapi to set Lustre file properties.
Several llapi commands are available to set Lustre properties, llapi_file_create, llapi_file_get_stripe, and llapi_file_open. These commands are described in the following sections:
Use llapi_file_create to set Lustre properties for a new file.
#include <lustre/liblustreapi.h>#include <lustre/lustre_user.h> int llapi_file_create(char *name, long stripe_size, int stripe_offset, int stripe_count, int stripe_pattern);
The llapi_file_create() function sets a file descriptor’s Lustre striping information. The file descriptor is then accessed with open ().
| Note - Currently, only RAID 0 is supported. To use the system defaults, set these values: stripe_size = 0, stripe_offset = -1, stripe_count = 0, stripe_pattern = 0 |
char *tfile = TESTFILE; int stripe_size = 65536
int stripe_offset = -1
int stripe_count = 1
To set a single stripe for this example, run:
int stripe_pattern = 0
Currently, only RAID 0 is supported.
int stripe_pattern = 0; int rc, fd; rc = llapi_file_create(tfile, stripe_size,stripe_offset, stripe_count,stripe_pattern);
Result code is inverted, you may return with ’EINVAL’ or an ioctl error.
if (rc) {
fprintf(stderr,"llapi_file_create failed: %d (%s) 0, rc, strerror(-rc));return -1; }
llapi_file_create closes the file descriptor. You must re-open the descriptor. To do this, run:
fd = open(tfile, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644); if (fd < 0) \ { fprintf(stderr, "Can’t open %s file: %s0, tfile,
str-
error(errno));
return -1;
}
Use llapi_file_get_stripe to get striping information.
int llapi_file_get_stripe(const char *path, struct lov_user_md *lum)
The llapi_file_get_stripe function returns the striping information to the caller. If it returns a zero (0), the operation was successful; a negative number means there was a failure.
|
A value of zero (0) mean the operation was successful. A value of a negative number means there was a failure. |
|
|
Indicates the number of OSTs that this file will be striped across. |
|
The llapi_file_open command opens or creates a file with the specified striping parameters.
int llapi_file_open(const char *name, int flags, int mode, unsigned long stripe_size, int stripe_offset, int stripe_count, int stripe_pattern)
The llapi_file_open function opens or creates a file with the specified striping parameters. If it returns a zero (0), the operation was successful; a negative number means there was a failure.
Use llapi_quotactl to manipulate disk quotas on a Lustre file system.
#include <liblustre.h>
#include <lustre/lustre_idl.h>
#include <lustre/liblustreapi.h>
#include <lustre/lustre_user.h>
int llapi_quotactl(char" " *mnt," " struct if_quotactl" " *qctl)
struct if_quotactl {
__u32 qc_cmd;
__u32 qc_type;
__u32 qc_id;
__u32 qc_stat;
struct obd_dqinfo qc_dqinfo;
struct obd_dqblk qc_dqblk;
char obd_type[16];
struct obd_uuid obd_uuid;
};
struct obd_dqblk {
__u64 dqb_bhardlimit;
__u64 dqb_bsoftlimit;
__u64 dqb_curspace;
__u64 dqb_ihardlimit;
__u64 dqb_isoftlimit;
__u64 dqb_curinodes;
__u64 dqb_btime;
__u64 dqb_itime;
__u32 dqb_valid;
__u32 padding;
};
struct obd_dqinfo {
__u64 dqi_bgrace;
__u64 dqi_igrace;
__u32 dqi_flags;
__u32 dqi_valid;
};
struct obd_uuid {
char uuid[40];
};
The llapi_quotactl() command manipulates disk quotas on a Lustre file system mount. qc_cmd indicates a command to be applied to UID qc_id or GID qc_id.
-1 on failure and sets error number to indicate the error
llapi errors are described below.
Use llapi_path2fid to get the FID from the pathname.
#include <lustre/liblustreapi.h> #include <lustre/lustre_user.h> int llapi_path2fid(const char *path, unsigned long long *seq, unsigned long *oid, unsigned long *ver)
The llapi_path2fid function returns the FID (sequence : object ID : version) for the pathname.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.