[stgt] [PATCH] fix display of TYPE_PT device type

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Sat Jul 31 02:04:41 CEST 2010


On Fri, 30 Jul 2010 18:28:33 +0300
Alexander Nezhinsky <alexandern at Voltaire.COM> wrote:

> New device type TYPE_PT (passthrough) was not added to disk_type_names
> array. Thus "Type:" in --op show was (null).
> 
> This patch adds the new device type, displays Unknown instead of (null)
> when printing device types.
> 
> Adding TYPE_PT to disk_type_names alone does not help detecting it
> there, because the type of device_type field in struct lu_phy_attr
> (accessed as lu->attrs.device_type when printing) is char,
> while the value of TYPE_PT is 0xff. Comparison fails as 0xff is
> interpreted as -1. Thus this patch changes the type of device_type
> field to unsigned char.
> 
> Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
> ---
>  usr/target.c |    5 ++++-
>  usr/tgtd.h   |    2 +-
>  2 files changed, 5 insertions(+), 2 deletions(-)

Thanks, applied with one change.

> diff --git a/usr/target.c b/usr/target.c
> index bb5b0c8..53a27f5 100644
> --- a/usr/target.c
> +++ b/usr/target.c
> @@ -1663,7 +1663,8 @@ static struct {
>  	{TYPE_ENCLOSURE, "enclosure"},
>  	{TYPE_RBC, "rbc"},
>  	{TYPE_OSD, "osd"},
> -	{TYPE_NO_LUN, "No LUN"}
> +	{TYPE_NO_LUN, "No LUN"},
> +	{TYPE_PT, "passthrough"}
>  };
>  
>  static char *print_type(int type)
> @@ -1677,6 +1678,8 @@ static char *print_type(int type)
>  			break;
>  		}
>  	}
> +	if (name == NULL)
> +		name = "Unknown";
>  	return name;

I dropped this part:

1. changing "null" to "Unknown" doesn't help much. If print_type can't
find an appropriate type, it's a bug.

2. linux's preferable style is "if (!name)"
--
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