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 * (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 */
16
17#ifndef __DAOS_FS_H__
18#define __DAOS_FS_H__
19
20#if defined(__cplusplus)
21extern "C" {
22#endif
23
24#include <dirent.h>
25#include <inttypes.h>
26#include <sys/stat.h>
27
28#include <daos_types.h>
29#include <daos_obj.h>
30#include <daos_obj_class.h>
31#include <daos_array.h>
32#include <daos_cont.h>
33
35#define DFS_MAX_NAME NAME_MAX
37#define DFS_MAX_PATH PATH_MAX
39#define DFS_MAX_FSIZE (~0ULL)
41#define DFS_DEFAULT_CHUNK_SIZE 1048576
43#define DFS_MAX_XATTR_NAME 255
45#define DFS_MAX_XATTR_LEN 65536
47#define DAOS_SUPER_MAGIC 0xDA05AD10
48
50typedef struct dfs_obj dfs_obj_t;
52typedef struct dfs dfs_t;
53
54/*
55 * Consistency modes of the DFS container. A container created with balanced
56 * mode, can only be accessed with balanced mode with dfs_mount. A container
57 * created with relaxed mode, can be accessed with either mode in the future.
58 *
59 * Reserve bit 3 in the access flags for dfs_mount() - bits 1 and 2 are used
60 * for read / write access (O_RDONLY, O_RDRW).
61 */
63#define DFS_BALANCED 4
65#define DFS_RELAXED 0
67#define DFS_RDONLY O_RDONLY
69#define DFS_RDWR O_RDWR
70
72typedef struct {
74 uint64_t da_id;
76 daos_size_t da_chunk_size;
78 daos_oclass_id_t da_oclass_id;
85 uint32_t da_mode;
87 daos_oclass_id_t da_dir_oclass_id;
89 daos_oclass_id_t da_file_oclass_id;
96
98typedef struct {
100 daos_size_t iod_nr;
103} dfs_iod_t;
104
106typedef struct {
108 daos_oclass_id_t doi_oclass_id;
110 daos_size_t doi_chunk_size;
112 daos_oclass_id_t doi_dir_oclass_id;
114 daos_oclass_id_t doi_file_oclass_id;
118
128int
130
138int
140
164int
165dfs_connect(const char *pool, const char *sys, const char *cont, int flags, dfs_attr_t *attr,
166 dfs_t **dfs);
167
193int
194dfs_connect_snap(const char *pool, const char *sys, const char *cont, int flags, daos_epoch_t epoch,
195 const char *name, dfs_t **dfs);
196
205int
207
224int
225dfs_destroy(const char *pool, const char *sys, const char *cont, int force, daos_event_t *ev);
226
240int
241dfs_cont_create(daos_handle_t poh, uuid_t *uuid, dfs_attr_t *attr, daos_handle_t *coh, dfs_t **dfs);
242
259int
261 uuid_t *uuid, daos_handle_t *coh, dfs_t **dfs);
262
278int
279dfs_mount(daos_handle_t poh, daos_handle_t coh, int flags, dfs_t **dfs);
280
304int
305dfs_mount_snap(daos_handle_t poh, daos_handle_t coh, int flags, daos_epoch_t epoch,
306 const char *name, dfs_t **dfs);
307
317int
319
329int
331
340int
342
352int
354
363int
365
374int
376
389int
390dfs_local2global(dfs_t *dfs, d_iov_t *glob);
391
406int
407dfs_global2local(daos_handle_t poh, daos_handle_t coh, int flags, d_iov_t glob,
408 dfs_t **dfs);
409
421int
422dfs_local2global_all(dfs_t *dfs, d_iov_t *glob);
423
435int
436dfs_global2local_all(int flags, d_iov_t glob, dfs_t **dfs);
437
450int
451dfs_set_prefix(dfs_t *dfs, const char *prefix);
452
461int
463
482int
483dfs_lookup(dfs_t *dfs, const char *path, int flags, dfs_obj_t **obj,
484 mode_t *mode, struct stat *stbuf);
485
507int
508dfs_lookup_rel(dfs_t *dfs, dfs_obj_t *parent, const char *name, int flags,
509 dfs_obj_t **obj, mode_t *mode, struct stat *stbuf);
510
523int
524dfs_suggest_oclass(dfs_t *dfs, const char *hint, daos_oclass_id_t *cid);
525
550int
551dfs_open(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
552 int flags, daos_oclass_id_t cid, daos_size_t chunk_size,
553 const char *value, dfs_obj_t **obj);
554
567int
568dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **new_obj);
569
583int
584dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob);
585
599int
600dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **obj);
601
609int
611
626int
627dfs_read(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
628 daos_size_t *read_size, daos_event_t *ev);
629
647int
648dfs_readx(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
649 daos_size_t *read_size, daos_event_t *ev);
650
663int
664dfs_write(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
665 daos_event_t *ev);
666
681int
682dfs_writex(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
683 daos_event_t *ev);
684
694int
695dfs_get_size(dfs_t *dfs, dfs_obj_t *obj, daos_size_t *size);
696
709int
710dfs_punch(dfs_t *dfs, dfs_obj_t *obj, daos_off_t offset, daos_size_t len);
711
730int
731dfs_readdir(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs);
732
754int
755dfs_readdirplus(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr,
756 struct dirent *dirs, struct stat *stbufs);
757
761typedef int (*dfs_filler_cb_t)(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg);
762
783int
785 uint32_t *nr, size_t size, dfs_filler_cb_t op, void *arg);
786
797int
798dfs_dir_anchor_set(dfs_obj_t *obj, const char name[], daos_anchor_t *anchor);
799
820int
821dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors);
822
835int
836dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor);
837
849int
850dfs_mkdir(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
851 daos_oclass_id_t cid);
852
866int
867dfs_remove(dfs_t *dfs, dfs_obj_t *parent, const char *name, bool force,
868 daos_obj_id_t *oid);
869
885int
886dfs_move(dfs_t *dfs, dfs_obj_t *parent, const char *name, dfs_obj_t *new_parent,
887 const char *new_name, daos_obj_id_t *oid);
888
900int
901dfs_exchange(dfs_t *dfs, dfs_obj_t *parent1, const char *name1, dfs_obj_t *parent2,
902 const char *name2);
903
912int
913dfs_get_mode(dfs_obj_t *obj, mode_t *mode);
914
925int
927
942int
943dfs_obj_set_oclass(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_oclass_id_t cid);
944
958int
959dfs_obj_set_chunk_size(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_size_t csize);
960
972int
974
984int
985dfs_get_chunk_size(dfs_obj_t *obj, daos_size_t *chunk_size);
986
1000int
1001dfs_get_symlink_value(dfs_obj_t *obj, char *buf, daos_size_t *size);
1002
1019int
1020dfs_update_parent(dfs_obj_t *obj, dfs_obj_t *src_obj, const char *name);
1021
1043int
1044dfs_stat(dfs_t *dfs, dfs_obj_t *parent, const char *name,
1045 struct stat *stbuf);
1046
1056int
1057dfs_ostat(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf);
1058
1060#define DFS_SET_ATTR_MODE (1 << 0)
1062#define DFS_SET_ATTR_ATIME (1 << 1)
1064#define DFS_SET_ATTR_MTIME (1 << 2)
1066#define DFS_SET_ATTR_SIZE (1 << 3)
1068#define DFS_SET_ATTR_UID (1 << 4)
1070#define DFS_SET_ATTR_GID (1 << 5)
1071
1089int
1090dfs_osetattr(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf, int flags);
1091
1106int
1107dfs_access(dfs_t *dfs, dfs_obj_t *parent, const char *name, int mask);
1108
1121int
1122dfs_chmod(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode);
1123
1140int
1141dfs_chown(dfs_t *dfs, dfs_obj_t *parent, const char *name, uid_t uid, gid_t gid, int flags);
1142
1153int
1155
1171int
1172dfs_setxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name,
1173 const void *value, daos_size_t size, int flags);
1174
1188int
1189dfs_getxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, void *value,
1190 daos_size_t *size);
1191
1202int
1203dfs_removexattr(dfs_t *dfs, dfs_obj_t *obj, const char *name);
1204
1220int
1221dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size);
1222
1223
1224enum {
1235};
1236
1253int
1254dfs_cont_check(daos_handle_t poh, const char *cont, uint64_t flags, const char *name);
1255
1268int
1269dfs_cont_set_owner(daos_handle_t coh, d_string_t user, uid_t uid, d_string_t group, gid_t gid);
1270
1271/*
1272 * The Pipeline DFS API (everything under this comment) is under heavy development and should not be
1273 * used in production. The API is subject to change.
1274 */
1275
1277typedef struct dfs_pipeline dfs_pipeline_t;
1278
1279enum {
1280 DFS_FILTER_NAME = (1 << 1),
1281 DFS_FILTER_NEWER = (1 << 2),
1282 DFS_FILTER_INCLUDE_DIRS = (1 << 3),
1283};
1284
1286typedef struct {
1290 time_t dp_newer;
1292 size_t dp_size;
1294
1308int
1309dfs_get_size_by_oid(dfs_t *dfs, daos_obj_id_t oid, daos_size_t chunk_size, daos_size_t *size);
1310
1322int
1323dfs_pipeline_create(dfs_t *dfs, dfs_predicate_t pred, uint64_t flags, dfs_pipeline_t **dpipe);
1324
1332int
1334
1364int
1366 uint32_t *nr, struct dirent *dirs, daos_obj_id_t *oids, daos_size_t *csizes,
1367 uint64_t *nr_scanned);
1368
1379int
1380dfs_cont_scan(daos_handle_t poh, const char *cont, uint64_t flags, const char *name);
1381
1382#if defined(__cplusplus)
1383}
1384#endif /* __cplusplus */
1385#endif /* __DAOS_FS_H__ */
#define DAOS_CONT_HINT_MAX_LEN
Definition daos_cont.h:94
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_mount_snap(daos_handle_t poh, daos_handle_t coh, int flags, daos_epoch_t epoch, const char *name, 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_filler_cb_t(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg)
Definition daos_fs.h:761
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:50
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:1277
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_connect_snap(const char *pool, const char *sys, const char *cont, int flags, daos_epoch_t epoch, const char *name, dfs_t **dfs)
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_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)
@ DFS_CHECK_RELINK
Definition daos_fs.h:1230
@ DFS_CHECK_REMOVE
Definition daos_fs.h:1228
@ DFS_CHECK_PRINT
Definition daos_fs.h:1226
@ DFS_CHECK_EVICT_ALL
Definition daos_fs.h:1234
@ DFS_CHECK_VERIFY
Definition daos_fs.h:1232
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)
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:35
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:52
int dfs_local2global_all(dfs_t *dfs, d_iov_t *glob)
char da_hints[DAOS_CONT_HINT_MAX_LEN]
Definition daos_fs.h:94
daos_oclass_id_t da_file_oclass_id
Definition daos_fs.h:89
daos_oclass_id_t da_dir_oclass_id
Definition daos_fs.h:87
uint32_t da_mode
Definition daos_fs.h:85
daos_prop_t * da_props
Definition daos_fs.h:80
uint64_t da_id
Definition daos_fs.h:74
daos_size_t da_chunk_size
Definition daos_fs.h:76
daos_oclass_id_t da_oclass_id
Definition daos_fs.h:78
daos_range_t * iod_rgs
Definition daos_fs.h:102
daos_size_t iod_nr
Definition daos_fs.h:100
daos_obj_id_t doi_oid
Definition daos_fs.h:116
daos_oclass_id_t doi_oclass_id
Definition daos_fs.h:108
daos_oclass_id_t doi_dir_oclass_id
Definition daos_fs.h:112
daos_size_t doi_chunk_size
Definition daos_fs.h:110
daos_oclass_id_t doi_file_oclass_id
Definition daos_fs.h:114
time_t dp_newer
Definition daos_fs.h:1290
char dp_name[DFS_MAX_NAME]
Definition daos_fs.h:1288