Re: [PATCH 2/3] SMC: Add an update argument "clear_slot" to force a storage element slot to become empty.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 28 Jan 2012 14:28:43 +1100
Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> wrote:

> This new argument can be used for force an exiting storage element slot to become empty.
> 
> Example:
> tgtadm --mode logicalunit --op update --tid 1 --lun 1 \
>  --params element_type=2,address=1025,clear_slot=1
> 
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
> ---
>  doc/tgtadm.8.xml |   10 ++++++++++
>  usr/smc.c        |    9 +++++++++
>  usr/smc.h        |    4 +++-
>  3 files changed, 22 insertions(+), 1 deletions(-)
> 
> diff --git a/doc/tgtadm.8.xml b/doc/tgtadm.8.xml
> index a2dd394..f0710ac 100644
> --- a/doc/tgtadm.8.xml
> +++ b/doc/tgtadm.8.xml
> @@ -407,6 +407,16 @@ Slot types:
>          </listitem>
>        </varlistentry>
>  
> +      <varlistentry><term><option>clear_slot=&lt;1&gt;</option></term>
> +        <listitem>
> +          <para>
> +	    This option is used to clear a storage element and remove any
> +	    media that may be present. Once this command completes
> +	    the storage element will show up as "Empty".
> +          </para>
> +        </listitem>
> +      </varlistentry>
> +
>        <varlistentry><term><option>barcode=&lt;string&gt;</option></term>
>          <listitem>
>            <para>
> diff --git a/usr/smc.c b/usr/smc.c
> index c0f25d6..3e77f2a 100644
> --- a/usr/smc.c
> +++ b/usr/smc.c
> @@ -672,6 +672,11 @@ static int config_slot(struct scsi_lu *lu, struct tmp_param *tmp)
>  		s = slot_lookup(&smc->slots, tmp->element_type, tmp->address);
>  		if (!s)
>  			break;	// Slot not found..
> +		if (tmp->clear_slot) {
> +			set_slot_empty(s);

What happens if we call set_slot_empty for a lu that has pending I/Os?


> +			ret = TGTADM_SUCCESS;
> +			break;
> +		}
>  		strncpy(s->barcode, tmp->barcode, sizeof(s->barcode));
>  		set_slot_full(s, 0, NULL);
>  		ret = TGTADM_SUCCESS;
> @@ -725,6 +730,10 @@ static int __smc_lu_config(struct scsi_lu *lu, char *params)
>  			match_strncpy(buf, &args[0], sizeof(buf));
>  			sv_param.sides = atoi(buf);
>  			break;
> +		case Opt_clear_slot:
> +			match_strncpy(buf, &args[0], sizeof(buf));
> +			sv_param.clear_slot = atoi(buf);
> +			break;
>  		case Opt_address:
>  			match_strncpy(buf, &args[0], sizeof(buf));
>  			sv_param.address = atoi(buf);
> diff --git a/usr/smc.h b/usr/smc.h
> index 0d216cd..eb50f45 100644
> --- a/usr/smc.h
> +++ b/usr/smc.h
> @@ -75,7 +75,7 @@ struct smc_info {
>  
>  enum {
>  	Opt_element_type, Opt_start_address,
> -	Opt_quantity, Opt_sides,
> +	Opt_quantity, Opt_sides, Opt_clear_slot,
>  	Opt_address, Opt_barcode,
>  	Opt_tid, Opt_lun,
>  	Opt_type, Opt_dump,
> @@ -88,6 +88,7 @@ static match_table_t tokens = {
>  	{Opt_start_address, "start_address=%s"},
>  	{Opt_quantity, "quantity=%s"},
>  	{Opt_sides, "sides=%s"},
> +	{Opt_clear_slot, "clear_slot=%s"},
>  	{Opt_address, "address=%s"},
>  	{Opt_barcode, "barcode=%s"},
>  	{Opt_tid, "tid=%s"},
> @@ -116,6 +117,7 @@ struct tmp_param {
>  	uint64_t lun;
>  	char barcode[20];
>  	int sides;
> +	int clear_slot;
>  } sv_param;
>  
>  #endif // _SMC_H_
> -- 
> 1.7.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stgt" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux