LLAPI_CHANGELOG_START(3)

NAME
llapi_changelog_start, llapi_changelog_set_xflags, llapi_changelog_fini - Initialize and clean a read instance for MDT changelogs

SYNOPSIS
#include <lustre/lustreapi.h>

int llapi_changelog_start(void **priv, enum changelog_send_flag flags,
                          const char *device, long long startrec);

int llapi_changelog_set_xflags(void *priv,
                               enum changelog_send_extra_flag extra_flags);

int llapi_changelog_fini(void **priv);

DESCRIPTION
The function llapi_changelog_start() initializes a new instance priv to read MDT changelogs. It opens the changelog char device corresponding to the MDT's name given by device (e.g: "lustrefs-MDT0000").

A changelog starting point can be specified with startrec record number. llapi_changelog_recv() will get changelog records with numbers greater or equal than startrec. 0 value means that all records will be read.

Some options can be passed to llapi_changelog_start() with flags mask.

enum changelog_send_flag values:
    	CHANGELOG_FLAG_FOLLOW
    	CHANGELOG_FLAG_BLOCK
    	CHANGELOG_FLAG_JOBID
    	CHANGELOG_FLAG_EXTRA_FLAGS

CHANGELOG_FLAG_FOLLOW
    Use changelog follow mode: llapi_changelog_recv() will not return when all records have been read. Instead it will block until a new record is available. It avoids restarting an instance and re-scan for newer changelogs.

CHANGELOG_FLAG_BLOCK
    Deprecated since Lustre 2.10.

CHANGELOG_FLAG_JOBID
    Pack jobid into the changelog records if available.

CHANGELOG_FLAG_EXTRA_FLAG
    Pack additional flag bits into the changelog record.

The function llapi_changelog_set_xflags() specifies additional changelog flags with extra_flags mask for the instance priv. To use those extra flags, CHANGELOG_FLAG_EXTRA_FLAG must be set by llapi_changelog_start() on flags parameter.

enum changelog_send_extra_flag values:
    	CHANGELOG_EXTRA_FLAG_UIDGID
    	CHANGELOG_EXTRA_FLAG_NID
    	CHANGELOG_EXTRA_FLAG_OMODE
    	CHANGELOG_EXTRA_FLAG_XATTR

CHANGELOG_EXTRA_FLAG_UIDGID
    Pack uid/gid into the changelog record

CHANGELOG_EXTRA_FLAG_NID
    Pack nid into the changelog record

CHANGELOG_EXTRA_FLAG_OMODE
    Pack open mode into the changelog record

CHANGELOG_EXTRA_FLAG_XATTR
    Pack xattr name into the changelog record

The function llapi_changelog_fini() closes the MDT's changelog char device and free internal pointers for the instance priv.

RETURN VALUES

Return 0 on success or a negative errno value on failure.

ERRORS

-ENOMEM
    Insufficient memory to complete operation.

-EINVAL
    One or more invalid arguments are given.

-ENOENT
    MDT's changelog char device not found. Is the Lustre FS mounted?

-EACCES
    Not enough permissions to open the changelog char device. By default, the device is only accessible to the root user.

EXAMPLE
An example can be found for in lfs.c source file. lfs_changelog() implements the following command:
    lfs changelog [--follow] MDTNAME [STARTREC [ENDREC]]

AVAILABILITY
llapi_changelog_start() is part of the lustre(7) user application interface library since release 2.4.0.

SEE ALSO
lfs-changelog(1), llapi_changelog_clear(3), llapi_changelog_get_fd(3), llapi_changelog_in_buf(3), llapi_changelog_recv(3), lustreapi(7)