C H A P T E R  30

Setting Lustre Properties (man3)

This chapter describes how to use llapi to set Lustre file properties.


30.1 Using llapi

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:

llapi_file_create

llapi_file_get_stripe

llapi_file_open

llapi_quotactl

30.1.1 llapi_file_create

Use llapi_file_create to set Lustre properties for a new file.

Synopsis
#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);
Description

The llapi_file_create() function sets a file descriptor’s Lustre striping information. The file descriptor is then accessed with open ().


Option

Description

llapi_file_create()

If the file already exists, this parameter returns to ‘EEXIST’. If the stripe parameters are invalid, this parameter returns to ‘EINVAL’.

stripe_size

This value must be an even multiple of system page size, as shown by getpagesize (). The default Lustre stripe size is 4MB.

stripe_offset

Indicates the starting OST for this file.

stripe_count

Indicates the number of OSTs that this file will be striped across.

stripe_pattern

Indicates the RAID pattern.




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


Examples

System default size is 4 MB.

char *tfile = TESTFILE;
int stripe_size = 65536

To start at default, run:

int stripe_offset = -1

To start at the default, run:

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;
}

30.1.2 llapi_file_get_stripe

Use llapi_file_get_stripe to get striping information.

Synopsis
int llapi_file_get_stripe(const char *path, struct lov_user_md *lum)
Description

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.


Option

Description

path

The path of the file.

lum

The returned striping information.

return

A value of zero (0) mean the operation was successful. A value of a negative number means there was a failure.

stripe_count

Indicates the number of OSTs that this file will be striped across.

stripe_pattern

Indicates the RAID pattern.


 

 

30.1.3 llapi_file_open

The llapi_file_open command opens or creates a file with the specified striping parameters.

Synopsis
int llapi_file_open(const char *name, int flags, int mode, unsigned long stripe_size, int stripe_offset, int stripe_count, int stripe_pattern)
Description

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.


Option

Description

name

The name of the file.

flags

This opens flags.

mode

This opens modes.

stripe_size

The stripe size of the file.

stripe_offset

The stripe offset (stripe_index) of the file.

stripe_count

The stripe count of the file.

stripe_pattern

The stripe pattern of the file.


30.1.4 llapi_quotactl

Use llapi_quotactl to manipulate disk quotas on a Lustre file system.

Synopsis
#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];
};
Description

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.


Option

Description

LUSTRE_Q_QUOTAON

Turns on quotas for a Lustre filesystem. qc_type is USRQUOTA, GRPQUOTA or UGQUOTA (both user and group quota). The quota files must exist. They are normally created with the llapi_quotacheck(3) call. This call is restricted to the super user privilege.

LUSTRE_Q_QUOTAOFF

Turns off quotas for a Lustre filesystem. qc_type is USRQUOTA, GRPQUOTA or UGQUOTA (both user and group quota). This call is restricted to the super user privilege.

LUSTRE_Q_GETQUOTA

Gets disk quota limits and current usage for user or group qc_id. qc_type is USRQUOTA or GRPQUOTA. UUID may be filled with OBD UUID string to query quota information from a specific node. dqb_valid may be set nonzero to query information only from MDS. If UUID is an empty string and dqb_valid is zero then clusterwide limits and usage are returned. On return, obd_dqblk contains the requested information (block limits unit is kilobyte). Quotas must be turned on before using this command.

LUSTRE_Q_SETQUOTA

Sets disk quota limits for user or group qc_id. qc_type is USRQUOTA or GRPQUOTA. dqb_valid mus be set to QIF_ILIMITS, QIF_BLIMITS or QIF_LIMITS (both inode limits and block limits) dependent on updating limits. obd_dqblk must be filled with limits values (as set in dqb_valid, block limits unit is kilobyte). Quotas must be turned on before using this command.

LUSTRE_Q_GETINFO

Gets information about quotas. qc_type is either USRQUOTA or GRPQUOTA. On return, dqi_igrace is inode grace time (in seconds), dqi_bgrace is block grace time (in seconds), dqi_flags is not used by the current Lustre version.

LUSTRE_Q_SETINFO

Sets quota information (like grace times). qc_type is either USRQUOTA or GRPQUOTA. dqi_igrace is inode grace time (in seconds), dqi_bgrace is block grace time (in seconds), dqi_flags is not used by the current Lustre version and must be zeroed.


 

 

Return Values

llapi_quotactl() returns:

0 on success

-1 on failure and sets error number to indicate the error

llapi Errors

llapi errors are described below.


Errors

Description

EFAULT

qctl is invalid.

ENOSYS

Kernel or Lustre modules have not been compiled with the QUOTA option.

ENOMEM

Insufficient memory to complete operation.

ENOTTY

qc_cmd is invalid.

EBUSY

Cannot process during quotacheck.

ENOENT

UUID does not correspond to OBD or mnt does not exist.

EPERM

The call is privileged and the caller is not the super user.

ESRCH

No disk quota is found for the indicated user. Quotas have not been turned on for this file system.


 

30.1.5 llapi_path2fid

Use llapi_path2fid to get the FID from the pathname.

Synopsis
#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)
Description

The llapi_path2fid function returns the FID (sequence : object ID : version) for the pathname.

Return Values

llapi_path2fid returns:

0 on success

non-zero value on failure