X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Flustreapi_internal.h;h=72e2eccd38f950369e4fe41bdc4548654aa93a84;hb=dbedb9a5f0bdd0012e8e15379b807d313060b65a;hp=ba2a84775f79b288c8bf0db067106246b25b4d19;hpb=b8afd0dcd3834a88b0ceead18c71d37052a00a8d;p=fs%2Flustre-release.git diff --git a/lustre/utils/lustreapi_internal.h b/lustre/utils/lustreapi_internal.h index ba2a847..72e2ecc 100644 --- a/lustre/utils/lustreapi_internal.h +++ b/lustre/utils/lustreapi_internal.h @@ -4,10 +4,10 @@ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * (C) Copyright 2012 Commissariat a l'energie atomique et aux energies - * - * Copyright (c) 2016, Intel Corporation. * alternatives * + * Copyright (c) 2016, 2017, Intel Corporation. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser General Public License * (LGPL) version 2.1 or (at your discretion) any later version. @@ -26,8 +26,6 @@ * * lustre/utils/lustreapi_internal.h * - * Copyright (c) 2016 Intel Corporation. - * * Author: Aurelien Degremont * Author: JC Lafoucriere * Author: Thomas Leibovici @@ -42,25 +40,35 @@ #include #include -#include -#include +#include +#include + +#define MAX_IOC_BUFLEN 8192 +#define MAX_LINE_LEN 256 +#define MAX_INSTANCE_LEN 32 #define WANT_PATH 0x1 #define WANT_FSNAME 0x2 #define WANT_FD 0x4 #define WANT_INDEX 0x8 #define WANT_ERROR 0x10 +#define WANT_DEV 0x20 +#define WANT_NID 0x40 + +/* Define a fixed 4096-byte encryption unit size */ +#define LUSTRE_ENCRYPTION_BLOCKBITS 12 +#define LUSTRE_ENCRYPTION_UNIT_SIZE ((size_t)1 << LUSTRE_ENCRYPTION_BLOCKBITS) +#define LUSTRE_ENCRYPTION_MASK (~(LUSTRE_ENCRYPTION_UNIT_SIZE - 1)) /* mount point listings in /proc/mounts */ #ifndef PROC_MOUNTS #define PROC_MOUNTS "/proc/mounts" #endif -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); -int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len); -int obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len); +int get_root_path(int want, char *fsname, int *outfd, char *path, int index, + dev_t *dev, char *nid); +int llapi_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len); +int llapi_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len); int sattr_cache_get_defaults(const char *const fsname, const char *const pathname, unsigned int *scount, unsigned int *ssize, unsigned int *soffset); @@ -128,10 +136,45 @@ static inline bool llapi_stripe_index_is_valid(int64_t index) return index >= -1 && index <= LOV_V1_INSANE_STRIPE_COUNT; } +static inline bool llapi_pool_name_is_valid(const char **pool_name) +{ + const char *ptr; + + if (*pool_name == NULL) + return false; + + /* Strip off any 'fsname.' portion. */ + ptr = strchr(*pool_name, '.'); + if (ptr != NULL) + *pool_name = ptr + 1; + + if (strlen(*pool_name) > LOV_MAXPOOLNAME) + return false; + + return true; +} + /* 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) +static inline bool llapi_dir_stripe_count_is_valid(int64_t count) +{ + return count >= -1 && count <= LMV_MAX_STRIPE_COUNT; +} + +static inline bool llapi_dir_stripe_index_is_valid(int64_t index) +{ + return index >= -1 && index < LMV_MAX_STRIPE_COUNT; +} + +static inline bool llapi_dir_hash_type_is_valid(int64_t hash) +{ + int64_t _hash = hash & LMV_HASH_TYPE_MASK; + + return _hash >= LMV_HASH_TYPE_UNKNOWN && _hash < LMV_HASH_TYPE_MAX; +} + /* * Kernel communication for Changelogs and HSM requests. */ @@ -140,4 +183,14 @@ 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); + +enum get_lmd_info_type { + GET_LMD_INFO = 1, + GET_LMD_STRIPE = 2, +}; + +int get_lmd_info_fd(const char *path, int parentfd, int dirfd, + void *lmd_buf, int lmd_len, enum get_lmd_info_type type); + +int lov_comp_md_size(struct lov_comp_md_v1 *lcm); #endif /* _LUSTREAPI_INTERNAL_H_ */