[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 03/17] tools: block-remus: use correct way to get remus_image



On Oct 13, 2014 10:15 PM, "Wen Congyang" <wency@xxxxxxxxxxxxxx> wrote:
>
> We set remus_image in backup_read(). If we do flush
> before the first read operation, remus_image will be
> NULL. Pass image to remus via the callback td_open().
>
> Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx>
> Acked-by: Shriram Rajagopalan <rshriram@xxxxxxxxx>
> ---
> Âtools/blktap2/drivers/block-aio.c    Â| 6 ++++--
> Âtools/blktap2/drivers/block-cache.c   Â| 5 +++--
> Âtools/blktap2/drivers/block-log.c    Â| 5 +++--
> Âtools/blktap2/drivers/block-qcow.c    | 6 ++++--
> Âtools/blktap2/drivers/block-ram.c    Â| 6 ++++--
> Âtools/blktap2/drivers/block-remus.c   Â| 8 ++++----
> Âtools/blktap2/drivers/block-vhd.c    Â| 6 ++++--
> Âtools/blktap2/drivers/tapdisk-interface.c | 3 +--
> Âtools/blktap2/drivers/tapdisk.h     Â| 2 +-
> Â9 files changed, 28 insertions(+), 19 deletions(-)
>
> diff --git a/tools/blktap2/drivers/block-aio.c b/tools/blktap2/drivers/block-aio.c
> index 1b560e5..27ba07d 100644
> --- a/tools/blktap2/drivers/block-aio.c
> +++ b/tools/blktap2/drivers/block-aio.c
> @@ -40,6 +40,7 @@
> Â#include "tapdisk.h"
> Â#include "tapdisk-driver.h"
> Â#include "tapdisk-interface.h"
> +#include "tapdisk-image.h"
>
> Â#define MAX_AIO_REQSÂ Â Â Â ÂTAPDISK_DATA_REQUESTS
>
> @@ -111,11 +112,12 @@ static int tdaio_get_image_info(int fd, td_disk_info_t *info)
> Â}
>
> Â/* Open the disk file and initialize aio state. */
> -int tdaio_open(td_driver_t *driver, const char *name, td_flag_t flags,
> -Â Â Â Â Â Â Â td_uuid_t uuid)
> +int tdaio_open(td_driver_t *driver, td_image_t *image, td_uuid_t uuid)
> Â{
> Â Â Â Â int i, fd, ret, o_flags;
> Â Â Â Â struct tdaio_state *prv;
> +Â Â Â Âconst char *name = image->name;
> +Â Â Â Âtd_flag_t flags = image->flags;
>
> Â Â Â Â ret = 0;
> Â Â Â Â prv = (struct tdaio_state *)driver->data;
> diff --git a/tools/blktap2/drivers/block-cache.c b/tools/blktap2/drivers/block-cache.c
> index cd6ea6a..ff2c773 100644
> --- a/tools/blktap2/drivers/block-cache.c
> +++ b/tools/blktap2/drivers/block-cache.c
> @@ -517,12 +517,13 @@ block_cache_put_request(block_cache_t *cache, block_cache_request_t *breq)
> Â}
>
> Âstatic int
> -block_cache_open(td_driver_t *driver, const char *name, td_flag_t flags,
> -Â Â Â Â Â Â Â Â td_uuid_t uuid)
> +block_cache_open(td_driver_t *driver, td_image_t *image, td_uuid_t uuid)
> Â{
> Â Â Â Â int i, err;
> Â Â Â Â radix_tree_t *tree;
> Â Â Â Â block_cache_t *cache;
> +Â Â Â Âconst char *name = image->name;
> +Â Â Â Âtd_flag_t flags = image->flags;
>
> Â Â Â Â if (!td_flag_test(flags, TD_OPEN_RDONLY))
> Â Â Â Â Â Â Â Â return -EINVAL;
> diff --git a/tools/blktap2/drivers/block-log.c b/tools/blktap2/drivers/block-log.c
> index 7b33b63..80351d3 100644
> --- a/tools/blktap2/drivers/block-log.c
> +++ b/tools/blktap2/drivers/block-log.c
> @@ -585,11 +585,12 @@ static void ctl_request(event_id_t id, char mode, void *private)
>
> Âstatic int tdlog_close(td_driver_t*);
>
> -static int tdlog_open(td_driver_t* driver, const char* name, td_flag_t flags,
> -Â Â Â Â Â Â Â Â Â Â Âtd_uuid_t uuid)
> +static int tdlog_open(td_driver_t* driver, td_image_t *image, td_uuid_t uuid)
> Â{
> Â Âstruct tdlog_state* s = (struct tdlog_state*)driver->data;
> Â Âint rc;
> +Â const char *name = image->name;
> +Â td_flag_t flags = image->flags;
>
> Â Âmemset(s, 0, sizeof(*s));
>
> diff --git a/tools/blktap2/drivers/block-qcow.c b/tools/blktap2/drivers/block-qcow.c
> index 64dfafc..c63bd9d 100644
> --- a/tools/blktap2/drivers/block-qcow.c
> +++ b/tools/blktap2/drivers/block-qcow.c
> @@ -45,6 +45,7 @@
> Â#include "qcow.h"
> Â#include "blk.h"
> Â#include "atomicio.h"
> +#include "tapdisk-image.h"
>
> Â/* *BSD has no O_LARGEFILE */
> Â#ifndef O_LARGEFILE
> @@ -865,14 +866,15 @@ out:
> Â}
>
> Â/* Open the disk file and initialize qcow state. */
> -int tdqcow_open (td_driver_t *driver, const char *name, td_flag_t flags,
> -Â Â Â Â Â Â Â Â td_uuid_t uuid)
> +int tdqcow_open (td_driver_t *driver, td_image_t *image, td_uuid_t uuid)
> Â{
> Â Â Â Â int fd, len, i, ret, size, o_flags;
> Â Â Â Â td_disk_info_t *bs = &(driver->info);
>     struct tdqcow_state Â*s = (struct tdqcow_state *)driver->data;
> Â Â Â Â QCowHeader header;
> Â Â Â Â uint64_t final_cluster = 0;
> +Â Â Â Âconst char *name = image->name;
> +Â Â Â Âtd_flag_t flags = image->flags;
>
> Â Â Â Â DPRINTF("QCOW: Opening %s\n", name);
>
> diff --git a/tools/blktap2/drivers/block-ram.c b/tools/blktap2/drivers/block-ram.c
> index b64a194..3e148ab 100644
> --- a/tools/blktap2/drivers/block-ram.c
> +++ b/tools/blktap2/drivers/block-ram.c
> @@ -40,6 +40,7 @@
> Â#include "tapdisk.h"
> Â#include "tapdisk-driver.h"
> Â#include "tapdisk-interface.h"
> +#include "tapdisk-image.h"
>
> Âchar *img;
> Âlong int Âdisksector_size;
> @@ -108,13 +109,14 @@ static int get_image_info(int fd, td_disk_info_t *info)
> Â}
>
> Â/* Open the disk file and initialize ram state. */
> -int tdram_open (td_driver_t *driver, const char *name, td_flag_t flags,
> -Â Â Â Â Â Â Â Âtd_uuid_t uuid)
> +int tdram_open (td_driver_t *driver, td_image_t *image, td_uuid_t uuid)
> Â{
> Â Â Â Â char *p;
> Â Â Â Â uint64_t size;
> Â Â Â Â int i, fd, ret = 0, count = 0, o_flags;
> Â Â Â Â struct tdram_state *prv = (struct tdram_state *)driver->data;
> +Â Â Â Âconst char *name = image->name;
> +Â Â Â Âtd_flag_t flags = image->flags;
>
> Â Â Â Â connections++;
>
> diff --git a/tools/blktap2/drivers/block-remus.c b/tools/blktap2/drivers/block-remus.c
> index eb8c0ed..a2c08d8 100644
> --- a/tools/blktap2/drivers/block-remus.c
> +++ b/tools/blktap2/drivers/block-remus.c
> @@ -1152,8 +1152,6 @@ void backup_queue_read(td_driver_t *driver, td_request_t treq)
> Â{
> Â Â Â Â struct tdremus_state *s = (struct tdremus_state *)driver->data;
> Â Â Â Â int i;
> -Â Â Â Âif(!remus_image)
> -Â Â Â Â Â Â Â Âremus_image = treq.image;
>
> Â Â Â Â /* check if this read is queued in any currently ongoing flush */
> Â Â Â Â if (ramdisk_read(&s->ramdisk, treq.sec, treq.secs, treq.buf)) {
> @@ -1632,15 +1630,17 @@ static int ctl_register(struct tdremus_state *s)
>
> Â/* interface */
>
> -static int tdremus_open(td_driver_t *driver, const char *name,
> -Â Â Â Â Â Â Â Â Â Â Â Âtd_flag_t flags, td_uuid_t uuid)
> +static int tdremus_open(td_driver_t *driver, td_image_t *image, td_uuid_t uuid)
> Â{
> Â Â Â Â struct tdremus_state *s = (struct tdremus_state *)driver->data;
> Â Â Â Â int rc;
> +Â Â Â Âconst char *name = image->name;
> +Â Â Â Âtd_flag_t flags = image->flags;
>
> Â Â Â Â RPRINTF("opening %s\n", name);
>
> Â Â Â Â device_vbd = tapdisk_server_get_vbd(uuid);
> +Â Â Â Âremus_image = image;
>
> Â Â Â Â memset(s, 0, sizeof(*s));
> Â Â Â Â s->server_fd.fd = -1;
> diff --git a/tools/blktap2/drivers/block-vhd.c b/tools/blktap2/drivers/block-vhd.c
> index 06e9c89..b20f724 100644
> --- a/tools/blktap2/drivers/block-vhd.c
> +++ b/tools/blktap2/drivers/block-vhd.c
> @@ -59,6 +59,7 @@
> Â#include "tapdisk-driver.h"
> Â#include "tapdisk-interface.h"
> Â#include "tapdisk-disktype.h"
> +#include "tapdisk-image.h"
>
> Âunsigned int SPB;
>
> @@ -675,10 +676,11 @@ __vhd_open(td_driver_t *driver, const char *name, vhd_flag_t flags)
> Â}
>
> Âstatic int
> -_vhd_open(td_driver_t *driver, const char *name, td_flag_t flags,
> -Â Â Â Â Âtd_uuid_t uuid)
> +_vhd_open(td_driver_t *driver, td_image_t *image, td_uuid_t uuid)
> Â{
> Â Â Â Â vhd_flag_t vhd_flags = 0;
> +Â Â Â Âconst char *name = image->name;
> +Â Â Â Âtd_flag_t flags = image->flags;
>
> Â Â Â Â if (flags & TD_OPEN_RDONLY)
> Â Â Â Â Â Â Â Â vhd_flags |= VHD_FLAG_OPEN_RDONLY;
> diff --git a/tools/blktap2/drivers/tapdisk-interface.c b/tools/blktap2/drivers/tapdisk-interface.c
> index 36b5393..a29de64 100644
> --- a/tools/blktap2/drivers/tapdisk-interface.c
> +++ b/tools/blktap2/drivers/tapdisk-interface.c
> @@ -79,8 +79,7 @@ __td_open(td_image_t *image, td_disk_info_t *info)
> Â Â Â Â }
>
> Â Â Â Â if (!td_flag_test(driver->state, TD_DRIVER_OPEN)) {
> -Â Â Â Â Â Â Â Âerr = driver->ops->td_open(driver, image->name, image->flags,
> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â vbd->uuid);
> +Â Â Â Â Â Â Â Âerr = driver->ops->td_open(driver, image, vbd->uuid);
> Â Â Â Â Â Â Â Â if (err) {
> Â Â Â Â Â Â Â Â Â Â Â Â if (!image->driver)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tapdisk_driver_free(driver);
> diff --git a/tools/blktap2/drivers/tapdisk.h b/tools/blktap2/drivers/tapdisk.h
> index 459eaec..3c3b51d 100644
> --- a/tools/blktap2/drivers/tapdisk.h
> +++ b/tools/blktap2/drivers/tapdisk.h
> @@ -157,7 +157,7 @@ struct tap_disk {
>     const char         *disk_type;
>     td_flag_t          flags;
>     int             private_data_size;
> -Â Â Â Âint (*td_open)Â Â Â Â Â Â Â Â(td_driver_t *, const char *, td_flag_t, td_uuid_t);
> +Â Â Â Âint (*td_open)Â Â Â Â Â Â Â Â(td_driver_t *, td_image_t *, td_uuid_t);
> Â Â Â Â int (*td_close)Â Â Â Â Â Â Â (td_driver_t *);
> Â Â Â Â int (*td_get_parent_id)Â Â Â (td_driver_t *, td_disk_id_t *);
> Â Â Â Â int (*td_validate_parent)Â Â (td_driver_t *, td_driver_t *, td_flag_t);
> --
> 1.9.3
>
>
>

Acked-by: Shriram Rajagopalan <rshriram@xxxxxxxxx> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.