dm-delay: Add a message to change delay
Subsystems (2)
PATCH 1/1 dm-delay: Add a message to change delay
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.
--- Documentation/device-mapper/delay.txt | 8 +++++++ drivers/md/dm-delay.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)
Documentation/device-mapper/delay.txt +8 -0
@@ -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 =============== [[
drivers/md/dm-delay.c +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.4.3
Quoted 16 lines · Andy Grover
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.
Signed-off-by Andy Grover <[email protected]>--- Documentation/device-mapper/delay.txt | 8 +++++++ drivers/md/dm-delay.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)Documentation/device-mapper/delay.txt +0
-0
Documentation/device-mapper/delay.txt Parameters: · line 18
Quoted 9 lines
Documentation/device-mapper/delay.txt +6
-0@@ -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>] +
Hi Andy,
So if I want to change only write_delay and keep read_delay same, how do I do that. Do I have to keep track of existing delay values in user space and pass same value in read_delay to achieve this.
Thanks
Vivek
Quoted 72 lines
Documentation/device-mapper/delay.txt +2
-0+'man dmsetup' for more information on the message interface. + Example scripts =============== [[drivers/md/dm-delay.c +42
-0@@ -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, };Signature · 6 lines
2.4.3 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 29 lines · Vivek Goyal
Quoted 16 lines · Andy Grover
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.
Signed-off-by Andy Grover <[email protected]>--- Documentation/device-mapper/delay.txt | 8 +++++++ drivers/md/dm-delay.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)Documentation/device-mapper/delay.txt +0
-0Documentation/device-mapper/delay.txt Parameters: · line 18
Quoted 9 lines
Documentation/device-mapper/delay.txt +6
-0@@ -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>] +Hi Andy,
Quoted 6 lines
So if I want to change only
write_delayand keepread_delaysame, how do I do that. Do I have to keep track of existing delay values in user space and pass same value inread_delayto achieve this.Thanks
Vivek
Hi Vivek,
Yes I suppose userspace would either need to remember read_delay so as to not change it while setting write_delay, or I guess it could read the existing values by getting table status before sending the message. Is this reasonable, or do you think it would be better to, say, have separate messages for setting the two values, or some other message style?
Thanks -- Regards -- Andy
Quoted 37 lines · Andy Grover
Quoted 29 lines · Vivek Goyal
Quoted 16 lines · Andy Grover
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.
Signed-off-by Andy Grover <[email protected]>--- Documentation/device-mapper/delay.txt | 8 +++++++ drivers/md/dm-delay.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)Documentation/device-mapper/delay.txt +0
-0Documentation/device-mapper/delay.txt Parameters: · line 18
Quoted 9 lines
Documentation/device-mapper/delay.txt +6
-0@@ -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>] +Hi Andy,
Quoted 6 lines
So if I want to change only
write_delayand keepread_delaysame, how do I do that. Do I have to keep track of existing delay values in user space and pass same value inread_delayto achieve this.Thanks
Vivek
Quoted 7 lines
Hi Vivek,
Yes I suppose userspace would either need to remember
read_delayso as to not change it while settingwrite_delay, or I guess it could read the existing values by getting table status before sending the message. Is this reasonable, or do you think it would be better to, say, have separate messages for setting the two values, or some other message style?
Ideally I think we should have those --key=value type of arguments which we don't have yet. So that option is not feasible I guess.
If latest values are readable from status, then I think single message sounds reasoanble to me.
Thanks
Vivek
Quoted 2 lines
Thanks -- Regards -- Andy
Quoted 46 lines · Vivek Goyal
Quoted 37 lines · Andy Grover
Quoted 29 lines · Vivek Goyal
Quoted 16 lines · Andy Grover
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.
Signed-off-by Andy Grover <[email protected]>--- Documentation/device-mapper/delay.txt | 8 +++++++ drivers/md/dm-delay.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)Documentation/device-mapper/delay.txt +0
-0Documentation/device-mapper/delay.txt Parameters: · line 18
Quoted 9 lines
Documentation/device-mapper/delay.txt +6
-0@@ -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>] +Hi Andy,
Quoted 6 lines
So if I want to change only
write_delayand keepread_delaysame, how do I do that. Do I have to keep track of existing delay values in user space and pass same value inread_delayto achieve this.Thanks
VivekQuoted 7 lines
Hi Vivek,
Yes I suppose userspace would either need to remember
read_delayso as to not change it while settingwrite_delay, or I guess it could read the existing values by getting table status before sending the message. Is this reasonable, or do you think it would be better to, say, have separate messages for setting the two values, or some other message style?
Quoted 5 lines
Ideally I think we should have those --key=value type of arguments which we don't have yet. So that option is not feasible I guess.
If latest values are readable from status, then I think single message sounds reasoanble to me.
As Zdenek already effectively said: there is no need for this patch. You don't need to use a message when a table reload would suffice to change the parameter that is already passed on the table ctr.
Any layer that would be trained to send a message can just as easily be trained to reload the table to achieve the same result.
Quoted 55 lines · Mike Snitzer
Quoted 46 lines · Vivek Goyal
Quoted 37 lines · Andy Grover
Quoted 29 lines · Vivek Goyal
Quoted 16 lines · Andy Grover
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.
Signed-off-by Andy Grover <[email protected]>--- Documentation/device-mapper/delay.txt | 8 +++++++ drivers/md/dm-delay.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)Documentation/device-mapper/delay.txt +0
-0Documentation/device-mapper/delay.txt Parameters: · line 18
Quoted 9 lines
Documentation/device-mapper/delay.txt +6
-0@@ -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>] +Hi Andy,
Quoted 6 lines
So if I want to change only
write_delayand keepread_delaysame, how do I do that. Do I have to keep track of existing delay values in user space and pass same value inread_delayto achieve this.Thanks
VivekQuoted 7 lines
Hi Vivek,
Yes I suppose userspace would either need to remember
read_delayso as to not change it while settingwrite_delay, or I guess it could read the existing values by getting table status before sending the message. Is this reasonable, or do you think it would be better to, say, have separate messages for setting the two values, or some other message style?Quoted 5 lines
Ideally I think we should have those --key=value type of arguments which we don't have yet. So that option is not feasible I guess.
If latest values are readable from status, then I think single message sounds reasoanble to me.
Quoted 6 lines
As Zdenek already effectively said: there is no need for this patch. You don't need to use a message when a table reload would suffice to change the parameter that is already passed on the table ctr.
Any layer that would be trained to send a message can just as easily be trained to reload the table to achieve the same result.
Ah I see. Thanks for the explanations. Noflush suspend & table reload is better for this.
Regards -- Andy
Dne 31.8.2015 v 23:24 Andy Grover napsal(a):
Quoted 5 lines
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
Quoted 86 lines
Signed-off-by Andy Grover <[email protected]>--- Documentation/device-mapper/delay.txt | 8 +++++++ drivers/md/dm-delay.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)Documentation/device-mapper/delay.txt +8
-0@@ -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 =============== [[drivers/md/dm-delay.c +42
-0@@ -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, };