* [PATCH v2 1/2] scsi: target: fix unmap_zeroes_data boolean initialisation
@ 2020-02-19 13:01 David Disseldorp
2020-02-19 17:32 ` Bart Van Assche
0 siblings, 1 reply; 2+ messages in thread
From: David Disseldorp @ 2020-02-19 13:01 UTC (permalink / raw)
To: target-devel
The LIO unmap_zeroes_data device attribute is mapped to the LBPRZ flag
in the READ CAPACITY (16) and Thin Provisioning VPD INQUIRY responses.
The unmap_zeroes_data attribute is exposed via configfs, where any write
value is correctly validated via strtobool(). However, when initialised
via target_configure_unmap_from_queue() it takes the value of the
device's max_write_zeroes_sectors queue limit, which is non-boolean.
A non-boolean value can be read from configfs, but attempting to write
the same value back results in -EINVAL, causing problems for configuration
utilities such as targetcli.
Fixes: 2237498f0b5c ("target/iblock: Convert WRITE_SAME to blkdev_issue_zeroout")
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
drivers/target/target_core_device.c | 2 +-
include/target/target_core_base.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 2d19f0e332b0..2c7ba2f7e13c 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -829,7 +829,7 @@ bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
attrib->unmap_granularity = q->limits.discard_granularity / block_size;
attrib->unmap_granularity_alignment = q->limits.discard_alignment /
block_size;
- attrib->unmap_zeroes_data = (q->limits.max_write_zeroes_sectors);
+ attrib->unmap_zeroes_data = !!(q->limits.max_write_zeroes_sectors);
return true;
}
EXPORT_SYMBOL(target_configure_unmap_from_queue);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 1728e883b7b2..35188e64239e 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -682,7 +682,7 @@ struct se_dev_attrib {
int force_pr_aptpl;
int is_nonrot;
int emulate_rest_reord;
- int unmap_zeroes_data;
+ bool unmap_zeroes_data;
u32 hw_block_size;
u32 block_size;
u32 hw_max_sectors;
--
2.16.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/2] scsi: target: fix unmap_zeroes_data boolean initialisation
2020-02-19 13:01 [PATCH v2 1/2] scsi: target: fix unmap_zeroes_data boolean initialisation David Disseldorp
@ 2020-02-19 17:32 ` Bart Van Assche
0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2020-02-19 17:32 UTC (permalink / raw)
To: target-devel
On 2/19/20 5:01 AM, David Disseldorp wrote:
> The LIO unmap_zeroes_data device attribute is mapped to the LBPRZ flag
> in the READ CAPACITY (16) and Thin Provisioning VPD INQUIRY responses.
>
> The unmap_zeroes_data attribute is exposed via configfs, where any write
> value is correctly validated via strtobool(). However, when initialised
> via target_configure_unmap_from_queue() it takes the value of the
> device's max_write_zeroes_sectors queue limit, which is non-boolean.
>
> A non-boolean value can be read from configfs, but attempting to write
> the same value back results in -EINVAL, causing problems for configuration
> utilities such as targetcli.
>
> Fixes: 2237498f0b5c ("target/iblock: Convert WRITE_SAME to blkdev_issue_zeroout")
> Signed-off-by: David Disseldorp <ddiss@suse.de>
> ---
> drivers/target/target_core_device.c | 2 +-
> include/target/target_core_base.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
> index 2d19f0e332b0..2c7ba2f7e13c 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -829,7 +829,7 @@ bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
> attrib->unmap_granularity = q->limits.discard_granularity / block_size;
> attrib->unmap_granularity_alignment = q->limits.discard_alignment /
> block_size;
> - attrib->unmap_zeroes_data = (q->limits.max_write_zeroes_sectors);
> + attrib->unmap_zeroes_data = !!(q->limits.max_write_zeroes_sectors);
> return true;
> }
> EXPORT_SYMBOL(target_configure_unmap_from_queue);
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index 1728e883b7b2..35188e64239e 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -682,7 +682,7 @@ struct se_dev_attrib {
> int force_pr_aptpl;
> int is_nonrot;
> int emulate_rest_reord;
> - int unmap_zeroes_data;
> + bool unmap_zeroes_data;
> u32 hw_block_size;
> u32 block_size;
> u32 hw_max_sectors;
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-19 17:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 13:01 [PATCH v2 1/2] scsi: target: fix unmap_zeroes_data boolean initialisation David Disseldorp
2020-02-19 17:32 ` Bart Van Assche
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.