-
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-4763 dfs: New API for anchor split to allow parallelizing dfs_readdir #2652
Changes from 2 commits
a0b33e5
3e5817d
c50bf20
d218328
90642f9
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 |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
#include <daos/common.h> | ||
#include <daos/event.h> | ||
#include <daos/container.h> | ||
#include <daos/object.h> | ||
#include <daos/array.h> | ||
|
||
#include "daos.h" | ||
|
@@ -3956,3 +3957,49 @@ dfs_umount_root_cont(dfs_t *dfs) | |
rc = daos_cont_close(coh, NULL); | ||
return daos_der2errno(rc); | ||
} | ||
|
||
int | ||
dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors) | ||
{ | ||
struct daos_obj_layout *layout; | ||
int rc; | ||
|
||
if (obj == NULL || nr == NULL || !S_ISDIR(obj->mode)) | ||
return EINVAL; | ||
|
||
rc = dc_obj_layout_get(obj->oh, &layout); | ||
if (rc) | ||
return rc; | ||
|
||
/** TBD - support more than per shard iteration */ | ||
if (*nr !=0 && *nr != layout->ol_nr) { | ||
D_ERROR("For now, num anchors should be the same as what is" | ||
"reported as optimal\n"); | ||
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. (style) break quoted strings at a space character |
||
D_GOTO(out, rc = ENOSYS); | ||
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. (style) ENOSYS means 'invalid syscall nr' and nothing else |
||
} | ||
|
||
*nr = layout->ol_nr; | ||
|
||
if (anchors) { | ||
uint32_t i; | ||
|
||
for (i = 0; i < layout->ol_nr; i++) { | ||
daos_anchor_set_zero(&anchors[i]); | ||
dc_obj_shard2anchor(&anchors[i], i); | ||
daos_anchor_set_flags(&anchors[i], DIOF_TO_SPEC_SHARD); | ||
} | ||
} | ||
out: | ||
daos_obj_layout_free(layout); | ||
return rc; | ||
} | ||
|
||
int | ||
dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor) | ||
{ | ||
/** TBD - support more than per shard iteration */ | ||
daos_anchor_set_zero(anchor); | ||
dc_obj_shard2anchor(anchor, index); | ||
daos_anchor_set_flags(anchor, DIOF_TO_SPEC_SHARD); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,6 +460,44 @@ 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); | ||
|
||
/** | ||
* Provide a function for large directories to split an anchor to be able to | ||
* execute a parallel readdir or iterate. This routine suggests the optimal | ||
* number of anchors to use instead of just 1 and optionally returns all those | ||
* anchors. The user would allocate the array of anchors after querying the | ||
* number of anchors needed. Alternatively, user does not provide an array and | ||
* can call dfs_obj_anchor_set() for every anchor to set. | ||
* | ||
* The user could suggest how many anchors to split the iteration over. This | ||
* feature is not supported yet. | ||
* | ||
* \param[in] obj Dir object to split anchor for. | ||
* \param[in/out] | ||
* nr [in]: Number of anchors requested and allocated in | ||
* \a anchors. Pass 0 for DAOS to recommend split num. | ||
* [out]: Number of anchors recommended if 0 is passed in. | ||
* \param[in] anchors Optional array of anchors that are split. | ||
* | ||
* \return 0 on success, errno code on failure. | ||
*/ | ||
int | ||
dfs_obj_anchor_split(dfs_obj_t *obj, uint32_t *nr, daos_anchor_t *anchors); | ||
|
||
/** | ||
* Set an anchor with an index based on split done with dfs_obj_anchor_split. | ||
* The anchor passed will be re-intialized and set to start and finish iteration | ||
* based on the specified index. | ||
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. (style) trailing whitespace |
||
* | ||
* \param[in] obj Dir object to split anchor for. | ||
* \param[in] index Index of set this anchor for iteration. | ||
* \param[in,out] | ||
* anchor Hash anchor to set. | ||
* | ||
* \return 0 on success, errno code on failure. | ||
*/ | ||
int | ||
dfs_obj_anchor_set(dfs_obj_t *obj, uint32_t index, daos_anchor_t *anchor); | ||
|
||
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. (style) trailing whitespace |
||
/** | ||
* Create a directory. | ||
* | ||
|
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.
(style) spaces required around that '!=' (ctx:WxV)