Hello,
We faced an issue that https://docs.ceph.com/en/latest/rados/api/librados/#c.rados_nobjects_list_get_pg_hash_position always returns 0 for our pools.
Ceph version is 16.2.15
Scenario is:
#include <rados/librados.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define POOL_NAME "TODO" // Change this to your pool name
int main(int argc, const char **argv) {
rados_t cluster;
char cluster_name[] = "ceph";
char user_name[] = "";
uint64_t flags = 0;
int ret;
// Initialize the cluster handle
ret = rados_create(&cluster, NULL);
if (ret < 0) {
fprintf(stderr, "Couldn't initialize the cluster handle! error %d\n", ret);
exit(EXIT_FAILURE);
}
fprintf(stdout, "cluster: %p\n", cluster);
// Read the Ceph configuration file
ret = rados_conf_read_file(cluster, "/etc/ceph/ceph.conf");
if (ret < 0) {
fprintf(stderr, "Cannot read config file: %d\n", ret);
exit(EXIT_FAILURE);
}
fprintf(stdout, "read conf: %d\n", ret);
// Connect to the cluster
ret = rados_connect(cluster);
if (ret < 0) {
fprintf(stderr, "Cannot connect to cluster: %d\n", ret);
exit(EXIT_FAILURE);
}
// Open the pool
rados_ioctx_t io_ctx;
ret = rados_ioctx_create(cluster, POOL_NAME, &io_ctx);
if (ret < 0) {
fprintf(stderr, "Cannot open pool %s: %d\n", POOL_NAME, ret);
exit(EXIT_FAILURE);
}
// Create an iterator for all objects in the pool
rados_list_ctx_t list_ctx;
ret = rados_nobjects_list_open(io_ctx, &list_ctx);
if (ret < 0) {
fprintf(stderr, "Cannot list objects: %d\n", ret);
rados_ioctx_destroy(io_ctx);
exit(EXIT_FAILURE);
}
printf("Objects in pool '%s':\n", POOL_NAME);
printf("--------------------------------\n");
// Iterate through all objects
const char *entry;
const char *key;
const char *ns;
while (rados_nobjects_list_next(list_ctx, &entry, &key, &ns) == 0) {
printf("%s\n", entry);
printf("ns: %s\n", ns);
printf("key: %s\n", key);
printf("hash: %d\n", rados_nobjects_list_get_pg_hash_position(list_ctx)); // here we're getting 0 for all objects/pools
}
// Clean up
rados_nobjects_list_close(list_ctx);
rados_ioctx_destroy(io_ctx);
return 0;
}
By my investigation, I found if I use get/seek cursor and after that call rados_nobjects_list_get_pg_hash_position then it returns the corrct hash position.
Questions:
1. Could you please have a look and provide thoughts on why we're getting 0 values in the code?
2. Can it be related to our osd configuraiton like sortbitwise or something else?
3. I found in the code that this hash position is moving only on seeking. Is it bug?
4. Can we add some new C API like rados_nobjects_list_get_cursor_hash_position for getting the hash from the cursor handle (since the cursor handle is actually an hobject, we can simply return get_hash() based on the passed cursor for this API)?
--
Best Regards,
Denis Tingaikin
We faced an issue that https://docs.ceph.com/en/latest/rados/api/librados/#c.rados_nobjects_list_get_pg_hash_position always returns 0 for our pools.
Ceph version is 16.2.15
Scenario is:
#include <rados/librados.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define POOL_NAME "TODO" // Change this to your pool name
int main(int argc, const char **argv) {
rados_t cluster;
char cluster_name[] = "ceph";
char user_name[] = "";
uint64_t flags = 0;
int ret;
// Initialize the cluster handle
ret = rados_create(&cluster, NULL);
if (ret < 0) {
fprintf(stderr, "Couldn't initialize the cluster handle! error %d\n", ret);
exit(EXIT_FAILURE);
}
fprintf(stdout, "cluster: %p\n", cluster);
// Read the Ceph configuration file
ret = rados_conf_read_file(cluster, "/etc/ceph/ceph.conf");
if (ret < 0) {
fprintf(stderr, "Cannot read config file: %d\n", ret);
exit(EXIT_FAILURE);
}
fprintf(stdout, "read conf: %d\n", ret);
// Connect to the cluster
ret = rados_connect(cluster);
if (ret < 0) {
fprintf(stderr, "Cannot connect to cluster: %d\n", ret);
exit(EXIT_FAILURE);
}
// Open the pool
rados_ioctx_t io_ctx;
ret = rados_ioctx_create(cluster, POOL_NAME, &io_ctx);
if (ret < 0) {
fprintf(stderr, "Cannot open pool %s: %d\n", POOL_NAME, ret);
exit(EXIT_FAILURE);
}
// Create an iterator for all objects in the pool
rados_list_ctx_t list_ctx;
ret = rados_nobjects_list_open(io_ctx, &list_ctx);
if (ret < 0) {
fprintf(stderr, "Cannot list objects: %d\n", ret);
rados_ioctx_destroy(io_ctx);
exit(EXIT_FAILURE);
}
printf("Objects in pool '%s':\n", POOL_NAME);
printf("--------------------------------\n");
// Iterate through all objects
const char *entry;
const char *key;
const char *ns;
while (rados_nobjects_list_next(list_ctx, &entry, &key, &ns) == 0) {
printf("%s\n", entry);
printf("ns: %s\n", ns);
printf("key: %s\n", key);
printf("hash: %d\n", rados_nobjects_list_get_pg_hash_position(list_ctx)); // here we're getting 0 for all objects/pools
}
// Clean up
rados_nobjects_list_close(list_ctx);
rados_ioctx_destroy(io_ctx);
return 0;
}
By my investigation, I found if I use get/seek cursor and after that call rados_nobjects_list_get_pg_hash_position then it returns the corrct hash position.
Questions:
1. Could you please have a look and provide thoughts on why we're getting 0 values in the code?
2. Can it be related to our osd configuraiton like sortbitwise or something else?
3. I found in the code that this hash position is moving only on seeking. Is it bug?
4. Can we add some new C API like rados_nobjects_list_get_cursor_hash_position for getting the hash from the cursor handle (since the cursor handle is actually an hobject, we can simply return get_hash() based on the passed cursor for this API)?
--
Best Regards,
Denis Tingaikin
_______________________________________________ Dev mailing list -- dev@xxxxxxx To unsubscribe send an email to dev-leave@xxxxxxx