Skip to content

Commit

Permalink
DLPX-83174 ZDB fails with input/output error on object store based po…
Browse files Browse the repository at this point in the history
…ols (openzfs#645)
  • Loading branch information
manoj-joseph authored Oct 20, 2022
1 parent 4a6f7a1 commit 1b36949
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
9 changes: 6 additions & 3 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static int objstore = 0;
char *endpoint;
char *region;
char *bucket;
char *creds_profile = "default";
char *creds_profile;
char *protocol;
#ifdef HAVE_LIBZOA
zoa_handle_t *zoa_handle;
Expand Down Expand Up @@ -8626,8 +8626,11 @@ make_objectstore_prop(void)
fnvlist_add_string(nv,
zpool_prop_to_name(ZPOOL_PROP_OBJ_REGION), region);
}
fnvlist_add_string(nv, zpool_prop_to_name(ZPOOL_PROP_OBJ_CRED_PROFILE),
creds_profile);
if (creds_profile != NULL) {
fnvlist_add_string(nv,
zpool_prop_to_name(ZPOOL_PROP_OBJ_CRED_PROFILE),
creds_profile);
}
fnvlist_add_string(nv, zpool_prop_to_name(ZPOOL_PROP_OBJ_PROTOCOL),
protocol);

Expand Down
16 changes: 9 additions & 7 deletions cmd/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ typedef struct ztest_shared_opts {
#define DEFAULT_PROTOCOL "s3"
#define DEFAULT_S3_ENDPOINT "https://s3-us-west-2.amazonaws.com"
#define DEFAULT_S3_REGION "us-west-2"
#define DEFAULT_CREDS_PROFILE "default"
#define DEFAULT_ZOA_LOG "/tmp/zoa.log"
#define DEFAULT_VDEV_COUNT 5
#define DEFAULT_VDEV_SIZE (SPA_MINDEVSIZE * 4) /* 256m default size */
Expand Down Expand Up @@ -244,7 +243,7 @@ static const ztest_shared_opts_t ztest_opts_defaults = {
.zo_obj_store = 0,
.zo_obj_store_protocol = DEFAULT_PROTOCOL,
.zo_obj_store_bucket = { '\0' },
.zo_obj_store_creds_profile = DEFAULT_CREDS_PROFILE,
.zo_obj_store_creds_profile = { '\0' },
.zo_zoa_log_file = DEFAULT_ZOA_LOG,
.zo_alt_ztest = { '\0' },
.zo_alt_libpath = { '\0' },
Expand Down Expand Up @@ -797,7 +796,7 @@ static ztest_option_t option_table[] = {
NO_DEFAULT, NULL},
{ 'z', "object-credentials-profile", "STRING",
"Object store credentials profile",
NO_DEFAULT, DEFAULT_CREDS_PROFILE},
NO_DEFAULT, NULL},
{ 'Z', "use-zettacache", NULL, "use zettacache",
NO_DEFAULT, NULL},
{ 'l', "zoa-log-file", "PATH", "ZFS object agent log file",
Expand Down Expand Up @@ -1309,9 +1308,11 @@ make_vdev_obj_store(void)
zpool_prop_to_name(ZPOOL_PROP_OBJ_REGION),
ztest_opts.zo_obj_store_region);
}
fnvlist_add_string(vdev,
zpool_prop_to_name(ZPOOL_PROP_OBJ_CRED_PROFILE),
ztest_opts.zo_obj_store_creds_profile);
if (*ztest_opts.zo_obj_store_creds_profile != '\0') {
fnvlist_add_string(vdev,
zpool_prop_to_name(ZPOOL_PROP_OBJ_CRED_PROFILE),
ztest_opts.zo_obj_store_creds_profile);
}
return (vdev);
}

Expand Down Expand Up @@ -7097,13 +7098,14 @@ ztest_run_zdb(const char *pool, uint64_t guid)

if (ztest_opts.zo_obj_store) {
ASSERT3P(guid, !=, 0);
snprintf(loc, len, "-T %s %s %s %s %s -B %s -f %s %llu",
snprintf(loc, len, "-T %s %s %s %s %s -B %s %s %s %llu",
ztest_opts.zo_obj_store_protocol,
*ztest_opts.zo_obj_store_endpoint == '\0' ? "" : "-a",
ztest_opts.zo_obj_store_endpoint,
*ztest_opts.zo_obj_store_region == '\0' ? "" : "-g",
ztest_opts.zo_obj_store_region,
ztest_opts.zo_obj_store_bucket,
*ztest_opts.zo_obj_store_creds_profile == '\0' ? "" : "-f",
ztest_opts.zo_obj_store_creds_profile,
(u_longlong_t)guid);
} else {
Expand Down
5 changes: 3 additions & 2 deletions lib/libzutil/zutil_zoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ zoa_create_connection_nvl(const char *protocol, const char *endpoint,
if (region != NULL) {
fnvlist_add_string(nvl, AGENT_REGION, region);
}
if (creds_profile != NULL) {
fnvlist_add_string(nvl, AGENT_CRED_PROFILE, creds_profile);
}
fnvlist_add_string(nvl, AGENT_BUCKET, bucket);
fnvlist_add_string(nvl, AGENT_CRED_PROFILE, creds_profile);

return (nvl);
}
5 changes: 4 additions & 1 deletion tests/zfs-tests/include/libtest.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -2020,8 +2020,11 @@ function run_zdb
log_note "Unknown object store $ZTS_OBJECT_STORE"
return 1
esac
typeset creds_args=""
! is_using_iam_role && \
creds_args="-f $ZTS_CREDS_PROFILE"
zdb_cmd="zdb
-f $ZTS_CREDS_PROFILE
$creds_args
-B $ZTS_BUCKET_NAME
-T $ZTS_OBJECT_STORE
$object_store_args
Expand Down

0 comments on commit 1b36949

Please sign in to comment.