ceph/rbd block driver for qemu-kvm

RBD is an block driver for the distributed file system Ceph
(http://ceph.newdream.net/). This driver uses librados (which is part
of the Ceph server) for direct access to the Ceph object store and is
running entirely in userspace (Yehuda also wrote a driver for the
linux kernel, that can be used to access rbd volumes as a block
device).

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Christian Brunner <chb@muc.de>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Christian Brunner 2010-12-06 20:53:01 +01:00 committed by Kevin Wolf
parent 2a81998a1a
commit f27aaf4b53
4 changed files with 1183 additions and 0 deletions

View File

@ -24,6 +24,7 @@ block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o
block-nested-$(CONFIG_WIN32) += raw-win32.o
block-nested-$(CONFIG_POSIX) += raw-posix.o
block-nested-$(CONFIG_CURL) += curl.o
block-nested-$(CONFIG_RBD) += rbd.o
block-obj-y += $(addprefix block/, $(block-nested-y))

1059
block/rbd.c Normal file

File diff suppressed because it is too large Load Diff

71
block/rbd_types.h Normal file
View File

@ -0,0 +1,71 @@
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.LIB.
*
*/
#ifndef CEPH_RBD_TYPES_H
#define CEPH_RBD_TYPES_H
/*
* rbd image 'foo' consists of objects
* foo.rbd - image metadata
* foo.00000000
* foo.00000001
* ... - data
*/
#define RBD_SUFFIX ".rbd"
#define RBD_DIRECTORY "rbd_directory"
#define RBD_INFO "rbd_info"
#define RBD_DEFAULT_OBJ_ORDER 22 /* 4MB */
#define RBD_MAX_OBJ_NAME_SIZE 96
#define RBD_MAX_BLOCK_NAME_SIZE 24
#define RBD_MAX_SEG_NAME_SIZE 128
#define RBD_COMP_NONE 0
#define RBD_CRYPT_NONE 0
#define RBD_HEADER_TEXT "<<< Rados Block Device Image >>>\n"
#define RBD_HEADER_SIGNATURE "RBD"
#define RBD_HEADER_VERSION "001.005"
struct rbd_info {
uint64_t max_id;
} __attribute__ ((packed));
struct rbd_obj_snap_ondisk {
uint64_t id;
uint64_t image_size;
} __attribute__((packed));
struct rbd_obj_header_ondisk {
char text[40];
char block_name[RBD_MAX_BLOCK_NAME_SIZE];
char signature[4];
char version[8];
struct {
uint8_t order;
uint8_t crypt_type;
uint8_t comp_type;
uint8_t unused;
} __attribute__((packed)) options;
uint64_t image_size;
uint64_t snap_seq;
uint32_t snap_count;
uint32_t reserved;
uint64_t snap_names_len;
struct rbd_obj_snap_ondisk snaps[0];
} __attribute__((packed));
#endif

52
configure vendored
View File

@ -332,6 +332,7 @@ zero_malloc=""
trace_backend="nop"
trace_file="trace"
spice=""
rbd=""
# OS specific
if check_define __linux__ ; then
@ -741,6 +742,10 @@ for opt do
;;
--*dir)
;;
--disable-rbd) rbd="no"
;;
--enable-rbd) rbd="yes"
;;
*) echo "ERROR: unknown option $opt"; show_help="yes"
;;
esac
@ -934,6 +939,7 @@ echo " --trace-file=NAME Full PATH,NAME of file to store traces"
echo " Default:trace-<pid>"
echo " --disable-spice disable spice"
echo " --enable-spice enable spice"
echo " --enable-rbd enable building the rados block device (rbd)"
echo ""
echo "NOTE: The object files are built at the place where configure is launched"
exit 1
@ -1745,6 +1751,48 @@ if test "$mingw32" != yes -a "$pthread" = no; then
exit 1
fi
##########################################
# rbd probe
if test "$rbd" != "no" ; then
cat > $TMPC <<EOF
#include <stdio.h>
#include <rados/librados.h>
int main(void) { rados_initialize(0, NULL); return 0; }
EOF
rbd_libs="-lrados -lcrypto"
if compile_prog "" "$rbd_libs" ; then
librados_too_old=no
cat > $TMPC <<EOF
#include <stdio.h>
#include <rados/librados.h>
#ifndef CEPH_OSD_TMAP_SET
#error missing CEPH_OSD_TMAP_SET
#endif
int main(void) {
int (*func)(const rados_pool_t pool, uint64_t *snapid) = rados_selfmanaged_snap_create;
rados_initialize(0, NULL);
return 0;
}
EOF
if compile_prog "" "$rbd_libs" ; then
rbd=yes
libs_tools="$rbd_libs $libs_tools"
libs_softmmu="$rbd_libs $libs_softmmu"
else
rbd=no
librados_too_old=yes
fi
else
if test "$rbd" = "yes" ; then
feature_not_found "rados block device"
fi
rbd=no
fi
if test "$librados_too_old" = "yes" ; then
echo "-> Your librados version is too old - upgrade needed to have rbd support"
fi
fi
##########################################
# linux-aio probe
@ -2354,6 +2402,7 @@ echo "vhost-net support $vhost_net"
echo "Trace backend $trace_backend"
echo "Trace output file $trace_file-<pid>"
echo "spice support $spice"
echo "rbd support $rbd"
if test $sdl_too_old = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have SDL support"
@ -2627,6 +2676,9 @@ echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
if test "$zero_malloc" = "yes" ; then
echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
fi
if test "$rbd" = "yes" ; then
echo "CONFIG_RBD=y" >> $config_host_mak
fi
# USB host support
case "$usb" in