*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <stdint.h>
#include <lustre/lustre_user.h>
+#ifndef LL_MAXQUOTAS
+#define LL_MAXQUOTAS 3
+#endif
+
+extern bool liblustreapi_initialized;
+
+
typedef void (*llapi_cb_t)(char *obd_type_name, char *obd_name, char *obd_uuid,
void *args);
void llapi_printf(enum llapi_message_level level, const char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3)));
+struct llapi_stripe_param {
+ unsigned long long lsp_stripe_size;
+ char *lsp_pool;
+ int lsp_stripe_offset;
+ int lsp_stripe_pattern;
+ /* Number of stripes. Size of lsp_osts[] if lsp_specific is true.*/
+ int lsp_stripe_count;
+ bool lsp_is_specific;
+ __u32 lsp_osts[0];
+};
+
+extern int llapi_file_open_param(const char *name, int flags, mode_t mode,
+ const struct llapi_stripe_param *param);
extern int llapi_file_create(const char *name, unsigned long long stripe_size,
int stripe_offset, int stripe_count,
int stripe_pattern);
extern int llapi_get_poolmembers(const char *poolname, char **members,
int list_size, char *buffer, int buffer_size);
extern int llapi_file_get_stripe(const char *path, struct lov_user_md *lum);
-#define HAVE_LLAPI_FILE_LOOKUP
extern int llapi_file_lookup(int dirfd, const char *name);
-#define VERBOSE_COUNT 0x1
-#define VERBOSE_SIZE 0x2
-#define VERBOSE_OFFSET 0x4
-#define VERBOSE_POOL 0x8
-#define VERBOSE_DETAIL 0x10
-#define VERBOSE_OBJID 0x20
-#define VERBOSE_GENERATION 0x40
-#define VERBOSE_MDTINDEX 0x80
-#define VERBOSE_LAYOUT 0x100
-#define VERBOSE_ALL (VERBOSE_COUNT | VERBOSE_SIZE | \
+#define VERBOSE_COUNT 0x1
+#define VERBOSE_SIZE 0x2
+#define VERBOSE_OFFSET 0x4
+#define VERBOSE_POOL 0x8
+#define VERBOSE_DETAIL 0x10
+#define VERBOSE_OBJID 0x20
+#define VERBOSE_GENERATION 0x40
+#define VERBOSE_MDTINDEX 0x80
+#define VERBOSE_LAYOUT 0x100
+#define VERBOSE_COMP_COUNT 0x200
+#define VERBOSE_COMP_FLAGS 0x400
+#define VERBOSE_COMP_START 0x800
+#define VERBOSE_COMP_END 0x1000
+#define VERBOSE_COMP_ID 0x2000
+#define VERBOSE_DFID 0x4000
+#define VERBOSE_HASH_TYPE 0x8000
+#define VERBOSE_DEFAULT (VERBOSE_COUNT | VERBOSE_SIZE | \
VERBOSE_OFFSET | VERBOSE_POOL | \
- VERBOSE_OBJID | VERBOSE_GENERATION |\
- VERBOSE_LAYOUT)
+ VERBOSE_OBJID | VERBOSE_GENERATION | \
+ VERBOSE_LAYOUT | VERBOSE_HASH_TYPE | \
+ VERBOSE_COMP_COUNT | VERBOSE_COMP_FLAGS | \
+ VERBOSE_COMP_START | VERBOSE_COMP_END | \
+ VERBOSE_COMP_ID)
struct find_param {
unsigned int fp_max_depth;
int fp_msign;
int fp_csign;
/* these need to be signed values */
- int size_sign:2,
- stripesize_sign:2,
- stripecount_sign:2;
- unsigned long long size;
- unsigned long long size_units;
-
- unsigned long zeroend:1,
- recursive:1,
- exclude_pattern:1,
+ int fp_size_sign:2,
+ fp_stripe_size_sign:2,
+ fp_stripe_count_sign:2,
+ fp_comp_start_sign:2,
+ fp_comp_end_sign:2,
+ fp_comp_count_sign:2,
+ fp_mdt_count_sign:2;
+ unsigned long long fp_size;
+ unsigned long long fp_size_units;
+
+ unsigned long long fp_zero_end:1,
+ fp_recursive:1,
+ fp_exclude_pattern:1,
fp_exclude_type:1,
- exclude_obd:1,
- exclude_mdt:1,
+ fp_exclude_obd:1,
+ fp_exclude_mdt:1,
fp_exclude_gid:1,
fp_exclude_uid:1,
fp_check_gid:1,
fp_check_uid:1,
- check_pool:1, /* LOV pool name */
- check_size:1, /* file size */
- exclude_pool:1,
- exclude_size:1,
+ fp_check_pool:1, /* LOV pool name */
+ fp_check_size:1, /* file size */
+ fp_exclude_pool:1,
+ fp_exclude_size:1,
fp_exclude_atime:1,
fp_exclude_mtime:1,
fp_exclude_ctime:1,
- get_lmv:1, /* get MDT list from LMV */
- raw:1, /* do not fill in defaults */
- check_stripesize:1, /* LOV stripe size */
- exclude_stripesize:1,
- check_stripecount:1, /* LOV stripe count */
- exclude_stripecount:1,
- check_layout:1,
- exclude_layout:1,
- get_default_lmv:1, /* Get default LMV */
- migrate:1;
-
- int verbose;
- int quiet;
+ fp_get_lmv:1, /* get MDT list from LMV */
+ fp_raw:1, /* do not fill in defaults */
+ fp_check_stripe_size:1, /* LOV stripe size */
+ fp_exclude_stripe_size:1,
+ fp_check_stripe_count:1, /* LOV stripe count */
+ fp_exclude_stripe_count:1,
+ fp_check_layout:1,
+ fp_exclude_layout:1,
+ fp_get_default_lmv:1, /* Get default LMV */
+ fp_migrate:1,
+ fp_check_comp_count:1,
+ fp_exclude_comp_count:1,
+ fp_check_comp_flags:1,
+ fp_exclude_comp_flags:1,
+ fp_check_comp_start:1,
+ fp_exclude_comp_start:1,
+ fp_check_comp_end:1,
+ fp_exclude_comp_end:1,
+ fp_check_comp_id:1,
+ fp_exclude_comp_id:1,
+ fp_check_mdt_count:1,
+ fp_exclude_mdt_count:1,
+ fp_check_hash_type:1,
+ fp_exclude_hash_type:1;
+
+ int fp_verbose;
+ int fp_quiet;
/* regular expression */
- char *pattern;
+ char *fp_pattern;
- struct obd_uuid *obduuid;
- int num_obds;
- int num_alloc_obds;
- int obdindex;
- int *obdindexes;
+ struct obd_uuid *fp_obd_uuid;
+ int fp_num_obds;
+ int fp_num_alloc_obds;
+ int fp_obd_index;
+ int *fp_obd_indexes;
- struct obd_uuid *mdtuuid;
- int num_mdts;
- int num_alloc_mdts;
- int mdtindex;
- int *mdtindexes;
- int file_mdtindex;
+ struct obd_uuid *fp_mdt_uuid;
+ int fp_num_mdts;
+ int fp_num_alloc_mdts;
+ int fp_mdt_index;
+ int *fp_mdt_indexes;
+ int fp_file_mdt_index;
- int lumlen;
- struct lov_user_mds_data *lmd;
+ size_t fp_lum_size;
+ struct lov_user_mds_data *fp_lmd;
- char poolname[LOV_MAXPOOLNAME + 1];
+ char fp_poolname[LOV_MAXPOOLNAME + 1];
- int fp_lmv_count;
+ __u32 fp_lmv_stripe_count;
struct lmv_user_md *fp_lmv_md;
- unsigned long long stripesize;
- unsigned long long stripesize_units;
- unsigned long long stripecount;
- __u32 layout;
+ unsigned long long fp_stripe_size;
+ unsigned long long fp_stripe_size_units;
+ unsigned long long fp_stripe_count;
+ __u32 fp_layout;
+
+ __u32 fp_comp_count;
+ __u32 fp_comp_flags;
+ __u32 fp_comp_id;
+ unsigned long long fp_comp_start;
+ unsigned long long fp_comp_start_units;
+ unsigned long long fp_comp_end;
+ unsigned long long fp_comp_end_units;
+ unsigned long long fp_mdt_count;
/* In-process parameters. */
- unsigned long got_uuids:1,
- obds_printed:1,
- have_fileinfo:1; /* file attrs and LOV xattr */
+ unsigned long fp_got_uuids:1,
+ fp_obds_printed:1;
unsigned int fp_depth;
+ unsigned int fp_hash_type;
};
extern int llapi_ostlist(char *path, struct find_param *param);
int stripe_count, int stripe_pattern,
const char *poolname);
int llapi_direntry_remove(char *dname);
+
+int llapi_obd_fstatfs(int fd, __u32 type, __u32 index,
+ struct obd_statfs *stat_buf, struct obd_uuid *uuid_buf);
extern int llapi_obd_statfs(char *path, __u32 type, __u32 index,
struct obd_statfs *stat_buf,
struct obd_uuid *uuid_buf);
char *mntdir, char *fsname);
extern int llapi_search_fsname(const char *pathname, char *fsname);
extern int llapi_getname(const char *path, char *buf, size_t size);
+extern int llapi_search_fileset(const char *pathname, char *fileset);
extern int llapi_search_rootpath(char *pathname, const char *fsname);
extern int llapi_nodemap_exists(const char *name);
+extern int llapi_migrate_mdt(char *path, struct find_param *param);
extern int llapi_mv(char *path, struct find_param *param);
struct mntent;
#define HAVE_LLAPI_IS_LUSTRE_MNT
extern int llapi_is_lustre_mnt(struct mntent *mnt);
-extern int llapi_quotachown(char *path, int flag);
-extern int llapi_quotacheck(char *mnt, int check_type);
-extern int llapi_poll_quotacheck(char *mnt, struct if_quotacheck *qchk);
extern int llapi_quotactl(char *mnt, struct if_quotactl *qctl);
extern int llapi_target_iterate(int type_num, char **obd_type, void *args,
llapi_cb_t cb);
extern int llapi_get_connect_flags(const char *mnt, __u64 *flags);
-extern int llapi_lsetfacl(int argc, char *argv[]);
-extern int llapi_lgetfacl(int argc, char *argv[]);
-extern int llapi_rsetfacl(int argc, char *argv[]);
-extern int llapi_rgetfacl(int argc, char *argv[]);
extern int llapi_cp(int argc, char *argv[]);
extern int llapi_ls(int argc, char *argv[]);
extern int llapi_fid2path(const char *device, const char *fidstr, char *path,
extern int llapi_get_mdt_index_by_fid(int fd, const lustre_fid *fid,
int *mdt_index);
extern int llapi_fd2fid(const int fd, lustre_fid *fid);
+/* get FID of parent dir + the related name of entry in this parent dir */
+extern int llapi_path2parent(const char *path, unsigned int linkno,
+ lustre_fid *parent_fid, char *name,
+ size_t name_size);
+extern int llapi_fd2parent(int fd, unsigned int linkno,
+ lustre_fid *parent_fid, char *name,
+ size_t name_size);
extern int llapi_chomp_string(char *buf);
extern int llapi_open_by_fid(const char *dir, const lustre_fid *fid,
int open_flags);
-extern int llapi_get_version(char *buffer, int buffer_size, char **version);
+extern int llapi_get_version_string(char *version, unsigned int version_size);
+/* llapi_get_version() is deprecated, use llapi_get_version_string() instead */
+extern int llapi_get_version(char *buffer, int buffer_size, char **version)
+ __attribute__((deprecated));
extern int llapi_get_data_version(int fd, __u64 *data_version, __u64 flags);
extern int llapi_hsm_state_get_fd(int fd, struct hsm_user_state *hus);
extern int llapi_hsm_state_get(const char *path, struct hsm_user_state *hus);
}
-extern int llapi_fswap_layouts(const int fd1, const int fd2,
- __u64 dv1, __u64 dv2, __u64 flags);
+extern int llapi_fswap_layouts_grouplock(int fd1, int fd2, __u64 dv1, __u64 dv2,
+ int gid, __u64 flags);
+extern int llapi_fswap_layouts(int fd1, int fd2, __u64 dv1, __u64 dv2,
+ __u64 flags);
extern int llapi_swap_layouts(const char *path1, const char *path2,
__u64 dv1, __u64 dv2, __u64 flags);
-/* Changelog interface. priv is private state, managed internally
- by these functions */
-#define CHANGELOG_FLAG_FOLLOW 0x01 /* Not yet implemented */
-#define CHANGELOG_FLAG_BLOCK 0x02 /* Blocking IO makes sense in case of
- slow user parsing of the records, but it also prevents us from cleaning
- up if the records are not consumed. */
+/* Changelog interface. priv is private state, managed internally by these
+ * functions */
-/* Records received are in extentded format now, though most of them are still
+/* Records received are in extended format now, though most of them are still
* written in disk in changelog_rec format (to save space and time), it's
- * converted to extented format in the lustre api to ease changelog analysis. */
+ * converted to extended format in the lustre api to ease changelog analysis. */
#define HAVE_CHANGELOG_EXTEND_REC 1
-extern int llapi_changelog_start(void **priv, int flags, const char *mdtname,
- long long startrec);
+extern int llapi_changelog_start(void **priv, enum changelog_send_flag flags,
+ const char *mdtname, long long startrec);
extern int llapi_changelog_fini(void **priv);
-extern int llapi_changelog_recv(void *priv, struct changelog_ext_rec **rech);
-extern int llapi_changelog_free(struct changelog_ext_rec **rech);
+extern int llapi_changelog_recv(void *priv, struct changelog_rec **rech);
+extern int llapi_changelog_free(struct changelog_rec **rech);
+extern int llapi_changelog_get_fd(void *priv);
/* Allow records up to endrec to be destroyed; requires registered id. */
extern int llapi_changelog_clear(const char *mdtname, const char *idstr,
long long endrec);
int llapi_group_lock(int fd, int gid);
int llapi_group_unlock(int fd, int gid);
+/* Ladvise */
+int llapi_ladvise(int fd, unsigned long long flags, int num_advise,
+ struct llapi_lu_ladvise *ladvise);
/** @} llapi */
/* llapi_layout user interface */
#define LLAPI_LAYOUT_RAID0 0
/**
+* The layout includes a specific set of OSTs on which to allocate.
+*/
+#define LLAPI_LAYOUT_SPECIFIC 0x2000000000000000ULL
+
+/**
+ * A valid ost index should be less than maximum valid OST index (UINT_MAX).
+ */
+#define LLAPI_LAYOUT_IDX_MAX 0x00000000FFFFFFFFULL
+
+/**
* Flags to modify how layouts are retrieved.
*/
/******************** Stripe Count ********************/
int llapi_layout_file_create(const char *path, int open_flags, int mode,
const struct llapi_layout *layout);
+/**
+ * Fetch the start and end offset of the current layout component.
+ */
+int llapi_layout_comp_extent_get(const struct llapi_layout *layout,
+ uint64_t *start, uint64_t *end);
+/**
+ * Set the extent of current layout component.
+ */
+int llapi_layout_comp_extent_set(struct llapi_layout *layout,
+ uint64_t start, uint64_t end);
+/**
+ * Gets the attribute flags of the current component.
+ */
+int llapi_layout_comp_flags_get(const struct llapi_layout *layout,
+ uint32_t *flags);
+/**
+ * Sets the specified flags of the current component leaving other flags as-is.
+ */
+int llapi_layout_comp_flags_set(struct llapi_layout *layout, uint32_t flags);
+/**
+ * Clears the flags specified in the flags leaving other flags as-is.
+ */
+int llapi_layout_comp_flags_clear(struct llapi_layout *layout, uint32_t flags);
+/**
+ * Fetches the file-unique component ID of the current layout component.
+ */
+int llapi_layout_comp_id_get(const struct llapi_layout *layout, uint32_t *id);
+/**
+ * Adds one component to the existing composite or plain layout.
+ */
+int llapi_layout_comp_add(struct llapi_layout *layout);
+/**
+ * Deletes the current layout component from the composite layout.
+ */
+int llapi_layout_comp_del(struct llapi_layout *layout);
+
+enum {
+ LLAPI_LAYOUT_COMP_POS_NEXT = 0,
+ LLAPI_LAYOUT_COMP_POS_FIRST = 1,
+ LLAPI_LAYOUT_COMP_POS_LAST = 2
+};
+
+/**
+ * Move the current component pointer by specified component ID.
+ */
+int llapi_layout_comp_move_at(struct llapi_layout *layout, uint32_t id);
+/**
+ * Move the current component pointer to a specified position.
+ */
+int llapi_layout_comp_move(struct llapi_layout *layout, uint32_t pos);
+/**
+ * Add layout components to an existing file.
+ */
+int llapi_layout_file_comp_add(const char *path,
+ const struct llapi_layout *layout);
+/**
+ * Delete component(s) by the specified component id (accepting lcme_id
+ * wildcards also) from an existing file.
+ */
+int llapi_layout_file_comp_del(const char *path, uint32_t id);
+/**
+ * Change flags or other parameters of the component(s) by component ID of an
+ * existing file. The component to be modified is specified by the
+ * comp->lcme_id value, which must be an unique component ID. The new
+ * attributes are passed in by @comp and @valid is used to specify which
+ * attributes in the component are going to be changed.
+ */
+int llapi_layout_file_comp_set(const char *path,
+ const struct llapi_layout *comp,
+ uint32_t valid);
+
/** @} llapi */
#endif