dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Subject: Re: [PATCH] dm-delay: Add a message to change delay
Date: Tue, 1 Sep 2015 10:55:19 +0200	[thread overview]
Message-ID: <55E567F7.1050309@redhat.com> (raw)
In-Reply-To: <1441056276-14288-1-git-send-email-agrover@redhat.com>

Dne 31.8.2015 v 23:24 Andy Grover napsal(a):
> This enables runtime modification of the read and write delay values.
>
> Make sure if the delay time is reduced to flush currently-delayed
> bios first, to maintain ordering.
>


Hi


Flush with suspend is an optional feature.

You could  'dmsetup suspend --noflush'  so IMHO there is no need for
message support - you just load new table line
and go through suspend resume (resume should be enough)

Messages are normally used for something unrelated to table line,
for table line args - you should go with standard table line load
(so dmsetup table always shows correct value)

Regards

Zdenek



> Signed-off-by: Andy Grover <agrover@redhat.com>
> ---
>   Documentation/device-mapper/delay.txt |  8 +++++++
>   drivers/md/dm-delay.c                 | 42 +++++++++++++++++++++++++++++++++++
>   2 files changed, 50 insertions(+)
>
> diff --git a/Documentation/device-mapper/delay.txt b/Documentation/device-mapper/delay.txt
> index 15adc55..9e80751 100644
> --- a/Documentation/device-mapper/delay.txt
> +++ b/Documentation/device-mapper/delay.txt
> @@ -10,6 +10,14 @@ Parameters:
>   With separate write parameters, the first set is only used for reads.
>   Delays are specified in milliseconds.
>
> +Message Interface
> +-----------------
> +The delay target will accept a message of the following format:
> +
> +set_delay <read_delay> [<write_delay>]
> +
> +'man dmsetup' for more information on the message interface.
> +
>   Example scripts
>   ===============
>   [[
> diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
> index 57b6a19..04c2ab0 100644
> --- a/drivers/md/dm-delay.c
> +++ b/drivers/md/dm-delay.c
> @@ -290,6 +290,47 @@ static int delay_map(struct dm_target *ti, struct bio *bio)
>   	return delay_bio(dc, dc->read_delay, bio);
>   }
>
> +/* Message interface
> + *	set_delay <read_delay> [<write_delay>]
> +*/
> +static int delay_message(struct dm_target *ti, unsigned argc, char **argv)
> +{
> +	struct delay_c *dc = ti->private;
> +	unsigned read_delay = dc->read_delay;
> +	unsigned write_delay = dc->write_delay;
> +	char dummy;
> +
> +	if (argc < 2 || argc > 3)
> +		goto error;
> +
> +	if (strcasecmp(argv[0], "set_delay"))
> +		goto error;
> +
> +	if (sscanf(argv[1], "%u%c", &read_delay, &dummy) != 1) {
> +		ti->error = "Invalid read delay";
> +		goto error;
> +	}
> +
> +	if (argc == 3) {
> +		if (sscanf(argv[2], "%u%c", &write_delay, &dummy) != 1) {
> +			ti->error = "Invalid write delay";
> +			goto error;
> +		}
> +	}
> +
> +	if (read_delay < dc->read_delay
> +	    || write_delay < dc->write_delay)
> +		flush_bios(flush_delayed_bios(dc, 1));
> +
> +	dc->read_delay = read_delay;
> +	dc->write_delay = write_delay;
> +	return 0;
> +
> +error:
> +	DMWARN("unrecognised message received.");
> +	return -EINVAL;
> +}
> +
>   static void delay_status(struct dm_target *ti, status_type_t type,
>   			 unsigned status_flags, char *result, unsigned maxlen)
>   {
> @@ -339,6 +380,7 @@ static struct target_type delay_target = {
>   	.map	     = delay_map,
>   	.presuspend  = delay_presuspend,
>   	.resume	     = delay_resume,
> +	.message     = delay_message,
>   	.status	     = delay_status,
>   	.iterate_devices = delay_iterate_devices,
>   };
>

      parent reply	other threads:[~2015-09-01  8:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31 21:24 [PATCH] dm-delay: Add a message to change delay Andy Grover
2015-09-01  2:05 ` Vivek Goyal
2015-09-01  5:02   ` Andy Grover
2015-09-01 12:14     ` Vivek Goyal
2015-09-01 13:09       ` Mike Snitzer
2015-09-01 14:17         ` Andy Grover
2015-09-01  8:55 ` Zdenek Kabelac [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55E567F7.1050309@redhat.com \
    --to=zkabelac@redhat.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).