-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAOS-16924 dfs: new readdir API #15687
base: feature/dfs_dcache
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||
/** | ||||||
* (C) Copyright 2018-2024 Intel Corporation. | ||||||
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP | ||||||
* | ||||||
* SPDX-License-Identifier: BSD-2-Clause-Patent | ||||||
*/ | ||||||
|
@@ -9,6 +10,7 @@ | |||||
#define D_LOGFAC DD_FAC(dfs) | ||||||
|
||||||
#include <daos/common.h> | ||||||
#include <daos/object.h> | ||||||
|
||||||
#include "dfs_internal.h" | ||||||
|
||||||
|
@@ -113,6 +115,78 @@ dfs_readdirplus(dfs_t *dfs, dfs_obj_t *obj, daos_anchor_t *anchor, uint32_t *nr, | |||||
return readdir_int(dfs, obj, anchor, nr, dirs, stbufs); | ||||||
} | ||||||
|
||||||
int | ||||||
dfs_dir_anchor_init(dfs_obj_t *obj, dfs_dir_anchor_t **_anchor) | ||||||
{ | ||||||
dfs_dir_anchor_t *anchor; | ||||||
|
||||||
if (obj == NULL || !S_ISDIR(obj->mode)) | ||||||
return ENOTDIR; | ||||||
|
||||||
D_ALLOC_PTR(anchor); | ||||||
if (anchor == NULL) | ||||||
return ENOMEM; | ||||||
|
||||||
anchor->dda_dir = obj; | ||||||
daos_anchor_init(&anchor->dda_anchor_int, 0); | ||||||
anchor->dda_bucket_id = 0; | ||||||
anchor->dda_bucket_offset = 0; | ||||||
*_anchor = anchor; | ||||||
return 0; | ||||||
} | ||||||
|
||||||
void | ||||||
dfs_dir_anchor_reset(dfs_dir_anchor_t *anchor) | ||||||
{ | ||||||
daos_anchor_init(&anchor->dda_anchor_int, 0); | ||||||
anchor->dda_bucket_id = 0; | ||||||
anchor->dda_bucket_offset = 0; | ||||||
} | ||||||
|
||||||
bool | ||||||
dfs_dir_anchor_is_eof(dfs_dir_anchor_t *anchor) | ||||||
{ | ||||||
return daos_anchor_is_eof(&anchor->dda_anchor_int); | ||||||
} | ||||||
|
||||||
void | ||||||
dfs_dir_anchor_destroy(dfs_dir_anchor_t *anchor) | ||||||
{ | ||||||
D_FREE(anchor); | ||||||
} | ||||||
|
||||||
int | ||||||
dfs_readdir_s(dfs_t *dfs, dfs_obj_t *dir, dfs_dir_anchor_t *anchor, struct dirent *entry) | ||||||
{ | ||||||
uint32_t nr = 1; | ||||||
int rc; | ||||||
|
||||||
if (daos_oid_cmp(dir->oid, anchor->dda_dir->oid) != 0) | ||||||
return EINVAL; | ||||||
if (daos_anchor_is_eof(&anchor->dda_anchor_int)) | ||||||
return -1; | ||||||
|
||||||
rc = readdir_int(dfs, dir, &anchor->dda_anchor_int, &nr, entry, NULL); | ||||||
if (rc) | ||||||
return rc; | ||||||
|
||||||
/** if we did not enumerate anything, try again to make sure we hit EOF */ | ||||||
if (nr == 0) { | ||||||
if (daos_anchor_is_eof(&anchor->dda_anchor_int)) | ||||||
return -1; /** typically EOF code */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a stupid question but why not using EOF macro directly ?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i can make that change in the follow on PR. i just wasn't sure if EOF was -1 on all linux platforms |
||||||
else | ||||||
return EIO; | ||||||
} | ||||||
return rc; | ||||||
#if 0 | ||||||
/** if no caching, just use the internal anchor with 1 entry */ | ||||||
if (dfs->dcache == NULL) | ||||||
return readdir_int(dfs, obj, &anchor->dda_anchor_int, 1, &dir, NULL); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dir --> entry? |
||||||
else | ||||||
dcache_readdir(dfs->dcache, obj, anchor, dir); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dir --> entry? |
||||||
#endif | ||||||
} | ||||||
|
||||||
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 *udata) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be usefull to add some comments on why this function declaration is commented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since i plan to add it next :-)
note this is all going to the feature branch, so this is just the first piece of the puzzle