DAOS API: src/include/daos_fs.h Source File

| DAOS API (v2.1 - dev)

Loading...
Searching...
No Matches
daos_fs.h
Go to the documentation of this file.
1/*
2 * (C) Copyright 2018-2023 Intel Corporation.
3 *
4 * SPDX-License-Identifier: BSD-2-Clause-Patent
5 */
15
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 <sys/stat.h>
25
27#define DFS_MAX_NAME NAME_MAX
29#define DFS_MAX_PATH PATH_MAX
31#define DFS_MAX_FSIZE (~0ULL)
33#define DFS_DEFAULT_CHUNK_SIZE 1048576
35#define DFS_MAX_XATTR_NAME 255
37#define DFS_MAX_XATTR_LEN 65536
38
40 typedef struct dfs_obj dfs_obj_t;
42 typedef struct dfs dfs_t;
43
44/*
45 * Consistency modes of the DFS container. A container created with balanced
46 * mode, can only be accessed with balanced mode with dfs_mount. A container
47 * created with relaxed mode, can be accessed with either mode in the future.
48 *
49 * Reserve bit 3 in the access flags for dfs_mount() - bits 1 and 2 are used
50 * for read / write access (O_RDONLY, O_RDRW).
51 */
53#define DFS_BALANCED 4
55#define DFS_RELAXED 0
57#define DFS_RDONLY O_RDONLY
59#define DFS_RDWR O_RDWR
60
62 typedef struct {
64 uint64_t da_id;
66 daos_size_t da_chunk_size;
68 daos_oclass_id_t da_oclass_id;
70 daos_prop_t *da_props;
75 uint32_t da_mode;
77 daos_oclass_id_t da_dir_oclass_id;
79 daos_oclass_id_t da_file_oclass_id;
84 char da_hints[DAOS_CONT_HINT_MAX_LEN];
85} dfs_attr_t;
86
88 typedef struct {
90 daos_size_t iod_nr;
92 daos_range_t *iod_rgs;
93} dfs_iod_t;
94
96 typedef struct {
98 daos_oclass_id_t doi_oclass_id;
100 daos_size_t doi_chunk_size;
101} dfs_obj_info_t;
102
112int
113dfs_init(void);
114
122int
123dfs_fini(void);
124
148int
149dfs_connect(const char *pool, const char *sys, const char *cont, int flags, dfs_attr_t *attr,
150 dfs_t **dfs);
151
160int
161dfs_disconnect(dfs_t *dfs);
162
179int
180dfs_destroy(const char *pool, const char *sys, const char *cont, int force, daos_event_t *ev);
181
195int
196dfs_cont_create(daos_handle_t poh, uuid_t *uuid, dfs_attr_t *attr, daos_handle_t *coh, dfs_t **dfs);
197
214int
215dfs_cont_create_with_label(daos_handle_t poh, const char *label, dfs_attr_t *attr,
216 uuid_t *uuid, daos_handle_t *coh, dfs_t **dfs);
217
233int
234dfs_mount(daos_handle_t poh, daos_handle_t coh, int flags, dfs_t **dfs);
235
245int
246dfs_umount(dfs_t *dfs);
247
257int
258dfs_pool_get(dfs_t *dfs, daos_handle_t *poh);
259
268int
269dfs_pool_put(dfs_t *dfs, daos_handle_t poh);
270
280int
281dfs_cont_get(dfs_t *dfs, daos_handle_t *coh);
282
291int
292dfs_cont_put(dfs_t *dfs, daos_handle_t coh);
293
302int
303dfs_query(dfs_t *dfs, dfs_attr_t *attr);
304
317int
318dfs_local2global(dfs_t *dfs, d_iov_t *glob);
319
334int
335dfs_global2local(daos_handle_t poh, daos_handle_t coh, int flags, d_iov_t glob,
336 dfs_t **dfs);
337
349int
350dfs_local2global_all(dfs_t *dfs, d_iov_t *glob);
351
363int
364dfs_global2local_all(int flags, d_iov_t glob, dfs_t **dfs);
365
378int
379dfs_set_prefix(dfs_t *dfs, const char *prefix);
380
389int
390dfs_obj2id(dfs_obj_t *obj, daos_obj_id_t *oid);
391
405int
406dfs_lookup(dfs_t *dfs, const char *path, int flags, dfs_obj_t **obj,
407 mode_t *mode, struct stat *stbuf);
408
428int
429dfs_lookup_rel(dfs_t *dfs, dfs_obj_t *parent, const char *name, int flags,
430 dfs_obj_t **obj, mode_t *mode, struct stat *stbuf);
431
444int
445dfs_suggest_oclass(dfs_t *dfs, const char *hint, daos_oclass_id_t *cid);
446
471int
472dfs_open(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
473 int flags, daos_oclass_id_t cid, daos_size_t chunk_size,
474 const char *value, dfs_obj_t **obj);
475
488int
489dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **new_obj);
490
504int
505dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob);
506
520int
521dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **obj);
522
530int
531dfs_release(dfs_obj_t *obj);
532
547int
548dfs_read(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
549 daos_size_t *read_size, daos_event_t *ev);
550
566int
567dfs_readx(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
568 daos_size_t *read_size, daos_event_t *ev);
569
582int
583dfs_write(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
584 daos_event_t *ev);
585
598int
599dfs_writex(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
600 daos_event_t *ev);
601
611int
612dfs_get_size(dfs_t *dfs, dfs_obj_t *obj, daos_size_t *size);
613
626int
627dfs_punch(dfs_t *dfs, dfs_obj_t *obj, daos_off_t offset, daos_size_t len);
628
647int
648dfs_readdir(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs);
649
671int
672dfs_readdirplus(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr,
673 struct dirent *dirs, struct stat *stbufs);
674
678 typedef int (*dfs_filler_cb_t)(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg);
679
700int
701dfs_iterate(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor,
702 uint32_t *nr, size_t size, dfs_filler_cb_t op, void *arg);
703
714int
715dfs_dir_anchor_set(dfs_obj_t *obj, const char name[], daos_anchor_t *anchor);
716
737int
738dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors);
739
752int
753dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor);
754
766int
767dfs_mkdir(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
768 daos_oclass_id_t cid);
769
783int
784dfs_remove(dfs_t *dfs, dfs_obj_t *parent, const char *name, bool force,
785 daos_obj_id_t *oid);
786
802int
803dfs_move(dfs_t *dfs, dfs_obj_t *parent, const char *name, dfs_obj_t *new_parent,
804 const char *new_name, daos_obj_id_t *oid);
805
817int
818dfs_exchange(dfs_t *dfs, dfs_obj_t *parent1, const char *name1, dfs_obj_t *parent2,
819 const char *name2);
820
829int
830dfs_get_mode(dfs_obj_t *obj, mode_t *mode);
831
842int
843dfs_obj_get_info(dfs_t *dfs, dfs_obj_t *obj, dfs_obj_info_t *info);
844
859int
860dfs_obj_set_oclass(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_oclass_id_t cid);
861
875int
876dfs_obj_set_chunk_size(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_size_t csize);
877
889int
890dfs_get_file_oh(dfs_obj_t *obj, daos_handle_t *oh);
891
901int
902dfs_get_chunk_size(dfs_obj_t *obj, daos_size_t *chunk_size);
903
917int
918dfs_get_symlink_value(dfs_obj_t *obj, char *buf, daos_size_t *size);
919
936int
937dfs_update_parent(dfs_obj_t *obj, dfs_obj_t *src_obj, const char *name);
938
960int
961dfs_stat(dfs_t *dfs, dfs_obj_t *parent, const char *name,
962 struct stat *stbuf);
963
973int
974dfs_ostat(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf);
975
977#define DFS_SET_ATTR_MODE (1 << 0)
979#define DFS_SET_ATTR_ATIME (1 << 1)
981#define DFS_SET_ATTR_MTIME (1 << 2)
983#define DFS_SET_ATTR_SIZE (1 << 3)
985#define DFS_SET_ATTR_UID (1 << 4)
987#define DFS_SET_ATTR_GID (1 << 5)
988
1003int
1004dfs_osetattr(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf, int flags);
1005
1020int
1021dfs_access(dfs_t *dfs, dfs_obj_t *parent, const char *name, int mask);
1022
1035int
1036dfs_chmod(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode);
1037
1054int
1055dfs_chown(dfs_t *dfs, dfs_obj_t *parent, const char *name, uid_t uid, gid_t gid, int flags);
1056
1067int
1068dfs_sync(dfs_t *dfs);
1069
1085int
1086dfs_setxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name,
1087 const void *value, daos_size_t size, int flags);
1088
1102int
1103dfs_getxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, void *value,
1104 daos_size_t *size);
1105
1116int
1117dfs_removexattr(dfs_t *dfs, dfs_obj_t *obj, const char *name);
1118
1134int
1135dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size);
1136
1137
1138enum {
1140 DFS_CHECK_PRINT = (1 << 0),
1142 DFS_CHECK_REMOVE = (1 << 1),
1144 DFS_CHECK_RELINK = (1 << 2),
1146 DFS_CHECK_VERIFY = (1 << 3),
1148 DFS_CHECK_EVICT_ALL = (1 << 4),
1149};
1150
1167int
1168dfs_cont_check(daos_handle_t poh, const char *cont, uint64_t flags, const char *name);
1169
1170#if defined(__cplusplus)
1171}
1172#endif /* __cplusplus */
1173#endif /* __DAOS_FS_H__ */
DAOS_CONT_HINT_MAX_LEN
#define DAOS_CONT_HINT_MAX_LEN
Definition daos_cont.h:83
dfs_cont_create
int dfs_cont_create(daos_handle_t poh, uuid_t *uuid, dfs_attr_t *attr, daos_handle_t *coh, dfs_t **dfs)
dfs_writex
int dfs_writex(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl, daos_event_t *ev)
dfs_init
int dfs_init(void)
dfs_obj_get_info
int dfs_obj_get_info(dfs_t *dfs, dfs_obj_t *obj, dfs_obj_info_t *info)
dfs_destroy
int dfs_destroy(const char *pool, const char *sys, const char *cont, int force, daos_event_t *ev)
dfs_obj_anchor_set
int dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor)
dfs_lookup_rel
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)
dfs_get_mode
int dfs_get_mode(dfs_obj_t *obj, mode_t *mode)
dfs_remove
int dfs_remove(dfs_t *dfs, dfs_obj_t *parent, const char *name, bool force, daos_obj_id_t *oid)
dfs_cont_check
int dfs_cont_check(daos_handle_t poh, const char *cont, uint64_t flags, const char *name)
dfs_set_prefix
int dfs_set_prefix(dfs_t *dfs, const char *prefix)
dfs_connect
int dfs_connect(const char *pool, const char *sys, const char *cont, int flags, dfs_attr_t *attr, dfs_t **dfs)
dfs_release
int dfs_release(dfs_obj_t *obj)
dfs_global2local_all
int dfs_global2local_all(int flags, d_iov_t glob, dfs_t **dfs)
dfs_setxattr
int dfs_setxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, const void *value, daos_size_t size, int flags)
dfs_readdirplus
int dfs_readdirplus(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs, struct stat *stbufs)
dfs_open
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)
dfs_get_file_oh
int dfs_get_file_oh(dfs_obj_t *obj, daos_handle_t *oh)
dfs_disconnect
int dfs_disconnect(dfs_t *dfs)
dfs_mount
int dfs_mount(daos_handle_t poh, daos_handle_t coh, int flags, dfs_t **dfs)
dfs_cont_put
int dfs_cont_put(dfs_t *dfs, daos_handle_t coh)
dfs_obj_t
struct dfs_obj dfs_obj_t
Definition daos_fs.h:40
dfs_cont_create_with_label
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)
dfs_listxattr
int dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size)
dfs_getxattr
int dfs_getxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, void *value, daos_size_t *size)
dfs_osetattr
int dfs_osetattr(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf, int flags)
dfs_query
int dfs_query(dfs_t *dfs, dfs_attr_t *attr)
dfs_stat
int dfs_stat(dfs_t *dfs, dfs_obj_t *parent, const char *name, struct stat *stbuf)
dfs_update_parent
int dfs_update_parent(dfs_obj_t *obj, dfs_obj_t *src_obj, const char *name)
dfs_readx
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)
dfs_get_symlink_value
int dfs_get_symlink_value(dfs_obj_t *obj, char *buf, daos_size_t *size)
dfs_chown
int dfs_chown(dfs_t *dfs, dfs_obj_t *parent, const char *name, uid_t uid, gid_t gid, int flags)
dfs_exchange
int dfs_exchange(dfs_t *dfs, dfs_obj_t *parent1, const char *name1, dfs_obj_t *parent2, const char *name2)
dfs_fini
int dfs_fini(void)
dfs_get_size
int dfs_get_size(dfs_t *dfs, dfs_obj_t *obj, daos_size_t *size)
dfs_obj2id
int dfs_obj2id(dfs_obj_t *obj, daos_obj_id_t *oid)
dfs_obj_local2global
int dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob)
dfs_pool_put
int dfs_pool_put(dfs_t *dfs, daos_handle_t poh)
dfs_get_chunk_size
int dfs_get_chunk_size(dfs_obj_t *obj, daos_size_t *chunk_size)
dfs_removexattr
int dfs_removexattr(dfs_t *dfs, dfs_obj_t *obj, const char *name)
dfs_obj_set_chunk_size
int dfs_obj_set_chunk_size(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_size_t csize)
dfs_punch
int dfs_punch(dfs_t *dfs, dfs_obj_t *obj, daos_off_t offset, daos_size_t len)
dfs_dup
int dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **new_obj)
dfs_obj_global2local
int dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **obj)
dfs_chmod
int dfs_chmod(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode)
dfs_obj_set_oclass
int dfs_obj_set_oclass(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_oclass_id_t cid)
dfs_read
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)
dfs_filler_cb_t
int(* dfs_filler_cb_t)(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg)
Definition daos_fs.h:678
dfs_access
int dfs_access(dfs_t *dfs, dfs_obj_t *parent, const char *name, int mask)
DFS_CHECK_RELINK
@ DFS_CHECK_RELINK
Definition daos_fs.h:1144
DFS_CHECK_REMOVE
@ DFS_CHECK_REMOVE
Definition daos_fs.h:1142
DFS_CHECK_PRINT
@ DFS_CHECK_PRINT
Definition daos_fs.h:1140
DFS_CHECK_EVICT_ALL
@ DFS_CHECK_EVICT_ALL
Definition daos_fs.h:1148
DFS_CHECK_VERIFY
@ DFS_CHECK_VERIFY
Definition daos_fs.h:1146
dfs_lookup
int dfs_lookup(dfs_t *dfs, const char *path, int flags, dfs_obj_t **obj, mode_t *mode, struct stat *stbuf)
dfs_write
int dfs_write(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off, daos_event_t *ev)
dfs_iterate
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)
dfs_dir_anchor_set
int dfs_dir_anchor_set(dfs_obj_t *obj, const char name[], daos_anchor_t *anchor)
dfs_umount
int dfs_umount(dfs_t *dfs)
dfs_readdir
int dfs_readdir(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs)
dfs_suggest_oclass
int dfs_suggest_oclass(dfs_t *dfs, const char *hint, daos_oclass_id_t *cid)
dfs_global2local
int dfs_global2local(daos_handle_t poh, daos_handle_t coh, int flags, d_iov_t glob, dfs_t **dfs)
dfs_pool_get
int dfs_pool_get(dfs_t *dfs, daos_handle_t *poh)
dfs_move
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)
dfs_mkdir
int dfs_mkdir(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode, daos_oclass_id_t cid)
dfs_cont_get
int dfs_cont_get(dfs_t *dfs, daos_handle_t *coh)
dfs_local2global
int dfs_local2global(dfs_t *dfs, d_iov_t *glob)
dfs_ostat
int dfs_ostat(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf)
dfs_obj_anchor_split
int dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors)
dfs_sync
int dfs_sync(dfs_t *dfs)
dfs_t
struct dfs dfs_t
Definition daos_fs.h:42
dfs_local2global_all
int dfs_local2global_all(dfs_t *dfs, d_iov_t *glob)
daos_anchor_t
Definition daos_types.h:58
daos_handle_t
Definition daos_types.h:73
daos_obj_id_t
Definition daos_types.h:222
daos_prop_t
Definition daos_prop.h:635
daos_range_t
Definition daos_array.h:23
dfs_attr_t
Definition daos_fs.h:62
dfs_attr_t::da_hints
char da_hints[DAOS_CONT_HINT_MAX_LEN]
Definition daos_fs.h:84
dfs_attr_t::da_file_oclass_id
daos_oclass_id_t da_file_oclass_id
Definition daos_fs.h:79
dfs_attr_t::da_dir_oclass_id
daos_oclass_id_t da_dir_oclass_id
Definition daos_fs.h:77
dfs_attr_t::da_mode
uint32_t da_mode
Definition daos_fs.h:75
dfs_attr_t::da_props
daos_prop_t * da_props
Definition daos_fs.h:70
dfs_attr_t::da_id
uint64_t da_id
Definition daos_fs.h:64
dfs_attr_t::da_chunk_size
daos_size_t da_chunk_size
Definition daos_fs.h:66
dfs_attr_t::da_oclass_id
daos_oclass_id_t da_oclass_id
Definition daos_fs.h:68
dfs_iod_t
Definition daos_fs.h:88
dfs_iod_t::iod_rgs
daos_range_t * iod_rgs
Definition daos_fs.h:92
dfs_iod_t::iod_nr
daos_size_t iod_nr
Definition daos_fs.h:90
dfs_obj_info_t
Definition daos_fs.h:96
dfs_obj_info_t::doi_oclass_id
daos_oclass_id_t doi_oclass_id
Definition daos_fs.h:98
dfs_obj_info_t::doi_chunk_size
daos_size_t doi_chunk_size
Definition daos_fs.h:100