[stgt] [PATCH] release backing store when offline

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Tue Jul 19 00:43:30 CEST 2011


As I wrote, I don't think that this is correct. So I don't plan to
merge the patch but I review it anyway.

On Wed, 13 Jul 2011 11:12:26 -0500
"James R. Leu" <jleu at inoc.com> wrote:

> diff -uNr tgt-1.0.18/usr/spc.c tgt-1.0.18-inoc/usr/spc.c
> --- tgt-1.0.18/usr/spc.c	2011-06-29 17:54:02.000000000 -0500
> +++ tgt-1.0.18-inoc/usr/spc.c	2011-07-13 10:09:23.341135538 -0500
> @@ -1687,10 +1687,20 @@
>  			break;
>  		case Opt_online:
>  			match_strncpy(buf, &args[0], sizeof(buf));
> -			if (atoi(buf))
> -				lu->dev_type_template.lu_online(lu);
> -			else
> +			switch (atoi(buf)) {
> +			    case 1:
> +				err = lu->bst->bs_open(lu, lu->path, &lu->fd, &lu->size);
> +				if (!err) {
> +				    lu->dev_type_template.lu_online(lu);
> +				}
> +				break;
> +			    case 0:
> +				lu->bst->bs_close(lu);
>  				lu->dev_type_template.lu_offline(lu);
> +				break;
> +			    default:
> +				break;
> +			}
>  			break;
>  		case Opt_mode_page:
>  			match_strncpy(buf, &args[0], sizeof(buf));
> diff -uNr tgt-1.0.18/usr/target.c tgt-1.0.18-inoc/usr/target.c
> --- tgt-1.0.18/usr/target.c	2011-06-29 17:54:02.000000000 -0500
> +++ tgt-1.0.18-inoc/usr/target.c	2011-07-13 09:39:50.955594499 -0500
> @@ -1740,12 +1740,15 @@
>  int tgt_set_target_state(int tid, char *str)
>  {
>  	int i, err = TGTADM_INVALID_REQUEST;
> +	struct scsi_lu *lu;
>  	struct target *target;
> +	int prev = 0;
>  
>  	target = target_lookup(tid);
>  	if (!target)
>  		return TGTADM_NO_TARGET;
>  
> +	prev = target->target_state;
>  	for (i = 0; i < ARRAY_SIZE(target_state); i++) {
>  		if (!strcmp(target_state[i].name, str)) {
>  			target->target_state = target_state[i].value;
> @@ -1754,6 +1757,22 @@
>  		}
>  	}
>  
> +	if (err == 0 && prev != target->target_state) {
> +	    list_for_each_entry(lu, &target->device_list, device_siblings) {
> +		if (target->target_state == SCSI_TARGET_OFFLINE) {
> +		    lu->bst->bs_close(lu);
> +		    lu->dev_type_template.lu_offline(lu);

Hmm, if an user set the target offline and the target has an offline
lun, this executes the offline operations against the offline lun?


> +		} else {
> +		    err = lu->bst->bs_open(lu, lu->path, &lu->fd, &lu->size);
> +		    if (err) {
> +			target->target_state = prev;
> +		    } else {
> +			lu->dev_type_template.lu_online(lu);

Ditto, this could execute the online operations against the online lun.
--
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