diff --git a/src/client/dfs/dir.c b/src/client/dfs/dir.c index 1b17cbc6039..99846c7f19f 100644 --- a/src/client/dfs/dir.c +++ b/src/client/dfs/dir.c @@ -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; diff --git a/src/tests/suite/dfs_unit_test.c b/src/tests/suite/dfs_unit_test.c index 41931fc1d1d..f7d654a643c 100644 --- a/src/tests/suite/dfs_unit_test.c +++ b/src/tests/suite/dfs_unit_test.c @@ -2246,6 +2246,7 @@ 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 @@ -2253,14 +2254,23 @@ compare_oclass(daos_handle_t coh, daos_oclass_id_t acid, daos_oclass_id_t ecid) */ 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) { @@ -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); @@ -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); @@ -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);