On Wed, 2014-05-14 at 15:48 -0700, Andy Grover wrote:
> Just like for pSCSI, if the transport sets get_write_cache, then it is
> not valid to enable write cache emulation for it. Return an error.
> 
> see https://bugzilla.redhat.com/show_bug.cgi?id=1082675
> 
> Reviewed-by: Chris Leech <cle...@redhat.com>
> Signed-off-by: Andy Grover <agro...@redhat.com>
> ---
>  drivers/target/target_core_device.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/target/target_core_device.c 
> b/drivers/target/target_core_device.c
> index 65001e1..d461ecb 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -798,10 +798,10 @@ int se_dev_set_emulate_write_cache(struct se_device 
> *dev, int flag)
>               pr_err("emulate_write_cache not supported for pSCSI\n");
>               return -EINVAL;
>       }
> -     if (dev->transport->get_write_cache) {
> -             pr_warn("emulate_write_cache cannot be changed when underlying"
> -                     " HW reports WriteCacheEnabled, ignoring request\n");
> -             return 0;
> +     if (flag &&
> +         dev->transport->get_write_cache) {
> +             pr_err("emulate_write_cache not supported for this device\n");
> +             return -EINVAL;
>       }
>  
>       dev->dev_attrib.emulate_write_cache = flag;

Allowing the target WCE bit to be disabled when the underlying device
has WCE enabled is a recipe for disaster.

How is the initiator supposed to know when to flush writes if the target
is telling it that WCE is disabled.

I'll take change to return -EINVAL here, but the other part is dangerous
and wrong.

--nab







--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to