Skip to content
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-13938 dfuse: adjust offset in readdir cache entry list #15213

Open
wants to merge 1 commit into
base: google/2.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/client/dfuse/ops/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ dfuse_dre_drop(struct dfuse_info *dfuse_info, struct dfuse_obj_hdl *oh)
struct dfuse_readdir_hdl *hdl;
struct dfuse_readdir_c *drc, *next;
uint32_t oldref;
off_t expected_offset = 2;
off_t next_offset = 0;

DFUSE_TRA_DEBUG(oh, "Dropping ref on %p", oh->doh_rd);

Expand Down Expand Up @@ -161,10 +161,11 @@ dfuse_dre_drop(struct dfuse_info *dfuse_info, struct dfuse_obj_hdl *oh)
oh->doh_ie->ie_rd_hdl = NULL;

d_list_for_each_entry_safe(drc, next, &hdl->drh_cache_list, drc_list) {
D_ASSERT(drc->drc_offset == expected_offset);
D_ASSERT(drc->drc_next_offset == expected_offset + 1 ||
drc->drc_next_offset == READDIR_EOD);
expected_offset = drc->drc_next_offset;
/** Verify offset/next_offset are consistent in the entry cache list */
D_ASSERTF(next_offset == 0 || next_offset == drc->drc_offset,
"Inconsistent offset list %#lx prev next %#lx " DF_DE,
drc->drc_offset, next_offset, DP_DE(drc->drc_name));
next_offset = drc->drc_next_offset;
if (drc->drc_rlink)
d_hash_rec_decref(&dfuse_info->dpi_iet, drc->drc_rlink);
D_FREE(drc);
Expand Down Expand Up @@ -472,7 +473,7 @@ dfuse_do_readdir(struct dfuse_info *dfuse_info, fuse_req_t req, struct dfuse_obj

if (rc != 0) {
DFUSE_TRA_DEBUG(oh, "Problem finding file %d", rc);
D_GOTO(reply, 0);
D_GOTO(reply, rc);
}
/* Check oid is the same! */

Expand Down Expand Up @@ -689,7 +690,8 @@ dfuse_do_readdir(struct dfuse_info *dfuse_info, fuse_req_t req, struct dfuse_obj
if (rc == ENOENT) {
DFUSE_TRA_DEBUG(oh, "File does not exist");
D_FREE(drc);
continue;
/** legitimate race */
D_GOTO(next, rc = 0);
} else if (rc != 0) {
DFUSE_TRA_DEBUG(oh, "Problem finding file %d", rc);
D_FREE(drc);
Expand Down Expand Up @@ -759,6 +761,12 @@ dfuse_do_readdir(struct dfuse_info *dfuse_info, fuse_req_t req, struct dfuse_obj
}

if (drc) {
if (oh->doh_rd_nextc != NULL)
/**
* Fix next offset of previous cache entry in case some
* dre entries were skipped (e.g. failed stat call).
*/
oh->doh_rd_nextc->drc_next_offset = drc->drc_offset;
oh->doh_rd_nextc = drc;
DFUSE_TRA_DEBUG(hdl, "Appending offset %#lx to list, next %#lx",
drc->drc_offset, drc->drc_next_offset);
Expand All @@ -769,12 +777,15 @@ dfuse_do_readdir(struct dfuse_info *dfuse_info, fuse_req_t req, struct dfuse_obj
dre->dre_offset = 0;
buff_offset += written;
added++;
next:
offset++;
oh->doh_rd_offset = dre->dre_next_offset;

if (dre->dre_next_offset == READDIR_EOD) {
DFUSE_TRA_DEBUG(oh, "Reached end of directory");
oh->doh_rd_offset = READDIR_EOD;
if (hdl->drh_caching && oh->doh_rd_nextc != NULL)
oh->doh_rd_nextc->drc_next_offset = READDIR_EOD;
D_GOTO(reply, rc = 0);
}
}
Expand Down
Loading