[stgt] [PATCH 1/1] Readonly disk LUNs

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Tue Mar 9 06:13:26 CET 2010


On Tue, 9 Mar 2010 15:32:48 +1100
ronnie sahlberg <ronniesahlberg at gmail.com> wrote:

> For DISK devices, this is communicated back to the initiator by setting the WP bit in teh device specific byte in the mode sense header.
> It will also fail any WRITE6/10/12/16 calls with a DATA_PROTECT/ASC_WRITE_PROTECT
> 
> The manpage for tgtadm has been expanded with a PARAMETERS section and the readonly parameter is added as the first parameter for this section.
> 
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
> ---
>  doc/htmlpages/tgtadm.8.html |   33 +++++++++++++++++++++++++++------
>  doc/manpages/tgtadm.8       |   35 +++++++++++++++++++++++++++++++----
>  doc/tgtadm.8.xml            |   43 +++++++++++++++++++++++++++++++++++++++++--
>  usr/sbc.c                   |    9 +++++++++
>  usr/spc.c                   |   18 +++++++++++++++++-
>  usr/tgtd.h                  |    1 +
>  6 files changed, 126 insertions(+), 13 deletions(-)

(snip)

> diff --git a/usr/spc.c b/usr/spc.c
> index 14a3ee1..25ff849 100644
> --- a/usr/spc.c
> +++ b/usr/spc.c
> @@ -567,8 +567,18 @@ int spc_mode_sense(int host_no, struct scsi_cmd *cmd)
>  
>  	if (mode6) {
>  		data[0] = len - 1;
> +
> +		/* device specific parameters */
> +		if (cmd->dev->attrs.readonly)
> +			if (cmd->dev->attrs.device_type == TYPE_DISK)
> +				data[2] |= 0x80;

I'm very reluctant to have

if (cmd->dev->attrs.device_type == TYPE_something)

in spc.c. tgt is designed not to do such with struct
device_type_operations. I guess that sbc_mode_sense would be not a
good idea too since it would be similar to spc_mode_sense.

But my real question is, for what setting a sbc device to read-only is?
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list