WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] blktap2: Remove LVM hacks.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] blktap2: Remove LVM hacks.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 09 Jun 2010 00:00:50 -0700
Delivery-date: Wed, 09 Jun 2010 00:01:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275980576 -3600
# Node ID 0391f15da2f31841de082a45e081009081fe9ab0
# Parent  c22ed5986227121c0ce00cbcc65e2457ac007ccd
blktap2: Remove LVM hacks.

These only mattered for XCP's LVHD with blktap1.

Signed-off-by: Jake Wires <jake.wires@xxxxxxxxxx>
Signed-off-by: Daniel Stodden <daniel.stodden@xxxxxxxxxx>
---
 tools/blktap2/drivers/tapdisk-vbd.c |  288 ------------------------------------
 1 files changed, 288 deletions(-)

diff -r c22ed5986227 -r 0391f15da2f3 tools/blktap2/drivers/tapdisk-vbd.c
--- a/tools/blktap2/drivers/tapdisk-vbd.c       Tue Jun 08 08:01:50 2010 +0100
+++ b/tools/blktap2/drivers/tapdisk-vbd.c       Tue Jun 08 08:02:56 2010 +0100
@@ -280,272 +280,6 @@ fail:
        return err;
 }
 
-/*
- * LVHD hack: have to rescan LVM metadata on pool
- * slaves to register lvchanges made on master.  FIXME.
- */
-static int
-tapdisk_vbd_reactivate_volume(const char *name)
-{
-       int err;
-       char *cmd;
-
-       DPRINTF("reactivating %s\n", name);
-
-       err = asprintf(&cmd, "lvchange -an %s", name);
-       if (err == - 1) {
-               EPRINTF("failed to deactivate %s\n", name);
-               return -errno;
-       }
-
-       err = system(cmd);
-       if (err) {
-               /* 
-                * Assume that LV deactivation failed because the LV is open, 
-                * in which case the LVM information should be up-to-date and 
-                * we don't need this step anyways (so ignore the error). If 
-                * the failure is due to a non-existent LV, the next command 
-                * (lvchange -ay) will catch it.
-                * If we want to be more prudent/paranoid, we can instead check 
-                * whether the LV is currently open (a bit more work).
-                */
-       }
-
-       free(cmd);
-       err = asprintf(&cmd, "lvchange -ay --refresh %s", name);
-       if (err == - 1) {
-               EPRINTF("failed to activate %s\n", name);
-               return -errno;
-       }
-
-       err = system(cmd);
-       if (err)
-               EPRINTF("%s failed: %d\n", cmd, err);
-       free(cmd);
-       return err;
-}
-
-static int
-tapdisk_vbd_reactivate_volumes(td_vbd_t *vbd, int resume)
-{
-       int i, cnt, err;
-       char *name, *new;
-       vhd_context_t vhd;
-       vhd_parent_locator_t *loc;
-
-       new  = NULL;
-       name = NULL;
-
-       if (vbd->storage != TAPDISK_STORAGE_TYPE_LVM)
-               return 0;
-
-       if (!resume && vbd->reactivated)
-               return 0;
-
-       name = strdup(vbd->name);
-       if (!name) {
-               EPRINTF("%s: nomem\n", vbd->name);
-               return -ENOMEM;
-       }
-
-       for (cnt = 0; 1; cnt++) {
-
-               /* only need to reactivate child and parent during resume */
-               if (resume && cnt == 2)
-                       break;
-
-               err = tapdisk_vbd_reactivate_volume(name);
-               if (err)
-                       goto fail;
-
-               if (!strstr(name, "VHD"))
-                       break;
-
-               for (i = 0; i < TD_VBD_EIO_RETRIES; i++) {
-                       err = vhd_open(&vhd, name, VHD_OPEN_RDONLY);
-                       if (!err)
-                               break;
-
-                       libvhd_set_log_level(1);
-                       sleep(TD_VBD_EIO_SLEEP);
-               }
-               libvhd_set_log_level(0);
-               if (err)
-                       goto fail;
-
-               if (vhd.footer.type != HD_TYPE_DIFF) {
-                       vhd_close(&vhd);
-                       break;
-               }
-
-               loc = NULL;
-               for (i = 0; i < 8; i++)
-                       if (vhd.header.loc[i].code == PLAT_CODE_MACX) {
-                               loc = vhd.header.loc + i;
-                               break;
-                       }
-
-               if (!loc) {
-                       vhd_close(&vhd);
-                       err = -EINVAL;
-                       goto fail;
-               }
-
-               free(name);
-               err = vhd_parent_locator_read(&vhd, loc, &name);
-               vhd_close(&vhd);
-
-               if (err) {
-                       name = NULL;
-                       goto fail;
-               }
-
-               /*
-                * vhd_parent_locator_read returns path relative to child:
-                * ./VG_XenStorage--<sr-uuid>-VHD--<vdi-uuid>
-                * we have to convert this to absolute path for lvm
-                */
-               err = asprintf(&new, "/dev/mapper/%s", name + 2);
-               if (err == -1) {
-                       err  = -errno;
-                       goto fail;
-               }
-
-               free(name);
-               name = new;
-       }
-
-       err = 0;
-       vbd->reactivated = 1;
-
-out:
-       free(name);
-       return err;
-
-fail:
-       EPRINTF("failed to reactivate %s: %d\n", vbd->name, err);
-       goto out;
-}
-
-/*
- * LVHD hack: 
- * raw volumes are named /dev/<sr-vg-name>-<sr-uuid>/LV-<sr-uuid>
- * vhd volumes are named /dev/<sr-vg-name>-<sr-uuid>/VHD-<sr-uuid>
- *
- * a live snapshot of a raw volume will result in the writeable volume's
- * name changing from the raw to vhd format, but this change will not be
- * reflected by xenstore.  hence this mess.
- */
-static int
-tapdisk_vbd_check_file(td_vbd_t *vbd)
-{
-       int i, err;
-       regex_t re;
-       size_t len, max;
-       regmatch_t matches[4];
-       char *new, *src, *dst, error[256];
-
-       if (vbd->storage != TAPDISK_STORAGE_TYPE_LVM)
-               return 0;
-
-       err = tapdisk_vbd_reactivate_volume(vbd->name);
-       if (!err)
-               return 0;
-       else
-               DPRINTF("reactivating %s failed\n", vbd->name);
-
-#define HEX   "[A-Za-z0-9]"
-#define UUID  HEX"\\{8\\}-"HEX"\\{4\\}-"HEX"\\{4\\}-"HEX"\\{4\\}-"HEX"\\{12\\}"
-#define VG    "VG_"HEX"\\+"
-#define TYPE  "\\(LV\\|VHD\\)"
-#define RE    "\\(/dev/"VG"-"UUID"/\\)"TYPE"\\(-"UUID"\\)"
-
-       err = regcomp(&re, RE, 0);
-       if (err)
-               goto regerr;
-
-#undef HEX
-#undef UUID
-#undef VG
-#undef TYPE
-#undef RE
-
-       err = regexec(&re, vbd->name, 4, matches, 0);
-       if (err)
-               goto regerr;
-
-       max = strlen("VHD") + 1;
-       for (i = 1; i < 4; i++) {
-               if (matches[i].rm_so == -1 || matches[i].rm_eo == -1) {
-                       EPRINTF("%s: failed to tokenize name\n", vbd->name);
-                       err = -EINVAL;
-                       goto out;
-               }
-
-               max += matches[i].rm_eo - matches[i].rm_so;
-       }
-
-       new = malloc(max);
-       if (!new) {
-               EPRINTF("%s: failed to allocate new name\n", vbd->name);
-               err = -ENOMEM;
-               goto out;
-       }
-
-       src = new;
-       for (i = 1; i < 4; i++) {
-               dst = vbd->name + matches[i].rm_so;
-               len = matches[i].rm_eo - matches[i].rm_so;
-
-               if (i == 2) {
-                       if (memcmp(dst, "LV", len)) {
-                               EPRINTF("%s: bad name format\n", vbd->name);
-                               free(new);
-                               err = -EINVAL;
-                               goto out;
-                       }
-
-                       src += sprintf(src, "VHD");
-                       continue;
-               }
-
-               memcpy(src, dst, len + 1);
-               src += len;
-       }
-
-       *src = '\0';
-
-       err = tapdisk_vbd_reactivate_volume(new);
-       if (err)
-               DPRINTF("reactivating %s failed\n", new);
-
-       err = access(new, F_OK);
-       if (err == -1) {
-               EPRINTF("neither %s nor %s accessible\n",
-                       vbd->name, new);
-               err = -errno;
-               free(new);
-               goto out;
-       }
-
-       DPRINTF("couldn't find %s, trying %s\n", vbd->name, new);
-
-       err = 0;
-       free(vbd->name);
-       vbd->name = new;
-       vbd->type = DISK_TYPE_VHD;
-
-out:
-       regfree(&re);
-       return err;
-
-regerr:
-       regerror(err, &re, error, sizeof(error));
-       EPRINTF("%s: regex failed: %s\n", vbd->name, error);
-       err = -EINVAL;
-       goto out;
-}
-
 /* TODO: ugh, lets not call it parent info... */
 static struct list_head *
 tapdisk_vbd_open_level(td_vbd_t *vbd, char* params, int driver_type, 
td_disk_info_t *parent_info, td_flag_t flags)
@@ -658,10 +392,6 @@ __tapdisk_vbd_open_vdi(td_vbd_t *vbd, td
        struct list_head *images;
        td_disk_info_t *parent_info = NULL;
 
-       err = tapdisk_vbd_reactivate_volumes(vbd, 0);
-       if (err)
-               return err;
-
        flags = (vbd->flags & ~TD_OPEN_SHAREABLE) | extra_flags;
 
        /* loop on each user specified driver.
@@ -1215,22 +945,10 @@ tapdisk_vbd_resume(td_vbd_t *vbd, const 
        vbd->type = drivertype;
 
        for (i = 0; i < TD_VBD_EIO_RETRIES; i++) {
-               err = tapdisk_vbd_check_file(vbd);
-               if (err)
-                       goto sleep;
-
-               err = tapdisk_vbd_reactivate_volumes(vbd, 1);
-               if (err) {
-                       EPRINTF("failed to reactivate %s: %d\n",
-                               vbd->name, err);
-                       goto sleep;
-               }
-
                err = __tapdisk_vbd_open_vdi(vbd, TD_OPEN_STRICT);
                if (!err)
                        break;
 
-       sleep:
                sleep(TD_VBD_EIO_SLEEP);
        }
 
@@ -1887,12 +1605,6 @@ tapdisk_vbd_resume_ring(td_vbd_t *vbd)
 
        tapdisk_vbd_start_queue(vbd);
 
-       err = tapdisk_vbd_reactivate_volumes(vbd, 1);
-       if (err) {
-               EPRINTF("failed to reactivate %s, %d\n", vbd->name, err);
-               goto out;
-       }
-
        for (i = 0; i < TD_VBD_EIO_RETRIES; i++) {
                err = __tapdisk_vbd_open_vdi(vbd, TD_OPEN_STRICT);
                if (err != -EIO)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] blktap2: Remove LVM hacks., Xen patchbot-unstable <=