[Sheepdog] how can i mount linux host on Sheepdog device?
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Sat May 21 14:44:05 CEST 2011
At Tue, 17 May 2011 13:22:47 +0900,
igoigo246 wrote:
> Thx
>
> I try this operation.
> Operation successful.
>
> but qemu-1.4.1 can't patched.
>
> Attached please find a patch.
>
> if possible this patch commit upstream.
>
> thx for reading.
I've sent the patch to the qemu mainline.
The patched version is also available at:
git://sheepdog.git.sourceforge.net/gitroot/sheepdog/qemu iscsi
See also https://sourceforge.net/apps/trac/sheepdog/wiki/General%20Protocol%20Support
Thanks,
Kazutaka
>
>
>
>
>
> 2011-05-16 (月) の 18:28 +0900 に MORITA Kazutaka さんは書きました:
> > At Mon, 16 May 2011 15:20:55 +0900,
> > igoigo246 wrote:
> > >
> > > For example
> > >
> > > qemu-img create sheepdog:Device 10G OK.
> > >
> > > But I want to Pararel Distributed Block Device.
> > >
> > > SheepDog are two possibilities that qemu-img and pararel distributed
> > > blocking device.
> > >
> > > Please make linux client for SheepDog.
> >
> > Currently, there is no direct support for any client other than QEMU,
> > but there are some means to export Sheepdog volumes using more general
> > protocols.
> >
> > - iSCSI
> > 1. Apply a patch to support data preallocation:
> > http://lists.wpkg.org/pipermail/sheepdog/2010-October/000706.html
> >
> > 2. Create a image with data preallocation.
> > $ qemu-img create sheepdog:image -o preallocation=data 1G
> >
> > 3. Install iSCSI target daemon (tgt) with Sheepdog support
> > $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/tomo/tgt.git -b sheepdog
> > $ cd tgt
> > $ make
> > # make install
> >
> > 4. Setup tgt
> > # tgtd
> > # tgtadm --op new --mode target --tid 1 --lld iscsi -T iqn.2001-04.com.example:storage.sr.rose.sys1.xyz
> > # tgtadm --op new --mode logicalunit --tid 1 --lun 1 -b image --bstype sheepdog
> >
> > See also http://www.mail-archive.com/sheepdog@lists.wpkg.org/msg00679.html
> >
> > - NBD
> > 1. Create a Sheepdog image
> > $ qemu-img create sheepdog:image 4G
> >
> > 2. Start qemu-nbd on the one of Sheepdog servers
> > $ qemu-nbd sheepdog:image
> >
> > The image is exported on port 10809
> >
> >
> > Thanks,
> >
> > Kazutaka
>
> [2 qemu.patch <text/x-patch; UTF-8 (7bit)>]
> diff -Nru qemu.org/block/sheepdog.c qemu/block/sheepdog.c
> --- qemu.org/block/sheepdog.c 2011-05-16 20:31:15.000000000 +0900
> +++ qemu/block/sheepdog.c 2011-05-16 20:39:46.000000000 +0900
> @@ -1292,12 +1292,65 @@
> return 0;
> }
>
> +static int sd_prealloc(uint32_t vid, int64_t vdi_size)
> +{
> + int fd, ret;
> + SheepdogInode *inode;
> + char *buf;
> + unsigned long idx, max_idx;
> +
> + fd = connect_to_sdog(NULL, NULL);
> + if (fd < 0) {
> + return -EIO;
> + }
> +
> + inode = qemu_malloc(sizeof(*inode));
> + buf = qemu_malloc(SD_DATA_OBJ_SIZE);
> +
> + ret = read_object(fd, (char *)inode, vid_to_vdi_oid(vid),
> + 0, sizeof(*inode), 0);
> +
> + max_idx = (vdi_size + SD_DATA_OBJ_SIZE - 1) / SD_DATA_OBJ_SIZE;
> +
> + for (idx = 0; idx < max_idx; idx++) {
> + uint64_t oid;
> + oid = vid_to_data_oid(vid, idx);
> +
> + if (inode->data_vdi_id[idx]) {
> + ret = read_object(fd, buf, vid_to_vdi_oid(inode->data_vdi_id[idx]),
> + 1, SD_DATA_OBJ_SIZE, 0);
> + if (ret)
> + goto out;
> + } else {
> + memset(buf, 0, SD_DATA_OBJ_SIZE);
> + }
> +
> + ret = write_object(fd, buf, oid, 1, SD_DATA_OBJ_SIZE, 0, 1);
> + if (ret)
> + goto out;
> +
> + inode->data_vdi_id[idx] = vid;
> + ret = write_object(fd, (char *)inode, vid_to_vdi_oid(vid),
> + 1, sizeof(*inode), 0, 0);
> + if (ret)
> + goto out;
> + }
> +out:
> + free(inode);
> + free(buf);
> + closesocket(fd);
> +
> + return ret;
> +}
> +
> +
> static int sd_create(const char *filename, QEMUOptionParameter *options)
> {
> int ret;
> uint32_t vid = 0, base_vid = 0;
> int64_t vdi_size = 0;
> char *backing_file = NULL;
> + int prealloc = 0;
> BDRVSheepdogState s;
> char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN];
> uint32_t snapid;
> @@ -1317,7 +1370,18 @@
> vdi_size = options->value.n;
> } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {
> backing_file = options->value.s;
> - }
> + } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) {
> + if (!options->value.s || !strcmp(options->value.s, "off")) {
> + prealloc = 0;
> + } else if (!strcmp(options->value.s, "data")) {
> + prealloc = 1;
> + } else {
> + error_report("Invalid preallocation mode: '%s'\n",
> + options->value.s);
> + return -EINVAL;
> + }
> +
> + }
> options++;
> }
>
> @@ -1353,8 +1417,12 @@
> base_vid = s->inode.vdi_id;
> bdrv_delete(bs);
> }
> + ret = do_sd_create((char *)filename, vdi_size, base_vid, &vid, 0, NULL, NULL);
> + if (!prealloc || ret)
> + return ret;
> +
> + return sd_prealloc(vid, vdi_size);
>
> - return do_sd_create((char *)vdi, vdi_size, base_vid, &vid, 0, s.addr, s.port);
> }
>
> static void sd_close(BlockDriverState *bs)
> @@ -1990,6 +2058,11 @@
> .type = OPT_STRING,
> .help = "File name of a base image"
> },
> + {
> + .name = BLOCK_OPT_PREALLOC,
> + .type = OPT_STRING,
> + .help = "Preallocation mode (allowed values: off, data)"
> + },
> { NULL }
> };
>
> [3 <text/plain; us-ascii (7bit)>]
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog
More information about the sheepdog
mailing list