diff mbox series

[v2] scsi: target: alua: do not report emtpy port group

Message ID 20220912125457.22573-1-d.bogdanov@yadro.com (mailing list archive)
State Superseded
Headers show
Series [v2] scsi: target: alua: do not report emtpy port group | expand

Commit Message

Dmitry Bogdanov Sept. 12, 2022, 12:54 p.m. UTC
Default target port group is always returned in the list of port
groups, even if the behaviour is unwanted, i.e. it has no members and
non-default port groups are primary port groups.

SPC-4 ("5.15.2.7 Target port asymmetric access state reporting")
states that a target MAY not provide info about port groups that do not
contain the current port through that the RTPG is received.

This patch hides port groups with no ports in REPORT TARGET PORT GROUPS
response.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
v2:
  new solution - just skip all empty groups
---
 drivers/target/target_core_alua.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mike Christie Sept. 12, 2022, 5:49 p.m. UTC | #1
On 9/12/22 7:54 AM, Dmitry Bogdanov wrote:
> Default target port group is always returned in the list of port
> groups, even if the behaviour is unwanted, i.e. it has no members and
> non-default port groups are primary port groups.
> 
> SPC-4 ("5.15.2.7 Target port asymmetric access state reporting")
> states that a target MAY not provide info about port groups that do not
> contain the current port through that the RTPG is received.
> 

Where is that? I see where it says the state value for a group might not
be up to date when the RTPG is sent through a different port. Are you
taking that to mean we don't have to report entire groups?

Note that I also don't see where it says we have to return every group.

