Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/client/dfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ dfs_obj_set_oclass(dfs_t *dfs, dfs_obj_t *obj, int flags, daos_oclass_id_t cid)
D_GOTO(out, rc = daos_der2errno(rc));
}

/** if this is root obj, we need to update the cached handle oclass */
/* Cache the updated default child oclass on the open directory handle. */
obj->d.oclass = cid;

/** if this is root obj, we need to update the cached default child oclass */
if (daos_oid_cmp(obj->oid, dfs->root.oid) == 0)
dfs->root.d.oclass = cid;

Expand Down
20 changes: 15 additions & 5 deletions src/tests/suite/dfs_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2246,21 +2246,31 @@ compare_oclass(daos_handle_t coh, daos_oclass_id_t acid, daos_oclass_id_t ecid)
{
int rc;
daos_obj_id_t oid = {};
daos_oclass_id_t normalized_ecid;

/*
* get the expected oclass - this is needed to convert things with GX to fit them in current
* system.
*/
rc = daos_obj_generate_oid(coh, &oid, 0, ecid, 0, 0);
assert_rc_equal(rc, 0);
ecid = daos_obj_id2class(oid);
normalized_ecid = daos_obj_id2class(oid);

if (acid == ecid)
if (acid == ecid || acid == normalized_ecid)
return 0;
else
return 1;
}

static daos_oclass_id_t
expected_dir_oclass(daos_oclass_id_t cid, daos_oclass_id_t fallback)
{
if (daos_cid_is_ec(cid))
return fallback;

return cid;
}

static void
dfs_test_oclass_hints(void **state)
{
Expand Down Expand Up @@ -2439,7 +2449,7 @@ dfs_test_oclass_hints(void **state)
/** get the dir info to query what oclass will be used */
rc = dfs_obj_get_info(dfs_l, dir, &oinfo);
assert_int_equal(rc, 0);
rc = compare_oclass(coh, oinfo.doi_dir_oclass_id, OC_RP_2G1);
rc = compare_oclass(coh, oinfo.doi_dir_oclass_id, expected_dir_oclass(ecidx, OC_RP_2G1));
assert_int_equal(rc, 0);
rc = compare_oclass(coh, oinfo.doi_file_oclass_id, ecidx);
assert_int_equal(rc, 0);
Expand Down Expand Up @@ -2506,7 +2516,7 @@ dfs_test_oclass_hints(void **state)
/** get the dir info to query what oclass will be used */
rc = dfs_obj_get_info(dfs_l, dir, &oinfo);
assert_int_equal(rc, 0);
rc = compare_oclass(coh, oinfo.doi_dir_oclass_id, OC_RP_3G1);
rc = compare_oclass(coh, oinfo.doi_dir_oclass_id, expected_dir_oclass(ecidx, OC_RP_3G1));
assert_int_equal(rc, 0);
rc = compare_oclass(coh, oinfo.doi_file_oclass_id, ecidx);
assert_int_equal(rc, 0);
Expand Down Expand Up @@ -2573,7 +2583,7 @@ dfs_test_oclass_hints(void **state)
/** get the dir info to query what oclass will be used */
rc = dfs_obj_get_info(dfs_l, dir, &oinfo);
assert_int_equal(rc, 0);
rc = compare_oclass(coh, oinfo.doi_dir_oclass_id, OC_RP_4G1);
rc = compare_oclass(coh, oinfo.doi_dir_oclass_id, expected_dir_oclass(ecidx, OC_RP_4G1));
assert_int_equal(rc, 0);
rc = compare_oclass(coh, oinfo.doi_file_oclass_id, ecidx);
assert_int_equal(rc, 0);
Expand Down
Loading