Skip to contentSkip to conversation

Newbie question about metadata_list.

DISCUSSION Łukasz Szymczyk 2 participants 3 messages Aug 6, 2015 – Aug 7, 2015 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

I'm writing some program to replace image in cluster with it's copy. But I have problem with metadata_list.
I created pool:
#rados mkpool dupa
then I created image:
#rbd create --size 1000 -p mypool image --image-format 2

Below is code which tries to get metadata, but it fails with -EOPNOTSUPP. I compile it with command like this:
g++ file.cpp -lrbd -lrados -I/ceph/source/directory/src

#include <stdio.h>
#include <stdlib.h>
#include "include/rbd/librbd.h"
#include "include/rbd/librbd.hpp"
using namespace ceph;
#include "librbd/ImageCtx.h"

int main() {
	rados_t clu;
	int ret = rados_create(&clu, NULL);
	if (ret) return -1;

	ret = rados_conf_read_file(clu, NULL);
	if (ret) return -1;

	rados_conf_parse_env(clu, NULL);
	ret = rados_connect(clu);
	if (ret) return -1;

	rados_ioctx_t io;
	ret = rados_ioctx_create(clu, "mypool", &io);
	if (ret) return -1;

	rbd_image_t im;
	ret = rbd_open(io, "image", &im, NULL);
	if (ret) return -1;

	librbd::ImageCtx *ic = (librbd::ImageCtx*)im;
	std::string start;
	int max = 1000;
	bufferlist in, out;
	::encode(start, in);
	::encode(max, in);
	ret = ((librados::IoCtx*)&io)->exec(ic->header_oid, "rbd", "metadata_list", in, out);
	if (ret < 0) printf("fail\n");

	return 0;

}

So, my question is: what should be set/enabled to get those metadata? Or maybe what I'm doing wrong here.
Thanks for your help.

Best regards,
Łukasz
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 40 lines · Łukasz Szymczyk

Hi,

I'm writing some program to replace image in cluster with it's copy. But I have problem with metadata_list.
I created pool:
#rados mkpool dupa
then I created image:
#rbd create --size 1000 -p mypool image --image-format 2

Below is code which tries to get metadata, but it fails with -EOPNOTSUPP. I compile it with command like this:
g++ file.cpp -lrbd -lrados -I/ceph/source/directory/src

#include <stdio.h>
#include <stdlib.h>
#include "include/rbd/librbd.h"
#include "include/rbd/librbd.hpp"
using namespace ceph;
#include "librbd/ImageCtx.h"

int main() {
        rados_t clu;
        int ret = rados_create(&clu, NULL);
        if (ret) return -1;

        ret = rados_conf_read_file(clu, NULL);
        if (ret) return -1;

        rados_conf_parse_env(clu, NULL);
        ret = rados_connect(clu);
        if (ret) return -1;

        rados_ioctx_t io;
        ret = rados_ioctx_create(clu, "mypool", &io);
        if (ret) return -1;

        rbd_image_t im;
        ret = rbd_open(io, "image", &im, NULL);
        if (ret) return -1;
Quoted 8 lines
        librbd::ImageCtx *ic = (librbd::ImageCtx*)im;
        std::string start;
        int max = 1000;
        bufferlist in, out;
        ::encode(start, in);
        ::encode(max, in);
        ret = ((librados::IoCtx*)&io)->exec(ic->header_oid, "rbd", "metadata_list", in, out);
        if (ret < 0) printf("fail\n");

You should use rbd_metadata_list() C API instead of this.

Quoted 7 lines
        return 0;

}

So, my question is: what should be set/enabled to get those metadata? Or maybe what I'm doing wrong here.

Try "rbd image-meta list image"?

It's a fairly recent feature, are you sure your OSDs support it? What's the output of "ceph daemon osd.0 version"?

Thanks,

Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 41 lines · Łukasz Szymczyk

On Thu, 6 Aug 2015 15:01:54 +0300
Ilya Dryomov <[email protected]> wrote:

Hi,

Quoted 16 lines
Quoted 5 lines · Łukasz Szymczyk

Hi,

I'm writing some program to replace image in cluster with it's copy. But I have problem with metadata_list.

Quoted 8 lines
        librbd::ImageCtx *ic = (librbd::ImageCtx*)im;
        std::string start;
        int max = 1000;
        bufferlist in, out;
        ::encode(start, in);
        ::encode(max, in);
        ret = ((librados::IoCtx*)&io)->exec(ic->header_oid, "rbd", "metadata_list", in, out);
        if (ret < 0) printf("fail\n");
Quoted 1 line

You should use rbd_metadata_list() C API instead of this.

Looks like my ceph version doesn't have it.

Quoted 10 lines
Quoted 8 lines

        return 0;

}

So, my question is: what should be set/enabled to get those metadata? Or maybe what I'm doing wrong here.

Try "rbd image-meta list image"?

I've got this:

# rbd image-meta list image
rbd: error parsing command 'image-meta'; -h or --help for usage
Quoted 1 line
Quoted 5 lines
Quoted 2 lines

It's a fairly recent feature, are you sure your OSDs support it? What's the output of "ceph daemon osd.0 version"?

# ceph daemon osd.0 version
{"version":"0.80.9"}

image metadata was introduced in v9.0.0.

Thanks,

Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html