Remember how ESX used to send a RTPG to one port and expect that it got
every group and that the state info was all in sync (basically opposite
if what's in the spec now)?

The spec and ESX were updated, but I don't know if other OSs did this and
if/when everyone was updated. Do you know this info? Are the old ESX versions
that worked like that end of life?


> This patch hides port groups with no ports in REPORT TARGET PORT GROUPS
> response.
> 
> Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
> ---
> v2:
>   new solution - just skip all empty groups
> ---
>  drivers/target/target_core_alua.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
> index fb91423a4e2e..c8470e7c0e10 100644
> --- a/drivers/target/target_core_alua.c
> +++ b/drivers/target/target_core_alua.c
> @@ -164,6 +164,9 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd)
>  	spin_lock(&dev->t10_alua.tg_pt_gps_lock);
>  	list_for_each_entry(tg_pt_gp, &dev->t10_alua.tg_pt_gps_list,
>  			tg_pt_gp_list) {
> +		/* Skip empty port groups */
> +		if (!tg_pt_gp->tg_pt_gp_members)
> +			continue;
>  		/*
>  		 * Check if the Target port group and Target port descriptor list
>  		 * based on tg_pt_gp_members count will fit into the response payload.
Dmitry Bogdanov Sept. 12, 2022, 9:45 p.m. UTC | #2
On Mon, Sep 12, 2022 at 12:49:22PM -0500, Mike Christie wrote:
> 
> On 9/12/22 7:54 AM, Dmitry Bogdanov wrote:
> > Default target port group is always returned in the list of port
> > groups, even if the behaviour is unwanted, i.e. it has no members and
> > non-default port groups are primary port groups.
> >
> > SPC-4 ("5.15.2.7 Target port asymmetric access state reporting")
> > states that a target MAY not provide info about port groups that do not
> > contain the current port through that the RTPG is received.
> >
> 
> Where is that? I see where it says the state value for a group might not
> be up to date when the RTPG is sent through a different port. Are you
> taking that to mean we don't have to report entire groups?

Yes, you are right, I mixed something up here. Actually, a target
do not MAY not send, it SHALL not send an empty port group:

SPC-4 "6.37 REPORT TARGET PORT GROUPS command":
 The TARGET PORT COUNT field indicates the number of target ports that
are in that target port group and the number of target port descriptors
in the target port group descriptor. Every target port group shall
contain at least one target port. The target port group descriptor
shall include one target port descriptor for each target port in the
target port group.

> 
> Note that I also don't see where it says we have to return every group.
> 
> Remember how ESX used to send a RTPG to one port and expect that it got
> every group and that the state info was all in sync (basically opposite
> if what's in the spec now)?
> 
> The spec and ESX were updated, but I don't know if other OSs did this and
> if/when everyone was updated. Do you know this info? Are the old ESX versions
> that worked like that end of life?

ESXi is kinda a pain. But fortunately it has nothing to do with that
patch :)
> 
> > This patch hides port groups with no ports in REPORT TARGET PORT GROUPS
> > response.
> >
> > Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
> > ---
> > v2:
> >   new solution - just skip all empty groups
> > ---
> >  drivers/target/target_core_alua.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
> > index fb91423a4e2e..c8470e7c0e10 100644
> > --- a/drivers/target/target_core_alua.c
> > +++ b/drivers/target/target_core_alua.c
> > @@ -164,6 +164,9 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd)
> >       spin_lock(&dev->t10_alua.tg_pt_gps_lock);
> >       list_for_each_entry(tg_pt_gp, &dev->t10_alua.tg_pt_gps_list,
> >                       tg_pt_gp_list) {
> > +             /* Skip empty port groups */
> > +             if (!tg_pt_gp->tg_pt_gp_members)
> > +                     continue;
> >               /*
> >                * Check if the Target port group and Target port descriptor list
> >                * based on tg_pt_gp_members count will fit into the response payload.
>
Mike Christie Sept. 14, 2022, 7:18 p.m. UTC | #3
On 9/12/22 4:45 PM, Dmitry Bogdanov wrote:
>> Remember how ESX used to send a RTPG to one port and expect that it got
>> every group and that the state info was all in sync (basically opposite
>> if what's in the spec now)?
>>
>> The spec and ESX were updated, but I don't know if other OSs did this and
>> if/when everyone was updated. Do you know this info? Are the old ESX versions
>> that worked like that end of life?
> ESXi is kinda a pain. But fortunately it has nothing to do with that
> patch 
Dmitry Bogdanov Sept. 15, 2022, 6:08 a.m. UTC | #4
On Wed, Sep 14, 2022 at 02:18:40PM -0500, Mike Christie wrote:
> 
> On 9/12/22 4:45 PM, Dmitry Bogdanov wrote:
> >> Remember how ESX used to send a RTPG to one port and expect that it got
> >> every group and that the state info was all in sync (basically opposite
> >> if what's in the spec now)?
> >>
> >> The spec and ESX were updated, but I don't know if other OSs did this and
> >> if/when everyone was updated. Do you know this info? Are the old ESX versions
> >> that worked like that end of life?
> > ESXi is kinda a pain. But fortunately it has nothing to do with that
> > patch 
Mike Christie Sept. 22, 2022, 4:26 p.m. UTC | #5
On 9/15/22 1:08 AM, Dmitry Bogdanov wrote:
> On Wed, Sep 14, 2022 at 02:18:40PM -0500, Mike Christie wrote:
>>
>> On 9/12/22 4:45 PM, Dmitry Bogdanov wrote:
>>>> Remember how ESX used to send a RTPG to one port and expect that it got
>>>> every group and that the state info was all in sync (basically opposite
>>>> if what's in the spec now)?
>>>>
>>>> The spec and ESX were updated, but I don't know if other OSs did this and
>>>> if/when everyone was updated. Do you know this info? Are the old ESX versions
>>>> that worked like that end of life?
>>> ESXi is kinda a pain. But fortunately it has nothing to do with that
>>> patch 
Dmitry Bogdanov Sept. 23, 2022, 11:38 a.m. UTC | #6
On Thu, Sep 22, 2022 at 11:26:29AM -0500, michael.christie@oracle.com wrote:
> 
> On 9/15/22 1:08 AM, Dmitry Bogdanov wrote:
> > On Wed, Sep 14, 2022 at 02:18:40PM -0500, Mike Christie wrote:
> >>
> >> On 9/12/22 4:45 PM, Dmitry Bogdanov wrote:
> >>>> Remember how ESX used to send a RTPG to one port and expect that it got
> >>>> every group and that the state info was all in sync (basically opposite
> >>>> if what's in the spec now)?
> >>>>
> >>>> The spec and ESX were updated, but I don't know if other OSs did this and
> >>>> if/when everyone was updated. Do you know this info? Are the old ESX versions
> >>>> that worked like that end of life?
> >>> ESXi is kinda a pain. But fortunately it has nothing to do with that
> >>> patch 
diff mbox series

Patch

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index fb91423a4e2e..c8470e7c0e10 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -164,6 +164,9 @@  target_emulate_report_target_port_groups(struct se_cmd *cmd)
 	spin_lock(&dev->t10_alua.tg_pt_gps_lock);
 	list_for_each_entry(tg_pt_gp, &dev->t10_alua.tg_pt_gps_list,
 			tg_pt_gp_list) {
+		/* Skip empty port groups */
+		if (!tg_pt_gp->tg_pt_gp_members)
+			continue;
 		/*
 		 * Check if the Target port group and Target port descriptor list
 		 * based on tg_pt_gp_members count will fit into the response payload.