DAOS API (v2.1 - dev)
Loading...
Searching...
No Matches
daos_fs.h
Go to the documentation of this file.
1/*
2 * (C) Copyright 2018-2024 Intel Corporation.
3 *
4 * SPDX-License-Identifier: BSD-2-Clause-Patent
5 */
16#ifndef __DAOS_FS_H__
17#define __DAOS_FS_H__
18
19#if defined(__cplusplus)
20extern "C" {
21#endif
22
23#include <dirent.h>
24#include <inttypes.h>
25#include <sys/stat.h>
26
27#include <daos_types.h>
28#include <daos_obj.h>
29#include <daos_obj_class.h>
30#include <daos_array.h>
31#include <daos_cont.h>
32
34#define DFS_MAX_NAME NAME_MAX
36#define DFS_MAX_PATH PATH_MAX
38#define DFS_MAX_FSIZE (~0ULL)
40#define DFS_DEFAULT_CHUNK_SIZE 1048576
42#define DFS_MAX_XATTR_NAME 255
44#define DFS_MAX_XATTR_LEN 65536
45
47typedef struct dfs_obj dfs_obj_t;
49typedef struct dfs dfs_t;
50
51/*
52 * Consistency modes of the DFS container. A container created with balanced
53 * mode, can only be accessed with balanced mode with dfs_mount. A container
54 * created with relaxed mode, can be accessed with either mode in the future.
55 *
56 * Reserve bit 3 in the access flags for dfs_mount() - bits 1 and 2 are used
57 * for read / write access (O_RDONLY, O_RDRW).
58 */
60#define DFS_BALANCED 4
62#define DFS_RELAXED 0
64#define DFS_RDONLY O_RDONLY
66#define DFS_RDWR O_RDWR
67
69typedef struct {
71 uint64_t da_id;
73 daos_size_t da_chunk_size;
75 daos_oclass_id_t da_oclass_id;
82 uint32_t da_mode;
84 daos_oclass_id_t da_dir_oclass_id;
86 daos_oclass_id_t da_file_oclass_id;
91 char da_hints[DAOS_CONT_HINT_MAX_LEN];
93
95typedef struct {
97 daos_size_t iod_nr;
100} dfs_iod_t;
101
103typedef struct {
105 daos_oclass_id_t doi_oclass_id;
107 daos_size_t doi_chunk_size;
109 daos_oclass_id_t doi_dir_oclass_id;
111 daos_oclass_id_t doi_file_oclass_id;
115
125int
127
135int
137
161int
162dfs_connect(const char *pool, const char *sys, const char *cont, int flags, dfs_attr_t *attr,
163 dfs_t **dfs);
164
173int
175
192int
193dfs_destroy(const char *pool, const char *sys, const char *cont, int force, daos_event_t *ev);
194
208int
209dfs_cont_create(daos_handle_t poh, uuid_t *uuid, dfs_attr_t *attr, daos_handle_t *coh, dfs_t **dfs);
210
227int
229 uuid_t *uuid, daos_handle_t *coh, dfs_t **dfs);
230
246int
247dfs_mount(daos_handle_t poh, daos_handle_t coh, int flags, dfs_t **dfs);
248
258int
260
270int
272
281int
283
293int
295
304int
306
315int
317
330int
331dfs_local2global(dfs_t *dfs, d_iov_t *glob);
332
347int
348dfs_global2local(daos_handle_t poh, daos_handle_t coh, int flags, d_iov_t glob,
349 dfs_t **dfs);
350
362int
363dfs_local2global_all(dfs_t *dfs, d_iov_t *glob);
364
376int
377dfs_global2local_all(int flags, d_iov_t glob, dfs_t **dfs);
378
391int
392dfs_set_prefix(dfs_t *dfs, const char *prefix);
393
402int
404
418int
419dfs_lookup(dfs_t *dfs, const char *path, int flags, dfs_obj_t **obj,
420 mode_t *mode, struct stat *stbuf);
421
441int
442dfs_lookup_rel(dfs_t *dfs, dfs_obj_t *parent, const char *name, int flags,
443 dfs_obj_t **obj, mode_t *mode, struct stat *stbuf);
444
457int
458dfs_suggest_oclass(dfs_t *dfs, const char *hint, daos_oclass_id_t *cid);
459
484int
485dfs_open(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
486 int flags, daos_oclass_id_t cid, daos_size_t chunk_size,
487 const char *value, dfs_obj_t **obj);
488
501int
502dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **new_obj);
503
517int
518dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob);
519
533int
534dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **obj);
535
543int
545
560int
561dfs_read(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
562 daos_size_t *read_size, daos_event_t *ev);
563
579int
580dfs_readx(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
581 daos_size_t *read_size, daos_event_t *ev);
582
595int
596dfs_write(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
597 daos_event_t *ev);
598
611int
612dfs_writex(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
613 daos_event_t *ev);
614
624int
625dfs_get_size(dfs_t *dfs, dfs_obj_t *obj, daos_size_t *size);
626
639int
640dfs_punch(dfs_t *dfs, dfs_obj_t *obj, daos_off_t offset, daos_size_t len);
641
660int
661dfs_readdir(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs);
662
684int
685dfs_readdirplus(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr,
686 struct dirent *dirs, struct stat *stbufs);
687
691typedef int (*dfs_filler_cb_t)(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg);
692
713int
715 uint32_t *nr, size_t size, dfs_filler_cb_t op, void *arg);
716
727int
728dfs_dir_anchor_set(dfs_obj_t *obj, const char name[], daos_anchor_t *anchor);
729
750int
751dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors);
752
765int
766dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor);
767
779int
780dfs_mkdir(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
781 daos_oclass_id_t cid);
782
796int
797dfs_remove(dfs_t *dfs, dfs_obj_t *parent, const char *name, bool force,
798 daos_obj_id_t *oid);
799
815int
816dfs_move(dfs_t *dfs, dfs_obj_t *parent, const char *name, dfs_obj_t *new_parent,
817 const char *new_name, daos_obj_id_t *oid);
818
830int
831dfs_exchange(dfs_t *dfs, dfs_obj_t *parent1, const char *name1, dfs_obj_t *parent2,
832 const char *name2);
833
842int
843dfs_get_mode(dfs_obj_t *obj, mode_t *mode);
844
855int
857
872int
873dfs_obj_set_oclass(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_oclass_id_t cid);
874
888int
889dfs_obj_set_chunk_size(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_size_t csize);
890
902int
904
914int
915dfs_get_chunk_size(dfs_obj_t *obj, daos_size_t *chunk_size);
916
930int
931dfs_get_symlink_value(dfs_obj_t *obj, char *buf, daos_size_t *size);
932
949int
950dfs_update_parent(dfs_obj_t *obj, dfs_obj_t *src_obj, const char *name);
951
973int
974dfs_stat(dfs_t *dfs, dfs_obj_t *parent, const char *name,
975 struct stat *stbuf);
976
986int
987dfs_ostat(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf);
988
990#define DFS_SET_ATTR_MODE (1 << 0)
992#define DFS_SET_ATTR_ATIME (1 << 1)
994#define DFS_SET_ATTR_MTIME (1 << 2)
996#define DFS_SET_ATTR_SIZE (1 << 3)
998#define DFS_SET_ATTR_UID (1 << 4)
1000#define DFS_SET_ATTR_GID (1 << 5)
1001
1019int
1020dfs_osetattr(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf, int flags);
1021
1036int
1037dfs_access(dfs_t *dfs, dfs_obj_t *parent, const char *name, int mask);
1038
1051int
1052dfs_chmod(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode);
1053
1070int
1071dfs_chown(dfs_t *dfs, dfs_obj_t *parent, const char *name, uid_t uid, gid_t gid, int flags);
1072
1083int
1085
1101int
1102dfs_setxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name,
1103 const void *value, daos_size_t size, int flags);
1104
1118int
1119dfs_getxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, void *value,
1120 daos_size_t *size);
1121
1132int
1133dfs_removexattr(dfs_t *dfs, dfs_obj_t *obj, const char *name);
1134
1150int
1151dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size);
1152
1153
1154enum {
1165};
1166
1183int
1184dfs_cont_check(daos_handle_t poh, const char *cont, uint64_t flags, const char *name);
1185
1198int
1199dfs_cont_set_owner(daos_handle_t coh, d_string_t user, uid_t uid, d_string_t group, gid_t gid);
1200
1201/*
1202 * The Pipeline DFS API (everything under this comment) is under heavy development and should not be
1203 * used in production. The API is subject to change.
1204 */
1205
1207typedef struct dfs_pipeline dfs_pipeline_t;
1208
1209enum {
1210 DFS_FILTER_NAME = (1 << 1),
1211 DFS_FILTER_NEWER = (1 << 2),
1212 DFS_FILTER_INCLUDE_DIRS = (1 << 3),
1213};
1214
1216typedef struct {
1218 char dp_name[DFS_MAX_NAME];
1220 time_t dp_newer;
1222 size_t dp_size;
1224
1238int
1239dfs_get_size_by_oid(dfs_t *dfs, daos_obj_id_t oid, daos_size_t chunk_size, daos_size_t *size);
1240
1252int
1253dfs_pipeline_create(dfs_t *dfs, dfs_predicate_t pred, uint64_t flags, dfs_pipeline_t **dpipe);
1254
1262int
1264
1294int
1296 uint32_t *nr, struct dirent *dirs, daos_obj_id_t *oids, daos_size_t *csizes,
1297 uint64_t *nr_scanned);
1298
1309int
1310dfs_cont_scan(daos_handle_t poh, const char *cont, uint64_t flags, const char *name);
1311
1312#if defined(__cplusplus)
1313}
1314#endif /* __cplusplus */
1315#endif /* __DAOS_FS_H__ */
#define DAOS_CONT_HINT_MAX_LEN
Definition daos_cont.h:83
int dfs_cont_create(daos_handle_t poh, uuid_t *uuid, dfs_attr_t *attr, daos_handle_t *coh, dfs_t **dfs)
int dfs_writex(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl, daos_event_t *ev)
int dfs_init(void)
int dfs_obj_get_info(dfs_t *dfs, dfs_obj_t *obj, dfs_obj_info_t *info)
int dfs_destroy(const char *pool, const char *sys, const char *cont, int force, daos_event_t *ev)
int dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor)
int dfs_lookup_rel(dfs_t *dfs, dfs_obj_t *parent, const char *name, int flags, dfs_obj_t **obj, mode_t *mode, struct stat *stbuf)
int dfs_get_mode(dfs_obj_t *obj, mode_t *mode)
int dfs_remove(dfs_t *dfs, dfs_obj_t *parent, const char *name, bool force, daos_obj_id_t *oid)
int dfs_cont_check(daos_handle_t poh, const char *cont, uint64_t flags, const char *name)
int dfs_set_prefix(dfs_t *dfs, const char *prefix)
int dfs_connect(const char *pool, const char *sys, const char *cont, int flags, dfs_attr_t *attr, dfs_t **dfs)
int dfs_release(dfs_obj_t *obj)
int dfs_global2local_all(int flags, d_iov_t glob, dfs_t **dfs)
int dfs_setxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, const void *value, daos_size_t size, int flags)
int dfs_readdirplus(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs, struct stat *stbufs)
int dfs_open(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode, int flags, daos_oclass_id_t cid, daos_size_t chunk_size, const char *value, dfs_obj_t **obj)
int dfs_get_file_oh(dfs_obj_t *obj, daos_handle_t *oh)
int dfs_disconnect(dfs_t *dfs)
int dfs_mount(daos_handle_t poh, daos_handle_t coh, int flags, dfs_t **dfs)
int dfs_cont_put(dfs_t *dfs, daos_handle_t coh)
struct dfs_obj dfs_obj_t
Definition daos_fs.h:47
int dfs_cont_create_with_label(daos_handle_t poh, const char *label, dfs_attr_t *attr, uuid_t *uuid, daos_handle_t *coh, dfs_t **dfs)
int dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size)
int dfs_getxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, void *value, daos_size_t *size)
struct dfs_pipeline dfs_pipeline_t
Definition daos_fs.h:1207
int dfs_osetattr(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf, int flags)
int dfs_query(dfs_t *dfs, dfs_attr_t *attr)
int dfs_stat(dfs_t *dfs, dfs_obj_t *parent, const char *name, struct stat *stbuf)
int dfs_update_parent(dfs_obj_t *obj, dfs_obj_t *src_obj, const char *name)
int dfs_readx(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl, daos_size_t *read_size, daos_event_t *ev)
int dfs_get_symlink_value(dfs_obj_t *obj, char *buf, daos_size_t *size)
int dfs_chown(dfs_t *dfs, dfs_obj_t *parent, const char *name, uid_t uid, gid_t gid, int flags)
int dfs_pipeline_destroy(dfs_pipeline_t *dpipe)
int dfs_exchange(dfs_t *dfs, dfs_obj_t *parent1, const char *name1, dfs_obj_t *parent2, const char *name2)
int dfs_fini(void)
int dfs_cont_set_owner(daos_handle_t coh, d_string_t user, uid_t uid, d_string_t group, gid_t gid)
int dfs_get_size(dfs_t *dfs, dfs_obj_t *obj, daos_size_t *size)
int dfs_obj2id(dfs_obj_t *obj, daos_obj_id_t *oid)
int dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob)
int dfs_cont_scan(daos_handle_t poh, const char *cont, uint64_t flags, const char *name)
int dfs_pool_put(dfs_t *dfs, daos_handle_t poh)
int dfs_get_size_by_oid(dfs_t *dfs, daos_obj_id_t oid, daos_size_t chunk_size, daos_size_t *size)
int dfs_get_chunk_size(dfs_obj_t *obj, daos_size_t *chunk_size)
int dfs_removexattr(dfs_t *dfs, dfs_obj_t *obj, const char *name)
int dfs_obj_set_chunk_size(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_size_t csize)
int dfs_punch(dfs_t *dfs, dfs_obj_t *obj, daos_off_t offset, daos_size_t len)
int dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **new_obj)
int dfs_pipeline_create(dfs_t *dfs, dfs_predicate_t pred, uint64_t flags, dfs_pipeline_t **dpipe)
int dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **obj)
int dfs_chmod(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode)
int dfs_obj_set_oclass(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_oclass_id_t cid)
int dfs_read(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off, daos_size_t *read_size, daos_event_t *ev)
int(* dfs_filler_cb_t)(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg)
Definition daos_fs.h:691
int dfs_readdir_with_filter(dfs_t *dfs, dfs_obj_t *obj, dfs_pipeline_t *dpipe, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs, daos_obj_id_t *oids, daos_size_t *csizes, uint64_t *nr_scanned)
int dfs_access(dfs_t *dfs, dfs_obj_t *parent, const char *name, int mask)
int dfs_lookup(dfs_t *dfs, const char *path, int flags, dfs_obj_t **obj, mode_t *mode, struct stat *stbuf)
int dfs_write(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off, daos_event_t *ev)
int dfs_iterate(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, size_t size, dfs_filler_cb_t op, void *arg)
int dfs_dir_anchor_set(dfs_obj_t *obj, const char name[], daos_anchor_t *anchor)
int dfs_umount(dfs_t *dfs)
int dfs_readdir(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs)
int dfs_suggest_oclass(dfs_t *dfs, const char *hint, daos_oclass_id_t *cid)
@ DFS_CHECK_RELINK
Definition daos_fs.h:1160
@ DFS_CHECK_REMOVE
Definition daos_fs.h:1158
@ DFS_CHECK_PRINT
Definition daos_fs.h:1156
@ DFS_CHECK_EVICT_ALL
Definition daos_fs.h:1164
@ DFS_CHECK_VERIFY
Definition daos_fs.h:1162
int dfs_global2local(daos_handle_t poh, daos_handle_t coh, int flags, d_iov_t glob, dfs_t **dfs)
int dfs_pool_get(dfs_t *dfs, daos_handle_t *poh)
int dfs_move(dfs_t *dfs, dfs_obj_t *parent, const char *name, dfs_obj_t *new_parent, const char *new_name, daos_obj_id_t *oid)
int dfs_mkdir(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode, daos_oclass_id_t cid)
int dfs_cont_get(dfs_t *dfs, daos_handle_t *coh)
int dfs_local2global(dfs_t *dfs, d_iov_t *glob)
int dfs_ostat(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf)
#define DFS_MAX_NAME
Definition daos_fs.h:34
int dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors)
int dfs_sync(dfs_t *dfs)
struct dfs dfs_t
Definition daos_fs.h:49
int dfs_local2global_all(dfs_t *dfs, d_iov_t *glob)
daos_oclass_id_t da_file_oclass_id
Definition daos_fs.h:86
daos_oclass_id_t da_dir_oclass_id
Definition daos_fs.h:84
uint32_t da_mode
Definition daos_fs.h:82
daos_prop_t * da_props
Definition daos_fs.h:77
uint64_t da_id
Definition daos_fs.h:71
daos_size_t da_chunk_size
Definition daos_fs.h:73
daos_oclass_id_t da_oclass_id
Definition daos_fs.h:75
daos_range_t * iod_rgs
Definition daos_fs.h:99
daos_size_t iod_nr
Definition daos_fs.h:97
daos_obj_id_t doi_oid
Definition daos_fs.h:113
daos_oclass_id_t doi_oclass_id
Definition daos_fs.h:105
daos_oclass_id_t doi_dir_oclass_id
Definition daos_fs.h:109
daos_size_t doi_chunk_size
Definition daos_fs.h:107
daos_oclass_id_t doi_file_oclass_id
Definition daos_fs.h:111
time_t dp_newer
Definition daos_fs.h:1220