X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Flustreapi_internal.h;h=00a66e3985a406e9df52323cf2b2363ba64c888b;hb=81aa70a14c7dcadd593ed987d3f92bd05d120a0f;hp=3ae67e9bdc48583363f9d0ba063400d21b4d8837;hpb=780a5724177ab87ed088a1da484fb99c3f75c7c6;p=fs%2Flustre-release.git diff --git a/lustre/utils/lustreapi_internal.h b/lustre/utils/lustreapi_internal.h index 3ae67e9..00a66e3 100644 --- a/lustre/utils/lustreapi_internal.h +++ b/lustre/utils/lustreapi_internal.h @@ -35,6 +35,9 @@ #ifndef _LUSTREAPI_INTERNAL_H_ #define _LUSTREAPI_INTERNAL_H_ +#include +#include + #define WANT_PATH 0x1 #define WANT_FSNAME 0x2 #define WANT_FD 0x4 @@ -44,5 +47,79 @@ int get_root_path(int want, char *fsname, int *outfd, char *path, int index); int root_ioctl(const char *mdtname, int opc, void *data, int *mdtidxp, int want_error); +/** + * Often when determining the parameter path in sysfs/procfs we + * are often only interest set of data. This enum gives use the + * ability to return data of parameters for: + * + * FILTER_BY_FS_NAME: a specific file system mount + * FILTER_BY_PATH: Using a Lustre file path to determine which + * file system is of interest + * FILTER_BY_EXACT: The default behavior. Search the parameter + * path as is. + */ +enum param_filter { + FILTER_BY_EXACT, + FILTER_BY_FS_NAME, + FILTER_BY_PATH +}; + +int get_lustre_param_path(const char *obd_type, const char *filter, + enum param_filter type, const char *param_name, + glob_t *param); +int get_lustre_param_value(const char *obd_type, const char *filter, + enum param_filter type, const char *param_name, + char *value, size_t val_len); + +static inline int +poolpath(glob_t *pool_path, const char *fsname, char *pathname) +{ + int rc; + + if (fsname != NULL) + rc = get_lustre_param_path("lov", fsname, FILTER_BY_FS_NAME, + "pools", pool_path); + else + rc = get_lustre_param_path("lov", pathname, FILTER_BY_PATH, + "pools", pool_path); + return rc; +} + +#define LLAPI_LAYOUT_MAGIC 0x11AD1107 /* LLAPILOT */ + +/* Helper functions for testing validity of stripe attributes. */ + +static inline bool llapi_stripe_size_is_aligned(uint64_t size) +{ + return (size & (LOV_MIN_STRIPE_SIZE - 1)) == 0; +} + +static inline bool llapi_stripe_size_is_too_big(uint64_t size) +{ + return size >= (1ULL << 32); +} + +static inline bool llapi_stripe_count_is_valid(int64_t count) +{ + return count >= -1 && count <= LOV_MAX_STRIPE_COUNT; +} + +static inline bool llapi_stripe_index_is_valid(int64_t index) +{ + return index >= -1 && index <= LOV_V1_INSANE_STRIPE_COUNT; +} + +/* Compatibility macro for legacy llapi functions that use "offset" + * terminology instead of the preferred "index". */ +#define llapi_stripe_offset_is_valid(os) llapi_stripe_index_is_valid(os) + +/* + * Kernel communication for Changelogs and HSM requests. + */ +int libcfs_ukuc_start(struct lustre_kernelcomm *l, int groups, int rfd_flags); +int libcfs_ukuc_stop(struct lustre_kernelcomm *l); +int libcfs_ukuc_get_rfd(struct lustre_kernelcomm *link); +int libcfs_ukuc_msg_get(struct lustre_kernelcomm *l, char *buf, int maxsize, + int transport); #endif /* _LUSTREAPI_INTERNAL_H_ */