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 Hewlett Packard Enterprise Development LP
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 */
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;
94 char da_hints[DAOS_CONT_HINT_MAX_LEN];
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
477int
478dfs_lookup(dfs_t *dfs, const char *path, int flags, dfs_obj_t **obj,
479 mode_t *mode, struct stat *stbuf);
480
500int
501dfs_lookup_rel(dfs_t *dfs, dfs_obj_t *parent, const char *name, int flags,
502 dfs_obj_t **obj, mode_t *mode, struct stat *stbuf);
503
516int
517dfs_suggest_oclass(dfs_t *dfs, const char *hint, daos_oclass_id_t *cid);
518
543int
544dfs_open(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
545 int flags, daos_oclass_id_t cid, daos_size_t chunk_size,
546 const char *value, dfs_obj_t **obj);
547
560int
561dfs_dup(dfs_t *dfs, dfs_obj_t *obj, int flags, dfs_obj_t **new_obj);
562
576int
577dfs_obj_local2global(dfs_t *dfs, dfs_obj_t *obj, d_iov_t *glob);
578
592int
593dfs_obj_global2local(dfs_t *dfs, int flags, d_iov_t glob, dfs_obj_t **obj);
594
602int
604
619int
620dfs_read(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
621 daos_size_t *read_size, daos_event_t *ev);
622
640int
641dfs_readx(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
642 daos_size_t *read_size, daos_event_t *ev);
643
656int
657dfs_write(dfs_t *dfs, dfs_obj_t *obj, d_sg_list_t *sgl, daos_off_t off,
658 daos_event_t *ev);
659
674int
675dfs_writex(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl,
676 daos_event_t *ev);
677
687int
688dfs_get_size(dfs_t *dfs, dfs_obj_t *obj, daos_size_t *size);
689
702int
703dfs_punch(dfs_t *dfs, dfs_obj_t *obj, daos_off_t offset, daos_size_t len);
704
723int
724dfs_readdir(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, struct dirent *dirs);
725
747int
748dfs_readdirplus(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr,
749 struct dirent *dirs, struct stat *stbufs);
750
754typedef int (*dfs_filler_cb_t)(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg);
755
776int
778 uint32_t *nr, size_t size, dfs_filler_cb_t op, void *arg);
779
790int
791dfs_dir_anchor_set(dfs_obj_t *obj, const char name[], daos_anchor_t *anchor);
792
813int
814dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors);
815
828int
829dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor);
830
842int
843dfs_mkdir(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode,
844 daos_oclass_id_t cid);
845
859int
860dfs_remove(dfs_t *dfs, dfs_obj_t *parent, const char *name, bool force,
861 daos_obj_id_t *oid);
862
878int
879dfs_move(dfs_t *dfs, dfs_obj_t *parent, const char *name, dfs_obj_t *new_parent,
880 const char *new_name, daos_obj_id_t *oid);
881
893int
894dfs_exchange(dfs_t *dfs, dfs_obj_t *parent1, const char *name1, dfs_obj_t *parent2,
895 const char *name2);
896
905int
906dfs_get_mode(dfs_obj_t *obj, mode_t *mode);
907
918int
920
935int
936dfs_obj_set_oclass(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_oclass_id_t cid);
937
951int
952dfs_obj_set_chunk_size(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_size_t csize);
953
965int
967
977int
978dfs_get_chunk_size(dfs_obj_t *obj, daos_size_t *chunk_size);
979
993int
994dfs_get_symlink_value(dfs_obj_t *obj, char *buf, daos_size_t *size);
995
1012int
1013dfs_update_parent(dfs_obj_t *obj, dfs_obj_t *src_obj, const char *name);
1014
1036int
1037dfs_stat(dfs_t *dfs, dfs_obj_t *parent, const char *name,
1038 struct stat *stbuf);
1039
1049int
1050dfs_ostat(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf);
1051
1053#define DFS_SET_ATTR_MODE (1 << 0)
1055#define DFS_SET_ATTR_ATIME (1 << 1)
1057#define DFS_SET_ATTR_MTIME (1 << 2)
1059#define DFS_SET_ATTR_SIZE (1 << 3)
1061#define DFS_SET_ATTR_UID (1 << 4)
1063#define DFS_SET_ATTR_GID (1 << 5)
1064
1082int
1083dfs_osetattr(dfs_t *dfs, dfs_obj_t *obj, struct stat *stbuf, int flags);
1084
1099int
1100dfs_access(dfs_t *dfs, dfs_obj_t *parent, const char *name, int mask);
1101
1114int
1115dfs_chmod(dfs_t *dfs, dfs_obj_t *parent, const char *name, mode_t mode);
1116
1133int
1134dfs_chown(dfs_t *dfs, dfs_obj_t *parent, const char *name, uid_t uid, gid_t gid, int flags);
1135
1146int
1148
1164int
1165dfs_setxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name,
1166 const void *value, daos_size_t size, int flags);
1167
1181int
1182dfs_getxattr(dfs_t *dfs, dfs_obj_t *obj, const char *name, void *value,
1183 daos_size_t *size);
1184
1195int
1196dfs_removexattr(dfs_t *dfs, dfs_obj_t *obj, const char *name);
1197
1213int
1214dfs_listxattr(dfs_t *dfs, dfs_obj_t *obj, char *list, daos_size_t *size);
1215
1216
1217enum {
1228};
1229
1246int
1247dfs_cont_check(daos_handle_t poh, const char *cont, uint64_t flags, const char *name);
1248
1261int
1262dfs_cont_set_owner(daos_handle_t coh, d_string_t user, uid_t uid, d_string_t group, gid_t gid);
1263
1264/*
1265 * The Pipeline DFS API (everything under this comment) is under heavy development and should not be
1266 * used in production. The API is subject to change.
1267 */
1268
1270typedef struct dfs_pipeline dfs_pipeline_t;
1271
1272enum {
1273 DFS_FILTER_NAME = (1 << 1),
1274 DFS_FILTER_NEWER = (1 << 2),
1275 DFS_FILTER_INCLUDE_DIRS = (1 << 3),
1276};
1277
1279typedef struct {
1281 char dp_name[DFS_MAX_NAME];
1283 time_t dp_newer;
1285 size_t dp_size;
1287
1301int
1302dfs_get_size_by_oid(dfs_t *dfs, daos_obj_id_t oid, daos_size_t chunk_size, daos_size_t *size);
1303
1315int
1316dfs_pipeline_create(dfs_t *dfs, dfs_predicate_t pred, uint64_t flags, dfs_pipeline_t **dpipe);
1317
1325int
1327
1357int
1359 uint32_t *nr, struct dirent *dirs, daos_obj_id_t *oids, daos_size_t *csizes,
1360 uint64_t *nr_scanned);
1361
1372int
1373dfs_cont_scan(daos_handle_t poh, const char *cont, uint64_t flags, const char *name);
1374
1375#if defined(__cplusplus)
1376}
1377#endif /* __cplusplus */
1378#endif /* __DAOS_FS_H__ */
#define DAOS_CONT_HINT_MAX_LEN
Definition daos_cont.h:86
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_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:1270
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_filler_cb_t)(dfs_t *dfs, dfs_obj_t *obj, const char name[], void *arg)
Definition daos_fs.h:754
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:1223
@ DFS_CHECK_REMOVE
Definition daos_fs.h:1221
@ DFS_CHECK_PRINT
Definition daos_fs.h:1219
@ DFS_CHECK_EVICT_ALL
Definition daos_fs.h:1227
@ DFS_CHECK_VERIFY
Definition daos_fs.h:1225
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)
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:1283