Skip to contentSkip to conversation

multipath-tools: improve processing efficiency for addition and deletion of multipath devices

PATCH In review [email protected] 3 participants 33 messages Dec 27, 2016 – Jan 9, 2017 Device mapper

lore
Share & tools
lore
#0 lore raw

cover multipath-tools: improve processing efficiency for addition and deletion of multipath devices

From: tang.junhui <[email protected]>

Hello Christophe, Ben, Hannes, Martin, Bart, and other guys:

The twelve patches in this series are used to improve processing efficiency for addition and deletion of multipath devices.

These patches are tested pass by ZTE multipath automatic testing syetem. The modification reduces the system consumption(such as CPU) and shortens the processing time obviously in scene of massive multipath devices addition or deletion.

The main processing flow of code is:
1)uevents accumulation in uevents burst scene:
--[pacth]libmultipath: wait one seconds for more uevents in
uevent_listen() in uevents burst situations
2)uevents filtering and merging:
--[pacth]multipathd: merge uevents before proccessing --[pacth]libmultipath: filter uevents before proccessing
3)uevents proccessing:
--[pacth]multipathd: add need_do_map to indicate whether need calling
domap() in ev_add_path()
--[pacth]multipathd: add need_do_map to indicate whether need calling
domap() in ev_remove_path()
--[pacth]multipathd: proccess merged uevents

There are some patches providing basic struct members or maros which would used in above pathes:
--[patch]libmultipath: add wwid for "struct uevent" to record wwid of
uevent
--[patch]libmultipath: add merge_node for "struct uevent" to record
nodes of merged uevents
--[patch]libmultipath: add two list iteration macros

There are also some independent optimization pathes for further improvement:
--[patch]multipathd: move uev_discard() to uevent.c and change its name
to uevent_can_discard()
--[patch]multipathd: move calling filter_devnode() from uev_trigger() to
uevent_can_discard()
--[patch]libmultipath: use existing wwid when wwid has already been
existed in uevent

Any comment will be welcome, and it would be appreciated if these patches would be considered for inclusion in the upstream multipath-tools.

Thank you all,
Tang Junhui

#1 lore raw

PATCH 1/12 libmultipath: add wwid for "struct uevent" to record wwid of uevent

From: tang.junhui <[email protected]>

Add "char *wwid" to point WWID of uevent. This member identifies the LUN ID which the path belongs to, and it is used for merging uevents. WWID possibly did not exist in uevent yet, so ->wwid would be NULL, those uevents would not be merged, but be proccessed as old way.

Change-Id Ie6b076363b3735dc7de10184b27fa799b499af0e
---
 libmultipath/uevent.c | 2 ++
 libmultipath/uevent.h | 1 +
 2 files changed, 3 insertions(+)
libmultipath/uevent.c +2 -0
index 7edcce1..ef1bafe 100644
@@ -424,6 +424,8 @@ struct uevent *uevent_from_udev_device(struct udev_device *dev)
 			uev->devpath = uev->envp[i] + 8;
 		if (strcmp(name, "ACTION") == 0)
 			uev->action = uev->envp[i] + 7;
+		if (strcmp(name, "ID_SERIAL") == 0)
+			uev->wwid = uev->envp[i] + 10;
 		i++;
 		if (i == HOTPLUG_NUM_ENVP - 1)
 			break;
libmultipath/uevent.h +1 -0
index 9d22dcd..7bfccef 100644
@@ -22,6 +22,7 @@ struct uevent {
 	char *devpath;
 	char *action;
 	char *kernel;
+	char *wwid;
 	unsigned long seqnum;
 	char *envp[HOTPLUG_NUM_ENVP];
 };
Signature · 1 line
2.8.1.windows.1
#2 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Quoted 7 lines · On Tue, Dec 27, 2016 at 04:03:18PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

Add "char *wwid" to point WWID of uevent. This member identifies the LUN ID which the path belongs to, and it is used for merging uevents. WWID possibly did not exist in uevent yet, so ->wwid would be NULL, those uevents would not be merged, but be proccessed as old way.

Right now, multipath users are allowed configure devices to set the wwid based on any udev environment variable (or even use a callout, although this is deprecated). With this patch, that breaks. If the udev sets ID_SERIAL for a device, that is its wwid, right? Do you know if rbd devices have ID_SERIAL set? If so, this change will break them. Even if this change doesn't break any devices in their default configurations, we would need to disallow changing how the wwid is set for this patch to be safe.

-Ben

Quoted 36 lines
Change-Id Ie6b076363b3735dc7de10184b27fa799b499af0e
---
 libmultipath/uevent.c | 2 ++
 libmultipath/uevent.h | 1 +
 2 files changed, 3 insertions(+)
libmultipath/uevent.c +2 -0
index 7edcce1..ef1bafe 100644
@@ -424,6 +424,8 @@ struct uevent *uevent_from_udev_device(struct udev_device *dev)
 			uev->devpath = uev->envp[i] + 8;
 		if (strcmp(name, "ACTION") == 0)
 			uev->action = uev->envp[i] + 7;
+		if (strcmp(name, "ID_SERIAL") == 0)
+			uev->wwid = uev->envp[i] + 10;
 		i++;
 		if (i == HOTPLUG_NUM_ENVP - 1)
 			break;
libmultipath/uevent.h +1 -0
index 9d22dcd..7bfccef 100644
@@ -22,6 +22,7 @@ struct uevent {
 	char *devpath;
 	char *action;
 	char *kernel;
+	char *wwid;
 	unsigned long seqnum;
 	char *envp[HOTPLUG_NUM_ENVP];
 };
Signature · 1 line
2.8.1.windows.1
#3 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Hello Ben,

Quoted 3 lines

Right now, multipath users are allowed configure devices to set the wwid based on any udev environment variable (or even use a callout, although this is deprecated). With this patch, that breaks.

Does WWID obtained by different methods change? If it changes, we would better to modify code to keep it no change.

Quoted 2 lines

If the udev sets
ID_SERIAL for a device, that is its wwid, right?

Yes

Quoted 2 lines

Do you know if rbd
devices have ID_SERIAL set?

WWID has different label in uevents for different devices, I only test for SCSI devices. Now we do not support rbd divice for uevents merging, these device process as old way, it has no harm in logic. If we need to merge rbd uevents for these devices, we can add code to get wwid from uevents and it can be supported easily.

Regards
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected]
日期: 2017/01/04 06:03
主题: Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to
record wwid of uevent

Quoted 7 lines · On Tue, Dec 27, 2016 at 04:03:18PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

Add "char *wwid" to point WWID of uevent. This member identifies the LUN ID which the path belongs to, and it is used for merging uevents. WWID possibly did not exist in uevent yet, so ->wwid would be NULL, those uevents would not be merged, but be proccessed as old way.

Right now, multipath users are allowed configure devices to set the wwid based on any udev environment variable (or even use a callout, although this is deprecated). With this patch, that breaks. If the udev sets ID_SERIAL for a device, that is its wwid, right? Do you know if rbd devices have ID_SERIAL set? If so, this change will break them. Even if this change doesn't break any devices in their default configurations, we would need to disallow changing how the wwid is set for this patch to be safe.

-Ben

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct

Quoted 13 lines
Change-Id Ie6b076363b3735dc7de10184b27fa799b499af0e
---
 libmultipath/uevent.c | 2 ++
 libmultipath/uevent.h | 1 +
 2 files changed, 3 insertions(+)
libmultipath/uevent.c +0 -0
index 7edcce1..ef1bafe 100644
@@ -424,6 +424,8 @@ struct uevent *uevent_from_udev_device(struct 

udev_device *dev)

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct · line 424

Quoted 1 line
libmultipath/uevent.c +0 -0
                                               uev->devpath = 

uev->envp[i] + 8;

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct · line 426

Quoted 2 lines
libmultipath/uevent.c +0 -0
                               if (strcmp(name, "ACTION") == 0)
                                               uev->action = 

uev->envp[i] + 7;

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct · line 428

Quoted 2 lines
libmultipath/uevent.c +2 -0
+                              if (strcmp(name, "ID_SERIAL") == 0)
+                                              uev->wwid = uev->envp[i] 

+ 10;

Quoted 18 lines
libmultipath/uevent.c +0 -0
                               i++;
                               if (i == HOTPLUG_NUM_ENVP - 1)
                                               break;
libmultipath/uevent.h +1 -0
index 9d22dcd..7bfccef 100644
@@ -22,6 +22,7 @@ struct uevent {
               char *devpath;
               char *action;
               char *kernel;
+              char *wwid;
               unsigned long seqnum;
               char *envp[HOTPLUG_NUM_ENVP];
 };
Signature · 1 line
2.8.1.windows.1
#4 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Quoted 7 lines · On Wed, Jan 04, 2017 at 02:56:46PM +0800, [email protected] wrote:

Hello Ben,

Quoted 3 lines

Right now, multipath users are allowed configure devices to set the wwid based on any udev environment variable (or even use a callout, although this is deprecated). With this patch, that breaks.

Does WWID obtained by different methods change? If it changes, we would better to modify code to keep it no change.

Yes. users can pick any udev environment variable (and currently, any callout program that they write) to use as the wwid.

Quoted 8 lines
Quoted 2 lines

If the udev sets
ID_SERIAL for a device, that is its wwid, right?

Yes

Quoted 2 lines

Do you know if rbd
devices have ID_SERIAL set?

WWID has different label in uevents for different devices, I only test for SCSI devices.

Where is that check? I only see a check for whether ID_SERIAL exists. If it exists on things that are not scsi devices, you will set the wwid for these devices with it as well, even if it doesn't work for them.

Quoted 4 lines

Now we do not support rbd divice for uevents merging, these device process as old way, it has no harm in logic. If we need to merge rbd uevents for these devices, we can add code to get wwid from uevents and it can be supported easily.

Look at get_rbd_uid(), and how it's called. rbd devices don't even use the getuid callout or uid_attribute. They use special code called by get_uid.

Now you could add explicit checks so we only check ID_SERIAL for scsi devices, ID_UID for dasd devices, and never set the wwid otherwise. You could even make the attribute we check configurable by device type with an option like

uid_attrs "sd:ID_SERIAL dasd:ID_UID"

in the defaults section, that would set up mappings between device types and uevent attributes to check for the uid. But this would be on per device types, not per storage array, like it currently is. uid_attribute and getuid attribute would only ever be used for device types that weren't in the uid_attrs list.

The other option would be to not actually merge the uevents, but simply run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it keeps the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

As long as we make sure that we are only checking specific uevent attributes for specific device types, I'm o.k. with your way, but we are losing flexibility that multipath has always had in regards to setting the wwid. I want to point that out so that anyone who needs this knows that it is changing.

-Ben

Quoted 66 lines
   Regards
   Tang Junhui

   ������:         "Benjamin Marzinski" <[email protected]>
   �ռ���:         [email protected],
   ����:        [email protected], [email protected],
   [email protected], [email protected], [email protected],
   [email protected], [email protected]
   ����:         2017/01/04 06:03
   ����:        Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent"
   to record wwid of uevent

   --------------------------------------------------------------------------

   On Tue, Dec 27, 2016 at 04:03:18PM +0800, [email protected] wrote:
   > From: tang.junhui <[email protected]>
   >
   > Add "char *wwid" to point WWID of uevent. This member identifies
   > the LUN ID which the path belongs to, and it is used for merging
   > uevents. WWID possibly did not exist in uevent yet, so ->wwid
   > would be NULL, those uevents would not be merged, but be proccessed
   > as old way.

   Right now, multipath users are allowed configure devices to set the wwid
   based on any udev environment variable (or even use a callout, although
   this is deprecated). With this patch, that breaks. If the udev sets
   ID_SERIAL for a device, that is its wwid, right?  Do you know if rbd
   devices have ID_SERIAL set? If so, this change will break them.  Even if
   this change doesn't break any devices in their default configurations,
   we would need to disallow changing how the wwid is set for this patch
   to be safe.

   -Ben

   >
   > Change-Id: Ie6b076363b3735dc7de10184b27fa799b499af0e
   > Signed-off-by: tang.junhui <[email protected]>
   > ---
   >  libmultipath/uevent.c | 2 ++
   >  libmultipath/uevent.h | 1 +
   >  2 files changed, 3 insertions(+)
   >
   > diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
   > index 7edcce1..ef1bafe 100644
   > --- a/libmultipath/uevent.c
   > +++ b/libmultipath/uevent.c
   > @@ -424,6 +424,8 @@ struct uevent *uevent_from_udev_device(struct
   udev_device *dev)
   >                                                     uev->devpath =
   uev->envp[i] + 8;
   >                                    if (strcmp(name, "ACTION") == 0)
   >                                                     uev->action =
   uev->envp[i] + 7;
   > +                                  if (strcmp(name, "ID_SERIAL") == 0)
   > +                                                   uev->wwid =
   uev->envp[i] + 10;
   >                                    i++;
   >                                    if (i == HOTPLUG_NUM_ENVP - 1)
   >                                                     break;
   > diff --git a/libmultipath/uevent.h b/libmultipath/uevent.h
   > index 9d22dcd..7bfccef 100644
   > --- a/libmultipath/uevent.h
   > +++ b/libmultipath/uevent.h
   > @@ -22,6 +22,7 @@ struct uevent {
   >                   char *devpath;
   >                   char *action;
Quoted 8 lines
   >                   char *kernel;
   > +                 char *wwid;
   >                   unsigned long seqnum;
   >                   char *envp[HOTPLUG_NUM_ENVP];
   >  };
   > --
   > 2.8.1.windows.1
   >

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#5 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Quoted 12 lines · Benjamin Marzinski

The other option would be to not actually merge the uevents, but simply
run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it keeps
the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

That sounds a lot like configure()/coalesce_paths() to me. Would it perhaps make sense, instead of refactoring/rewriting a whole lot of code, to re-use that mature code path?

Cheers,
Martin

Signature · 8 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#6 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Quoted 14 lines · Martin Wilck
Quoted 12 lines · Benjamin Marzinski

The other option would be to not actually merge the uevents, but simply
run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it keeps
the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

Quoted 3 lines

That sounds a lot like configure()/coalesce_paths() to me. Would it perhaps make sense, instead of refactoring/rewriting a whole lot of code, to re-use that mature code path?

Like I mentioned before, configure does a lot of extra unnecessary work, and currently has the problem of dropping information about failed paths.

-Ben

Quoted 8 lines

Cheers,
Martin

Signature · 3 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
#7 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

In reply to Benjamin Marzinski

Hello Ben,

I know what you concern about. Maybe we can change the "wwid" member in "struct uevent" to another name such as "merge_id" to only identify which uevents can merge together. The value of "merge_id" can set by "ID_SERIAL" or "ID_UID" in uevent. If we get the "merge_id" from uevents, we can merge and process it as merging way, otherwise we process it as old way (processed one by one).

And we revert this patch:
"[dm-devel] [PATCH 12/12] libmultipath: use existing wwid when wwid has already been existed in uevent"
thus wwid of each path will get by methods of configuration as old ways.

The premise is that, devices whose "merge_id" is the same have the same "wwid". I think this premise can be established.

how do you think about the above proposal?

Quoted 1 line

The other option would be to not actually merge the uevents, but

simply

Quoted 5 lines

run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it

keeps

Quoted 3 lines

the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

I think it is ok, but a little complex. and if we can get rid of the "wwid" issue, we do not need to do so.

Regards
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/05 02:23
主题: Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid for "struct
uevent" to record wwid of uevent
发件人: [email protected]

Quoted 3 lines · On Wed, Jan 04, 2017 at 02:56:46PM +0800, [email protected] wrote:

Hello Ben,

Quoted 1 line

Right now, multipath users are allowed configure devices to set the

wwid

Quoted 1 line
Quoted 1 line

based on any udev environment variable (or even use a callout,

although

Quoted 2 lines
Quoted 1 line

this is deprecated). With this patch, that breaks.

Does WWID obtained by different methods change? If it changes, we

would

Quoted 1 line

better to modify code to keep it no change.

Yes. users can pick any udev environment variable (and currently, any callout program that they write) to use as the wwid.

Quoted 7 lines
Quoted 2 lines

If the udev sets
ID_SERIAL for a device, that is its wwid, right?

Yes

Quoted 2 lines

Do you know if rbd
devices have ID_SERIAL set?

WWID has different label in uevents for different devices, I only

test for

Quoted 1 line

SCSI devices.

Where is that check? I only see a check for whether ID_SERIAL exists. If it exists on things that are not scsi devices, you will set the wwid for these devices with it as well, even if it doesn't work for them.

Quoted 2 lines

Now we do not support rbd divice for uevents merging, these device process as old way, it has no harm in logic. If we need to

merge

Quoted 1 line

rbd uevents for these devices, we can add code to get wwid from

uevents

Quoted 1 line

and it can be supported easily.

Look at get_rbd_uid(), and how it's called. rbd devices don't even use the getuid callout or uid_attribute. They use special code called by get_uid.

Now you could add explicit checks so we only check ID_SERIAL for scsi devices, ID_UID for dasd devices, and never set the wwid otherwise. You could even make the attribute we check configurable by device type with an option like

uid_attrs "sd:ID_SERIAL dasd:ID_UID"

in the defaults section, that would set up mappings between device types and uevent attributes to check for the uid. But this would be on per device types, not per storage array, like it currently is. uid_attribute and getuid attribute would only ever be used for device types that weren't in the uid_attrs list.

The other option would be to not actually merge the uevents, but simply run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it keeps the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

As long as we make sure that we are only checking specific uevent attributes for specific device types, I'm o.k. with your way, but we are losing flexibility that multipath has always had in regards to setting the wwid. I want to point that out so that anyone who needs this knows that it is changing.

-Ben

Quoted 10 lines

Regards
Tang Junhui

������: "Benjamin Marzinski" <[email protected]>
�ռ���: [email protected],
����: [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected], [email protected]
����: 2017/01/04 06:03
����: Re: [PATCH 01/12] libmultipath: add wwid for "struct

uevent"

Quoted 3 lines

to record wwid of uevent

--------------------------------------------------------------------------

Quoted 2 lines
   On Tue, Dec 27, 2016 at 04:03:18PM +0800, [email protected] 
Quoted 9 lines · wrote:
Quoted 7 lines

From: tang.junhui <[email protected]>

Add "char *wwid" to point WWID of uevent. This member identifies the LUN ID which the path belongs to, and it is used for merging uevents. WWID possibly did not exist in uevent yet, so ->wwid would be NULL, those uevents would not be merged, but be proccessed as old way.

Right now, multipath users are allowed configure devices to set the

wwid

Quoted 1 line

based on any udev environment variable (or even use a callout,

although

Quoted 3 lines

this is deprecated). With this patch, that breaks. If the udev sets ID_SERIAL for a device, that is its wwid, right? Do you know if rbd devices have ID_SERIAL set? If so, this change will break them. Even

if

Quoted 1 line

this change doesn't break any devices in their default

configurations,

Quoted 17 lines
   we would need to disallow changing how the wwid is set for this patch
   to be safe.

   -Ben

   >
   > Change-Id: Ie6b076363b3735dc7de10184b27fa799b499af0e
   > Signed-off-by: tang.junhui <[email protected]>
   > ---
   >  libmultipath/uevent.c | 2 ++
   >  libmultipath/uevent.h | 1 +
   >  2 files changed, 3 insertions(+)
   >
   > diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
   > index 7edcce1..ef1bafe 100644
   > --- a/libmultipath/uevent.c
   > +++ b/libmultipath/uevent.c
Quoted 8 lines
   > @@ -424,6 +424,8 @@ struct uevent *uevent_from_udev_device(struct
   udev_device *dev)
   >                                                     uev->devpath =
   uev->envp[i] + 8;
   >                                    if (strcmp(name, "ACTION") == 0)
   >                                                     uev->action =
   uev->envp[i] + 7;
   > +                                  if (strcmp(name, "ID_SERIAL") == 

0)

Quoted 12 lines
Quoted 1 line

+ uev->wwid =

   uev->envp[i] + 10;
   >                                    i++;
   >                                    if (i == HOTPLUG_NUM_ENVP - 1)
   >                                                     break;
   > diff --git a/libmultipath/uevent.h b/libmultipath/uevent.h
   > index 9d22dcd..7bfccef 100644
   > --- a/libmultipath/uevent.h
   > +++ b/libmultipath/uevent.h
   > @@ -22,6 +22,7 @@ struct uevent {
   >                   char *devpath;
   >                   char *action;
Quoted 8 lines
   >                   char *kernel;
   > +                 char *wwid;
   >                   unsigned long seqnum;
   >                   char *envp[HOTPLUG_NUM_ENVP];
   >  };
   > --
   > 2.8.1.windows.1
   >

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#8 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Quoted 10 lines · On Thu, Jan 05, 2017 at 11:10:43AM +0800, [email protected] wrote:

Hello Ben,

I know what you concern about. Maybe we can change the "wwid" member in "struct uevent" to another name such as "merge_id" to only identify which uevents can merge together. The value of "merge_id" can set by "ID_SERIAL" or "ID_UID" in uevent. If we get the "merge_id" from uevents, we can merge and process it as merging way, otherwise we process it as old way (processed one by one).

Quoted 8 lines

And we revert this patch:
"[dm-devel] [PATCH 12/12] libmultipath: use existing wwid when wwid has already been existed in uevent"
thus wwid of each path will get by methods of configuration as old ways.

The premise is that, devices whose "merge_id" is the same have the same "wwid". I think this premise can be established.

So, if you have device where the merge_id doesn't equal the wwid, you call domap on that device, as it it wasn't part of a merged set?

That would work, but you would have to be careful to deal with the case where the last uevent in the set, the one that would be used to call domap for the whole merged set, suddenly gets processed all on it's own, because it had a different wwid from the rest of the set. In that case You would need to make sure that something called domap on the other members of the merged set. Now, I admit that this is a very unlikely thing to happen.

I thought about proposing that we revert patch 12, but it does add complexity if you find that only some of your merged devices change wwid. Also, if all of them change to the same new wwid, you just skipped merging when you should be able to. But I'm not against reverting it, as long as we handle everything o.k. Reverting it would mean that we don't have to worry about removing a capability that multipath previously had. There's just a trade-off between supporting a capability (that we don't know if anyone uses), and maintaining less complex code.

As long as it is possible to configure what uevent variable you check for by device type, I don't know of a situation where this will cause real world problems. It's possible that some users are changing uid_attribute for only certain scsi-based arrays, but I don't know of any cases. If somebody reading this knows of any cases, please speak up. But I would like to have the variable you check be configurable so that it's flexible with regards to new device types or the possiblity of differing uevent variable names either between distributions or over time. Does that sound reasonable?

-Ben

Quoted 190 lines

how do you think about the above proposal?

Quoted 1 line

   The other option would be to not actually merge the uevents, but

simply

Quoted 5 lines

   run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it

keeps

Quoted 3 lines

   the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

I think it is ok, but a little complex. and if we can get rid of the "wwid" issue, we do not need to do so.

Regards
Tang Junhui

发件人:         "Benjamin Marzinski" <[email protected]> 收件人:         [email protected],
抄送:        [email protected], [email protected], [email protected], [email protected], [email protected] 日期:         2017/01/05 02:23
主题:        Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent
发件人:        [email protected]

--------------------------------------------------------------------------

Quoted 3 lines · On Wed, Jan 04, 2017 at 02:56:46PM +0800, [email protected] wrote:

   Hello Ben,

   > Right now, multipath users are allowed configure devices to set the

wwid

Quoted 1 line

   > based on any udev environment variable (or even use a callout,

although

Quoted 2 lines

   > this is deprecated). With this patch, that breaks. Does WWID obtained by different methods change? If it changes, we

would

Quoted 1 line

   better to modify code to keep it no change.

Yes. users can pick any udev environment variable (and currently, any callout program that they write) to use as the wwid.

Quoted 7 lines

   > If the udev sets
   > ID_SERIAL for a device, that is its wwid, right? Yes

   > Do you know if rbd
   > devices have ID_SERIAL set?
   WWID has different label in uevents for different devices, I only

test for

Quoted 1 line

   SCSI devices.

Where is that check? I only see a check for whether ID_SERIAL exists. If it exists on things that are not scsi devices, you will set the wwid for these devices with it as well, even if it doesn't work for them.

Quoted 2 lines

   Now we do not support rbd divice for uevents merging, these device process as old way, it has no harm in logic. If we need to

merge

Quoted 1 line

   rbd uevents for these devices, we can add code to get wwid from

uevents

Quoted 1 line

   and it can be supported easily.

Look at get_rbd_uid(), and how it's called. rbd devices don't even use the getuid callout or uid_attribute. They use special code called by get_uid.

Now you could add explicit checks so we only check ID_SERIAL for scsi devices, ID_UID for dasd devices, and never set the wwid otherwise.  You could even make the attribute we check configurable by device type with an option like

uid_attrs "sd:ID_SERIAL dasd:ID_UID"

in the defaults section, that would set up mappings between device types and uevent attributes to check for the uid. But this would be on per device types, not per storage array, like it currently is. uid_attribute and getuid attribute would only ever be used for device types that weren't in the uid_attrs list.

The other option would be to not actually merge the uevents, but simply run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it keeps the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

As long as we make sure that we are only checking specific uevent attributes for specific device types, I'm o.k. with your way, but we are losing flexibility that multipath has always had in regards to setting the wwid. I want to point that out so that anyone who needs this knows that it is changing.

   -Ben

   >    Regards
   >    Tang Junhui
   >
   >    ������:         "Benjamin Marzinski" <[email protected]>
   >    �ռ���:         [email protected],
   >    ����:        [email protected], [email protected],
   >    [email protected], [email protected], [email protected],
   >    [email protected], [email protected]
   >    ����:         2017/01/04 06:03
   >    ����:        Re: [PATCH 01/12] libmultipath: add wwid for "struct
   uevent"
   >    to record wwid of uevent
   >
   >  
    --------------------------------------------------------------------------
   >
   >    On Tue, Dec 27, 2016 at 04:03:18PM +0800, [email protected]
   wrote:
   >    > From: tang.junhui <[email protected]>
   >    >
   >    > Add "char *wwid" to point WWID of uevent. This member identifies
   >    > the LUN ID which the path belongs to, and it is used for merging
   >    > uevents. WWID possibly did not exist in uevent yet, so ->wwid
   >    > would be NULL, those uevents would not be merged, but be proccessed
   >    > as old way.
   >
   >    Right now, multipath users are allowed configure devices to set the
   wwid
   >    based on any udev environment variable (or even use a callout,
   although
   >    this is deprecated). With this patch, that breaks. If the udev sets
   >    ID_SERIAL for a device, that is its wwid, right?  Do you know if rbd
   >    devices have ID_SERIAL set? If so, this change will break them.  Even
   if
   >    this change doesn't break any devices in their default
   configurations,
   >    we would need to disallow changing how the wwid is set for this patch
   >    to be safe.
   >
   >    -Ben
   >
   >    >
   >    > Change-Id: Ie6b076363b3735dc7de10184b27fa799b499af0e
   >    > Signed-off-by: tang.junhui <[email protected]>
   >    > ---
   >    >  libmultipath/uevent.c | 2 ++
   >    >  libmultipath/uevent.h | 1 +
   >    >  2 files changed, 3 insertions(+)
   >    >
   >    > diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
   >    > index 7edcce1..ef1bafe 100644
   >    > --- a/libmultipath/uevent.c
   >    > +++ b/libmultipath/uevent.c
   >    > @@ -424,6 +424,8 @@ struct uevent *uevent_from_udev_device(struct
   >    udev_device *dev)
   >    >                                                     uev->devpath =
   >    uev->envp[i] + 8;
   >    >                                    if (strcmp(name, "ACTION") == 0)
   >    >                                                     uev->action =
   >    uev->envp[i] + 7;
   >    > +                                  if (strcmp(name, "ID_SERIAL") ==
   0)
   >    > +                                                   uev->wwid =
   >    uev->envp[i] + 10;
   >    >                                    i++;
   >    >                                    if (i == HOTPLUG_NUM_ENVP - 1)
   >    >                                                     break;
   >    > diff --git a/libmultipath/uevent.h b/libmultipath/uevent.h
   >    > index 9d22dcd..7bfccef 100644
   >    > --- a/libmultipath/uevent.h
   >    > +++ b/libmultipath/uevent.h
   >    > @@ -22,6 +22,7 @@ struct uevent {
   >    >                   char *devpath;
   >    >                   char *action;
   >    >                   char *kernel;
   >    > +                 char *wwid;
   >    >                   unsigned long seqnum;
   >    >                   char *envp[HOTPLUG_NUM_ENVP];
   >    >  };
   >    > --
   >    > 2.8.1.windows.1
   >    >

   --
   dm-devel mailing list
   [email protected]
   [1]https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 4 lines

References

Visible links
1. https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#9 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Hello Ben,

Quoted 1 line
Quoted 1 line

The premise is that, devices whose "merge_id" is the same have

the

Quoted 4 lines
Quoted 1 line

same "wwid". I think this premise can be established.

So, if you have device where the merge_id doesn't equal the wwid, you call domap on that device, as it it wasn't part of a merged set?

Maybe I did not say clearly. "merge_id" is only used for uevents merging, and
it has nothing to do with "wwid". I only primse devices whose "merge_id" are
same have same "wwid" (Sorry, maybe I had a misleading statement in previous email).
"merge_id" and "wwid" can be same or not same. The merged uevents are still
processed as bellow patch I send previous:
[dm-devel] [PATCH 11/12] multipathd: proccess merged uevents

Regards,
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/06 01:37
主题: Re: Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid for
"struct uevent" to record wwid of uevent

Quoted 5 lines · On Thu, Jan 05, 2017 at 11:10:43AM +0800, [email protected] wrote:

Hello Ben,

I know what you concern about. Maybe we can change the "wwid" member in "struct uevent" to another name such as "merge_id" to only identify which uevents can merge together. The value of "merge_id"

can

Quoted 5 lines

set by "ID_SERIAL" or "ID_UID" in uevent. If we get the "merge_id" from uevents, we can merge and process it as merging way, otherwise we process it as old way (processed one by one).

Quoted 8 lines

And we revert this patch:
"[dm-devel] [PATCH 12/12] libmultipath: use existing wwid when wwid has already been existed in uevent"
thus wwid of each path will get by methods of configuration as old ways.

The premise is that, devices whose "merge_id" is the same have the same "wwid". I think this premise can be established.

So, if you have device where the merge_id doesn't equal the wwid, you call domap on that device, as it it wasn't part of a merged set?

That would work, but you would have to be careful to deal with the case where the last uevent in the set, the one that would be used to call domap for the whole merged set, suddenly gets processed all on it's own, because it had a different wwid from the rest of the set. In that case You would need to make sure that something called domap on the other members of the merged set. Now, I admit that this is a very unlikely thing to happen.

I thought about proposing that we revert patch 12, but it does add complexity if you find that only some of your merged devices change wwid. Also, if all of them change to the same new wwid, you just skipped merging when you should be able to. But I'm not against reverting it, as long as we handle everything o.k. Reverting it would mean that we don't have to worry about removing a capability that multipath previously had. There's just a trade-off between supporting a capability (that we don't know if anyone uses), and maintaining less complex code.

As long as it is possible to configure what uevent variable you check for by device type, I don't know of a situation where this will cause real world problems. It's possible that some users are changing uid_attribute for only certain scsi-based arrays, but I don't know of any cases. If somebody reading this knows of any cases, please speak up. But I would like to have the variable you check be configurable so that it's flexible with regards to new device types or the possiblity of differing uevent variable names either between distributions or over time. Does that sound reasonable?

-Ben

Quoted 6 lines

how do you think about the above proposal?

Quoted 1 line

The other option would be to not actually merge the uevents, but

simply

Quoted 1 line

run through the filtered but unmerged list of uevents, and skip

the

Quoted 1 line
Quoted 1 line

domap stuff but remember the maps that need pushing to

device-mapper.

Quoted 1 line
Quoted 1 line

Once you are done processing all the uevents, except for

updating the

Quoted 1 line
Quoted 1 line

maps in device-mapper, you go back and update all the maps that

need

Quoted 3 lines
Quoted 1 line

updating. There's more code refactoring in this approach, but it

keeps

Quoted 1 line

the uid being set in pathinfo, where you have all the

information

Quoted 1 line
Quoted 1 line

necessary to set it using uid_attribute, getuid, or specialized

code

Quoted 7 lines
Quoted 1 line

like rbd uses.

I think it is ok, but a little complex. and if we can get rid of the "wwid" issue, we do not need to do so.

Regards
Tang Junhui

Quoted 10 lines

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/05 02:23
主题: Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid for
"struct uevent" to record wwid of uevent
发件人: [email protected]

--------------------------------------------------------------------------

Quoted 2 lines
   On Wed, Jan 04, 2017 at 02:56:46PM +0800, [email protected] 
Quoted 3 lines · wrote:
Quoted 3 lines

Hello Ben,

Quoted 1 line

Right now, multipath users are allowed configure devices to

set the

Quoted 5 lines

wwid

Quoted 1 line
Quoted 1 line

based on any udev environment variable (or even use a callout,

although

Quoted 2 lines
Quoted 1 line

this is deprecated). With this patch, that breaks.

Does WWID obtained by different methods change? If it changes,

we

Quoted 13 lines

would

Quoted 1 line

better to modify code to keep it no change.

Yes. users can pick any udev environment variable (and currently, any callout program that they write) to use as the wwid.

Quoted 7 lines
Quoted 2 lines

If the udev sets
ID_SERIAL for a device, that is its wwid, right?

Yes

Quoted 2 lines

Do you know if rbd
devices have ID_SERIAL set?

WWID has different label in uevents for different devices, I

only

Quoted 4 lines

test for

Quoted 1 line

SCSI devices.

Where is that check? I only see a check for whether ID_SERIAL exists.

If

Quoted 1 line

it exists on things that are not scsi devices, you will set the wwid

for

Quoted 4 lines

these devices with it as well, even if it doesn't work for them.

Quoted 2 lines

Now we do not support rbd divice for uevents merging, these device process as old way, it has no harm in logic. If we need

to

Quoted 6 lines

merge

Quoted 1 line

rbd uevents for these devices, we can add code to get wwid from

uevents

Quoted 1 line

and it can be supported easily.

Look at get_rbd_uid(), and how it's called. rbd devices don't even

use

Quoted 5 lines

the getuid callout or uid_attribute. They use special code called by get_uid.

Now you could add explicit checks so we only check ID_SERIAL for scsi devices, ID_UID for dasd devices, and never set the wwid otherwise.

You

Quoted 1 line

could even make the attribute we check configurable by device type

with

Quoted 5 lines

an option like

uid_attrs "sd:ID_SERIAL dasd:ID_UID"

in the defaults section, that would set up mappings between device

types

Quoted 2 lines

and uevent attributes to check for the uid. But this would be on per device types, not per storage array, like it currently is.

uid_attribute

Quoted 4 lines

and getuid attribute would only ever be used for device types that weren't in the uid_attrs list.

The other option would be to not actually merge the uevents, but

simply

Quoted 5 lines

run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it

keeps

Quoted 6 lines

the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

As long as we make sure that we are only checking specific uevent attributes for specific device types, I'm o.k. with your way, but we

are

Quoted 1 line

losing flexibility that multipath has always had in regards to

setting

Quoted 1 line

the wwid. I want to point that out so that anyone who needs this

knows

Quoted 11 lines

that it is changing.

-Ben

Quoted 7 lines

Regards
Tang Junhui

������: "Benjamin Marzinski" <[email protected]>
�ռ���: [email protected],
����: [email protected], [email protected],
[email protected], [email protected],

[email protected],

Quoted 3 lines
Quoted 3 lines
   [email protected], [email protected]
   ����:         2017/01/04 06:03
   ����:        Re: [PATCH 01/12] libmultipath: add wwid for 

"struct

Quoted 5 lines
   uevent"
   >    to record wwid of uevent
   >
   >  

--------------------------------------------------------------------------

Quoted 6 lines
Quoted 2 lines
   On Tue, Dec 27, 2016 at 04:03:18PM +0800, [email protected]
Quoted 3 lines · wrote:
Quoted 3 lines

From: tang.junhui <[email protected]>

Add "char *wwid" to point WWID of uevent. This member

identifies

Quoted 1 line
Quoted 1 line
Quoted 1 line

the LUN ID which the path belongs to, and it is used for

merging

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

uevents. WWID possibly did not exist in uevent yet, so ->wwid would be NULL, those uevents would not be merged, but be

proccessed

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

as old way.

Right now, multipath users are allowed configure devices to set

the

Quoted 4 lines

wwid

Quoted 1 line

based on any udev environment variable (or even use a callout,

although

Quoted 1 line

this is deprecated). With this patch, that breaks. If the udev

sets

Quoted 1 line
Quoted 1 line

ID_SERIAL for a device, that is its wwid, right? Do you know if

rbd

Quoted 1 line
Quoted 1 line

devices have ID_SERIAL set? If so, this change will break them.

Even

Quoted 4 lines

if

Quoted 1 line

this change doesn't break any devices in their default

configurations,

Quoted 1 line

we would need to disallow changing how the wwid is set for this

patch

Quoted 12 lines
Quoted 12 lines

to be safe.

-Ben

Quoted 8 lines
Change-Id Ie6b076363b3735dc7de10184b27fa799b499af0e
---
 libmultipath/uevent.c | 2 ++
 libmultipath/uevent.h | 1 +
 2 files changed, 3 insertions(+)
Quoted 5 lines
Quoted 5 lines

libmultipath/uevent.c struct uevent

Quoted 5 lines
libmultipath/uevent.c +0 -0
index 7edcce1..ef1bafe 100644
@@ -424,6 +424,8 @@ struct uevent 

*uevent_from_udev_device(struct

Quoted 2 lines
Quoted 2 lines
   udev_device *dev)
   >                                                     

uev->devpath =

Quoted 2 lines
Quoted 2 lines
   uev->envp[i] + 8;
   >                                    if (strcmp(name, "ACTION") 

== 0)

Quoted 1 line
Quoted 1 line
Quoted 1 line

uev->action =

Quoted 2 lines
Quoted 2 lines

uev->envp[i] + 7;

Quoted 1 line

+ if (strcmp(name,

"ID_SERIAL") ==

Quoted 2 lines
   0)
   >    > +                                                   uev->wwid 

=

Quoted 3 lines
Quoted 3 lines
   uev->envp[i] + 10;
   >                                    i++;
   >                                    if (i == HOTPLUG_NUM_ENVP - 

1)

Quoted 26 lines
Quoted 8 lines
Quoted 8 lines
                                                    break;
libmultipath/uevent.h +0 -0
index 9d22dcd..7bfccef 100644
@@ -22,6 +22,7 @@ struct uevent {
                  char *devpath;
                  char *action;
Quoted 8 lines
Quoted 8 lines
libmultipath/uevent.h +1 -1
                  char *kernel;
+                 char *wwid;
                  unsigned long seqnum;
                  char *envp[HOTPLUG_NUM_ENVP];
 };
--

2.8.1.windows.1

--
dm-devel mailing list
[email protected] [1]https://www.redhat.com/mailman/listinfo/dm-devel

References

Visible links
1. https://www.redhat.com/mailman/listinfo/dm-devel

#10 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Quoted 9 lines · On Fri, Jan 06, 2017 at 08:59:27AM +0800, [email protected] wrote:

Hello Ben,

Quoted 1 line

   >    The premise is that, devices whose "merge_id" is the same have

the

Quoted 4 lines

   >    same "wwid". I think this premise can be established.

   So, if you have device where the merge_id doesn't equal the wwid, you call domap on that device, as it it wasn't part of a merged set?

Quoted 10 lines

Maybe I did not say clearly. "merge_id" is only used for uevents merging, and
it has nothing to do with "wwid". I only primse devices whose "merge_id" are
same have same "wwid" (Sorry, maybe I had a misleading statement in previous email).
"merge_id" and "wwid" can be same or not same. The merged uevents are still
processed as bellow patch I send previous:
[dm-devel] [PATCH 11/12] multipathd: proccess merged uevents

Let me back up. Say you have a batch of merged uevents

"add path1, path2, path3"

where path1 and path2 are on path3's merge_node list. This means that when you call uev_add_path() for path1 and path2, you will call it with need_do_map set to 0, and no multipath device will be created. The multipath device will be created when you call uev_add_path() for path3, with need_no_map set to 1. Now lets say that when you call pathinfo on path2, you get a different wwid than your merge_id. path1 and path3 get the same wwid as their merge_id. In this situation you would call domap on path1 and path3, but nothing would create the multipath device for path2.

Like I said, this is unlikely to happen. But it could. Imagine that there was some device that presented itself like a scsi device, but ID_SERIAL could have the same value for devices that should not be multipathed together. To figure out which devices actually should be multipathed together, you need to call pathinfo and get the correct wwid. In this case you would find that you had incorrectly batched devices with different wwids together.

To solve this, you would need to make sure to call domap on the device if its wwid ended up being different from its merge_id. The issue that my last email pointed out was that if the main uevent, path3 in the above example, was the only one to have a different wwid, then you would need to make sure to call domap on the other devices as well. Otherwise you would create a multipath device for path3, but not path1 and path2.

If you don't handle these cases, you will only work correctly on the (admittedly vastly more common) case where even if the wwid and merge_id don't match, the wwid is still the same for all the batched devices. But if you are already assuming that the merge_id will correctly group the devices, then what is the purpose in fetching the wwid at all? It may be different from the merge_id, but it will still group the devices the same way. There's nothing special about the wwid value itself. It is just a tool to correctly group the devices. So, I would say that you should either not grab the wwid at all if you got it from the uevent, or do grab the wwid, but be prepared to deal with the case where not all of the devices that you have batched having the same wwid.

Does that make more sense?

-Ben

Quoted 301 lines

Regards,
Tang Junhui

发件人:         "Benjamin Marzinski" <[email protected]>
收件人:         [email protected],
抄送:        [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
日期:         2017/01/06 01:37
主题:        Re: Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

--------------------------------------------------------------------------

Quoted 5 lines · On Thu, Jan 05, 2017 at 11:10:43AM +0800, [email protected] wrote:

   Hello Ben,

   I know what you concern about. Maybe we can change the "wwid" member in "struct uevent" to another name such as "merge_id" to only identify which uevents can merge together. The value of "merge_id"

can

Quoted 4 lines

   set by "ID_SERIAL" or "ID_UID" in uevent. If we get the "merge_id" from uevents, we can merge and process it as merging way, otherwise we process it as old way (processed one by one).

Quoted 8 lines

   And we revert this patch:
   "[dm-devel] [PATCH 12/12] libmultipath: use existing wwid when wwid has already been existed in uevent"
   thus wwid of each path will get by methods of configuration as old ways.

   The premise is that, devices whose "merge_id" is the same have the same "wwid". I think this premise can be established.

So, if you have device where the merge_id doesn't equal the wwid, you call domap on that device, as it it wasn't part of a merged set?

That would work, but you would have to be careful to deal with the case where the last uevent in the set, the one that would be used to call domap for the whole merged set, suddenly gets processed all on it's own, because it had a different wwid from the rest of the set. In that case You would need to make sure that something called domap on the other members of the merged set.  Now, I admit that this is a very unlikely thing to happen.

I thought about proposing that we revert patch 12, but it does add complexity if you find that only some of your merged devices change wwid. Also, if all of them change to the same new wwid, you just skipped merging when you should be able to. But I'm not against reverting it, as long as we handle everything o.k. Reverting it would mean that we don't have to worry about removing a capability that multipath previously had. There's just a trade-off between supporting a capability (that we don't know if anyone uses), and maintaining less complex code.

As long as it is possible to configure what uevent variable you check for by device type, I don't know of a situation where this will cause real world problems. It's possible that some users are changing uid_attribute for only certain scsi-based arrays, but I don't know of any cases. If somebody reading this knows of any cases, please speak up. But I would like to have the variable you check be configurable so that it's flexible with regards to new device types or the possiblity of differing uevent variable names either between distributions or over time. Does that sound reasonable?

-Ben

Quoted 6 lines

   how do you think about the above proposal?

   >    The other option would be to not actually merge the uevents, but simply
   >    run through the filtered but unmerged list of uevents, and skip

the

Quoted 1 line

   >    domap stuff but remember the maps that need pushing to

device-mapper.

Quoted 1 line

   >    Once you are done processing all the uevents, except for

updating the

Quoted 1 line

   >    maps in device-mapper, you go back and update all the maps that

need

Quoted 3 lines

   >    updating. There's more code refactoring in this approach, but it keeps
   >    the uid being set in pathinfo, where you have all the

information

Quoted 1 line

   >    necessary to set it using uid_attribute, getuid, or specialized

code

Quoted 16 lines

   >    like rbd uses.
   I think it is ok, but a little complex. and if we can get rid of the "wwid" issue, we do not need to do so.

   Regards
   Tang Junhui

   发件人:         "Benjamin Marzinski" <[email protected]> 收件人:         [email protected],
   抄送:        [email protected], [email protected], [email protected], [email protected], [email protected] 日期:         2017/01/05 02:23
   主题:        Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent
   发件人:        [email protected]

Quoted 1 line

 --------------------------------------------------------------------------

Quoted 2 lines

   On Wed, Jan 04, 2017 at 02:56:46PM +0800, [email protected]

Quoted 3 lines · wrote:

   >    Hello Ben,
   >
   >    > Right now, multipath users are allowed configure devices to

set the

Quoted 5 lines

   wwid
   >    > based on any udev environment variable (or even use a callout, although
   >    > this is deprecated). With this patch, that breaks. >    Does WWID obtained by different methods change? If it changes,

we

Quoted 6 lines

   would
   >    better to modify code to keep it no change.

   Yes. users can pick any udev environment variable (and currently, any callout program that they write) to use as the wwid.

Quoted 7 lines

   >    > If the udev sets
   >    > ID_SERIAL for a device, that is its wwid, right? >    Yes
   >
   >    > Do you know if rbd
   >    > devices have ID_SERIAL set?
   >    WWID has different label in uevents for different devices, I

only

Quoted 4 lines

   test for
   >    SCSI devices.

   Where is that check? I only see a check for whether ID_SERIAL exists.

If

Quoted 1 line

   it exists on things that are not scsi devices, you will set the wwid

for

Quoted 4 lines

   these devices with it as well, even if it doesn't work for them.

   >    Now we do not support rbd divice for uevents merging, these >    device process as old way, it has no harm in logic. If we need

to

Quoted 6 lines

   merge
   >    rbd uevents for these devices, we can add code to get wwid from uevents
   >    and it can be supported easily.

   Look at get_rbd_uid(), and how it's called. rbd devices don't even

use

Quoted 5 lines

   the getuid callout or uid_attribute. They use special code called by get_uid.

   Now you could add explicit checks so we only check ID_SERIAL for scsi devices, ID_UID for dasd devices, and never set the wwid otherwise.

 You

Quoted 1 line

   could even make the attribute we check configurable by device type

with

Quoted 5 lines

   an option like

   uid_attrs "sd:ID_SERIAL dasd:ID_UID"

   in the defaults section, that would set up mappings between device

types

Quoted 2 lines

   and uevent attributes to check for the uid. But this would be on per device types, not per storage array, like it currently is.

uid_attribute

Quoted 4 lines

   and getuid attribute would only ever be used for device types that weren't in the uid_attrs list.

   The other option would be to not actually merge the uevents, but

simply

Quoted 5 lines

   run through the filtered but unmerged list of uevents, and skip the domap stuff but remember the maps that need pushing to device-mapper. Once you are done processing all the uevents, except for updating the maps in device-mapper, you go back and update all the maps that need updating. There's more code refactoring in this approach, but it

keeps

Quoted 6 lines

   the uid being set in pathinfo, where you have all the information necessary to set it using uid_attribute, getuid, or specialized code like rbd uses.

   As long as we make sure that we are only checking specific uevent attributes for specific device types, I'm o.k. with your way, but we

are

Quoted 1 line

   losing flexibility that multipath has always had in regards to

setting

Quoted 1 line

   the wwid. I want to point that out so that anyone who needs this

knows

Quoted 11 lines

   that it is changing.

   -Ben

   >    Regards
   >    Tang Junhui
   >
   >    ������:         "Benjamin Marzinski" <[email protected]> >    �ռ���:         [email protected],
   >    ����:        [email protected], [email protected], >    [email protected], [email protected],

[email protected],

Quoted 3 lines

   >    [email protected], [email protected] >    ����:         2017/01/04 06:03
   >    ����:        Re: [PATCH 01/12] libmultipath: add wwid for

"struct

Quoted 5 lines

   uevent"
   >    to record wwid of uevent
   >
   >

  --------------------------------------------------------------------------

Quoted 6 lines

   >
   >    On Tue, Dec 27, 2016 at 04:03:18PM +0800, [email protected] wrote:
   >    > From: tang.junhui <[email protected]>
   >    >
   >    > Add "char *wwid" to point WWID of uevent. This member

identifies

Quoted 1 line

   >    > the LUN ID which the path belongs to, and it is used for

merging

Quoted 2 lines

   >    > uevents. WWID possibly did not exist in uevent yet, so ->wwid >    > would be NULL, those uevents would not be merged, but be

proccessed

Quoted 3 lines

   >    > as old way.
   >
   >    Right now, multipath users are allowed configure devices to set

the

Quoted 4 lines

   wwid
   >    based on any udev environment variable (or even use a callout, although
   >    this is deprecated). With this patch, that breaks. If the udev

sets

Quoted 1 line

   >    ID_SERIAL for a device, that is its wwid, right?  Do you know if

rbd

Quoted 1 line

   >    devices have ID_SERIAL set? If so, this change will break them.

 Even

Quoted 4 lines

   if
   >    this change doesn't break any devices in their default configurations,
   >    we would need to disallow changing how the wwid is set for this

patch

Quoted 9 lines

   >    to be safe.
   >
   >    -Ben
   >
   >    >
   >    > Change-Id: Ie6b076363b3735dc7de10184b27fa799b499af0e >    > Signed-off-by: tang.junhui <[email protected]> >    > ---
   >    >  libmultipath/uevent.c | 2 ++

Quoted 8 lines

   >    >  libmultipath/uevent.h | 1 +
   >    >  2 files changed, 3 insertions(+)
   >    >
   >    > diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c >    > index 7edcce1..ef1bafe 100644
   >    > --- a/libmultipath/uevent.c
   >    > +++ b/libmultipath/uevent.c
   >    > @@ -424,6 +424,8 @@ struct uevent

*uevent_from_udev_device(struct

Quoted 2 lines

   >    udev_device *dev)
   >    >

uev->devpath =

Quoted 2 lines

   >    uev->envp[i] + 8;
   >    >                                    if (strcmp(name, "ACTION")

== 0)

Quoted 1 line

   >    >

uev->action =

Quoted 2 lines

   >    uev->envp[i] + 7;
   >    > +                                  if (strcmp(name,

"ID_SERIAL") ==

Quoted 2 lines

   0)
   >    > +                                                   uev->wwid

=

Quoted 3 lines

   >    uev->envp[i] + 10;
   >    >                                    i++;
   >    >                                    if (i == HOTPLUG_NUM_ENVP -

1)

Quoted 24 lines

   >    >                                                     break; >    > diff --git a/libmultipath/uevent.h b/libmultipath/uevent.h >    > index 9d22dcd..7bfccef 100644
   >    > --- a/libmultipath/uevent.h
   >    > +++ b/libmultipath/uevent.h
   >    > @@ -22,6 +22,7 @@ struct uevent {
   >    >                   char *devpath;
   >    >                   char *action;
   >    >                   char *kernel;
   >    > +                 char *wwid;
   >    >                   unsigned long seqnum;
   >    >                   char *envp[HOTPLUG_NUM_ENVP]; >    >  };
   >    > --
   >    > 2.8.1.windows.1
   >    >

   --
   dm-devel mailing list
   [email protected] [1][1]https://www.redhat.com/mailman/listinfo/dm-devel

References

Quoted 8 lines
Quoted 2 lines

   Visible links
   1. [2]https://www.redhat.com/mailman/listinfo/dm-devel

References

Visible links
1. https://www.redhat.com/mailman/listinfo/dm-devel
2. https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#11 lore raw

Re: [PATCH 01/12] libmultipath: add wwid for "struct uevent" to record wwid of uevent

Hello Ben,

OK, I will modify code to call domap() on the device if its wwid is different from its merge_id.

I'll resend a serials of patch later,
Thank you for your patience.

Regards,
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected]
日期: 2017/01/07 00:11
主题: Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid for "struct
uevent" to record wwid of uevent
发件人: [email protected]

Quoted 3 lines · On Fri, Jan 06, 2017 at 08:59:27AM +0800, [email protected] wrote:

Hello Ben,

Quoted 1 line
Quoted 1 line

The premise is that, devices whose "merge_id" is the same

have

Quoted 4 lines

the

Quoted 3 lines
Quoted 1 line

same "wwid". I think this premise can be established.

So, if you have device where the merge_id doesn't equal the

wwid, you

Quoted 3 lines
Quoted 1 line

call domap on that device, as it it wasn't part of a merged set?

Maybe I did not say clearly. "merge_id" is only used for uevents

merging,

Quoted 2 lines

and
it has nothing to do with "wwid". I only primse devices whose

"merge_id"

Quoted 7 lines

are
same have same "wwid" (Sorry, maybe I had a misleading statement in previous email).
"merge_id" and "wwid" can be same or not same. The merged uevents are still
processed as bellow patch I send previous:
[dm-devel] [PATCH 11/12] multipathd: proccess merged uevents

Let me back up. Say you have a batch of merged uevents

"add path1, path2, path3"

where path1 and path2 are on path3's merge_node list. This means that when you call uev_add_path() for path1 and path2, you will call it with need_do_map set to 0, and no multipath device will be created. The multipath device will be created when you call uev_add_path() for path3, with need_no_map set to 1. Now lets say that when you call pathinfo on path2, you get a different wwid than your merge_id. path1 and path3 get the same wwid as their merge_id. In this situation you would call domap on path1 and path3, but nothing would create the multipath device for path2.

Like I said, this is unlikely to happen. But it could. Imagine that there was some device that presented itself like a scsi device, but ID_SERIAL could have the same value for devices that should not be multipathed together. To figure out which devices actually should be multipathed together, you need to call pathinfo and get the correct wwid. In this case you would find that you had incorrectly batched devices with different wwids together.

To solve this, you would need to make sure to call domap on the device if its wwid ended up being different from its merge_id. The issue that my last email pointed out was that if the main uevent, path3 in the above example, was the only one to have a different wwid, then you would need to make sure to call domap on the other devices as well. Otherwise you would create a multipath device for path3, but not path1 and path2.

If you don't handle these cases, you will only work correctly on the (admittedly vastly more common) case where even if the wwid and merge_id don't match, the wwid is still the same for all the batched devices. But if you are already assuming that the merge_id will correctly group the devices, then what is the purpose in fetching the wwid at all? It may be different from the merge_id, but it will still group the devices the same way. There's nothing special about the wwid value itself. It is just a tool to correctly group the devices. So, I would say that you should either not grab the wwid at all if you got it from the uevent, or do grab the wwid, but be prepared to deal with the case where not all of the devices that you have batched having the same wwid.

Does that make more sense?

-Ben

Quoted 8 lines

Regards,
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected],

[email protected],

Quoted 3 lines
   [email protected]
   日期:         2017/01/06 01:37
   主题:        Re: Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid 

for

Quoted 3 lines

"struct uevent" to record wwid of uevent

--------------------------------------------------------------------------

Quoted 2 lines
   On Thu, Jan 05, 2017 at 11:10:43AM +0800, [email protected] 
Quoted 3 lines · wrote:
Quoted 3 lines

Hello Ben,

I know what you concern about. Maybe we can change the "wwid"

member

Quoted 2 lines
Quoted 2 lines

in "struct uevent" to another name such as "merge_id" to only identify which uevents can merge together. The value of

"merge_id"

Quoted 2 lines

can

Quoted 1 line

set by "ID_SERIAL" or "ID_UID" in uevent. If we get the

"merge_id"

Quoted 1 line
Quoted 1 line

from uevents, we can merge and process it as merging way,

otherwise

Quoted 4 lines
Quoted 4 lines

we process it as old way (processed one by one).

And we revert this patch:
"[dm-devel] [PATCH 12/12] libmultipath: use existing wwid when

wwid

Quoted 2 lines
Quoted 2 lines

has already been existed in uevent"
thus wwid of each path will get by methods of configuration as

old

Quoted 3 lines
Quoted 3 lines

ways.

The premise is that, devices whose "merge_id" is the same have

the

Quoted 6 lines
Quoted 1 line

same "wwid". I think this premise can be established.

So, if you have device where the merge_id doesn't equal the wwid, you call domap on that device, as it it wasn't part of a merged set?

That would work, but you would have to be careful to deal with the

case

Quoted 2 lines

where the last uevent in the set, the one that would be used to call domap for the whole merged set, suddenly gets processed all on it's

own,

Quoted 1 line

because it had a different wwid from the rest of the set. In that

case

Quoted 7 lines

You would need to make sure that something called domap on the other members of the merged set. Now, I admit that this is a very unlikely thing to happen.

I thought about proposing that we revert patch 12, but it does add complexity if you find that only some of your merged devices change wwid. Also, if all of them change to the same new wwid, you just

skipped

Quoted 1 line

merging when you should be able to. But I'm not against reverting it,

as

Quoted 1 line

long as we handle everything o.k. Reverting it would mean that we

don't

Quoted 1 line

have to worry about removing a capability that multipath previously

had.

Quoted 1 line

There's just a trade-off between supporting a capability (that we

don't

Quoted 7 lines

know if anyone uses), and maintaining less complex code.

As long as it is possible to configure what uevent variable you check for by device type, I don't know of a situation where this will cause real world problems. It's possible that some users are changing uid_attribute for only certain scsi-based arrays, but I don't know of any cases. If somebody reading this knows of any cases, please speak

up.

Quoted 1 line

But I would like to have the variable you check be configurable so

that

Quoted 10 lines

it's flexible with regards to new device types or the possiblity of differing uevent variable names either between distributions or over time. Does that sound reasonable?

-Ben

Quoted 4 lines

how do you think about the above proposal?

Quoted 1 line

The other option would be to not actually merge the

uevents, but

Quoted 2 lines
Quoted 2 lines

simply

Quoted 1 line

run through the filtered but unmerged list of uevents, and

skip

Quoted 6 lines

the

Quoted 1 line
Quoted 1 line

domap stuff but remember the maps that need pushing to

device-mapper.

Quoted 1 line
Quoted 1 line

Once you are done processing all the uevents, except for

updating the

Quoted 1 line
Quoted 1 line

maps in device-mapper, you go back and update all the maps

that

Quoted 2 lines

need

Quoted 1 line
Quoted 1 line

updating. There's more code refactoring in this approach,

but it

Quoted 4 lines
Quoted 2 lines

keeps

Quoted 1 line

the uid being set in pathinfo, where you have all the

information

Quoted 1 line
Quoted 1 line

necessary to set it using uid_attribute, getuid, or

specialized

Quoted 3 lines

code

Quoted 2 lines
Quoted 1 line

like rbd uses.

I think it is ok, but a little complex. and if we can get rid of

the

Quoted 11 lines
Quoted 11 lines

"wwid" issue, we do not need to do so.

Regards
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/05 02:23
主题: Re: [dm-devel] [PATCH 01/12] libmultipath: add wwid

for

Quoted 5 lines
Quoted 4 lines

"struct uevent" to record wwid of uevent
发件人: [email protected]

--------------------------------------------------------------------------

Quoted 6 lines
Quoted 2 lines
   On Wed, Jan 04, 2017 at 02:56:46PM +0800, [email protected]
Quoted 3 lines · wrote:
Quoted 3 lines

Hello Ben,

Quoted 1 line

Right now, multipath users are allowed configure devices

to

Quoted 3 lines

set the

Quoted 2 lines

wwid

Quoted 1 line
Quoted 1 line

based on any udev environment variable (or even use a

callout,

Quoted 3 lines
Quoted 3 lines

although

Quoted 2 lines
Quoted 1 line

this is deprecated). With this patch, that breaks.

Does WWID obtained by different methods change? If it

changes,

Quoted 5 lines

we

Quoted 4 lines

would

Quoted 1 line

better to modify code to keep it no change.

Yes. users can pick any udev environment variable (and

currently, any

Quoted 9 lines
Quoted 9 lines

callout program that they write) to use as the wwid.

Quoted 7 lines
Quoted 2 lines

If the udev sets
ID_SERIAL for a device, that is its wwid, right?

Yes

Quoted 2 lines

Do you know if rbd
devices have ID_SERIAL set?

WWID has different label in uevents for different devices,

I

Quoted 5 lines

only

Quoted 4 lines

test for

Quoted 1 line

SCSI devices.

Where is that check? I only see a check for whether ID_SERIAL

exists.

Quoted 2 lines

If

Quoted 1 line

it exists on things that are not scsi devices, you will set the

wwid

Quoted 5 lines

for

Quoted 4 lines

these devices with it as well, even if it doesn't work for them.

Quoted 2 lines

Now we do not support rbd divice for uevents merging, these device process as old way, it has no harm in logic. If we

need

Quoted 3 lines

to

Quoted 2 lines

merge

Quoted 1 line

rbd uevents for these devices, we can add code to get wwid

from

Quoted 4 lines
Quoted 4 lines

uevents

Quoted 1 line

and it can be supported easily.

Look at get_rbd_uid(), and how it's called. rbd devices don't

even

Quoted 2 lines

use

Quoted 1 line

the getuid callout or uid_attribute. They use special code

called by

Quoted 3 lines
Quoted 3 lines

get_uid.

Now you could add explicit checks so we only check ID_SERIAL for

scsi

Quoted 1 line
Quoted 1 line

devices, ID_UID for dasd devices, and never set the wwid

otherwise.

Quoted 2 lines

You

Quoted 1 line

could even make the attribute we check configurable by device

type

Quoted 6 lines

with

Quoted 5 lines

an option like

uid_attrs "sd:ID_SERIAL dasd:ID_UID"

in the defaults section, that would set up mappings between

device

Quoted 2 lines

types

Quoted 1 line

and uevent attributes to check for the uid. But this would be on

per

Quoted 3 lines
Quoted 1 line

device types, not per storage array, like it currently is.

uid_attribute

Quoted 1 line

and getuid attribute would only ever be used for device types

that

Quoted 5 lines
Quoted 3 lines

weren't in the uid_attrs list.

The other option would be to not actually merge the uevents, but

simply

Quoted 1 line

run through the filtered but unmerged list of uevents, and skip

the

Quoted 1 line
Quoted 1 line

domap stuff but remember the maps that need pushing to

device-mapper.

Quoted 1 line
Quoted 1 line

Once you are done processing all the uevents, except for

updating the

Quoted 1 line
Quoted 1 line

maps in device-mapper, you go back and update all the maps that

need

Quoted 3 lines
Quoted 1 line

updating. There's more code refactoring in this approach, but it

keeps

Quoted 1 line

the uid being set in pathinfo, where you have all the

information

Quoted 1 line
Quoted 1 line

necessary to set it using uid_attribute, getuid, or specialized

code

Quoted 3 lines
Quoted 3 lines

like rbd uses.

As long as we make sure that we are only checking specific

uevent

Quoted 1 line
Quoted 1 line

attributes for specific device types, I'm o.k. with your way,

but we

Quoted 13 lines

are

Quoted 1 line

losing flexibility that multipath has always had in regards to

setting

Quoted 1 line

the wwid. I want to point that out so that anyone who needs this

knows

Quoted 8 lines

that it is changing.

-Ben

Quoted 4 lines

Regards
Tang Junhui

������: "Benjamin Marzinski"

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

�ռ���: [email protected],
����: [email protected],

[email protected],

Quoted 5 lines
Quoted 1 line
Quoted 1 line

[email protected], [email protected],

[email protected],

Quoted 3 lines
Quoted 3 lines
   [email protected], [email protected]
   ����:         2017/01/04 06:03
   ����:        Re: [PATCH 01/12] libmultipath: add wwid 

for

Quoted 7 lines
   "struct
   >    uevent"
   >    >    to record wwid of uevent
   >    >
   >    >  
   >  

--------------------------------------------------------------------------

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
   On Tue, Dec 27, 2016 at 04:03:18PM +0800, 

[email protected]

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines · wrote:
Quoted 3 lines

From: tang.junhui <[email protected]>

Add "char *wwid" to point WWID of uevent. This member

identifies

Quoted 1 line
Quoted 1 line
Quoted 1 line

the LUN ID which the path belongs to, and it is used for

merging

Quoted 1 line
Quoted 1 line
Quoted 1 line

uevents. WWID possibly did not exist in uevent yet, so

->wwid

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

would be NULL, those uevents would not be merged, but be

proccessed

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

as old way.

Right now, multipath users are allowed configure devices to

set

Quoted 3 lines

the

Quoted 2 lines

wwid

Quoted 1 line

based on any udev environment variable (or even use a

callout,

Quoted 2 lines
Quoted 2 lines

although

Quoted 1 line

this is deprecated). With this patch, that breaks. If the

udev

Quoted 2 lines

sets

Quoted 1 line
Quoted 1 line

ID_SERIAL for a device, that is its wwid, right? Do you

know if

Quoted 2 lines

rbd

Quoted 1 line
Quoted 1 line

devices have ID_SERIAL set? If so, this change will break

them.

Quoted 5 lines

Even

Quoted 4 lines

if

Quoted 1 line

this change doesn't break any devices in their default

configurations,

Quoted 1 line

we would need to disallow changing how the wwid is set for

this

Quoted 6 lines
   patch
   >    >    to be safe.
   >    >
   >    >    -Ben
   >    >
   >    >    >
Quoted 8 lines
   >    >    > Change-Id: Ie6b076363b3735dc7de10184b27fa799b499af0e
   >    >    > Signed-off-by: tang.junhui <[email protected]>
   >    >    > ---
   >    >    >  libmultipath/uevent.c | 2 ++
   >    >    >  libmultipath/uevent.h | 1 +
   >    >    >  2 files changed, 3 insertions(+)
   >    >    >
   >    >    > diff --git a/libmultipath/uevent.c 

b/libmultipath/uevent.c

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

libmultipath/uevent.c struct uevent

Quoted 4 lines

index 7edcce1..ef1bafe 100644

libmultipath/uevent.c +0 -0
@@ -424,6 +424,8 @@ struct uevent

*uevent_from_udev_device(struct

Quoted 2 lines
Quoted 2 lines
   udev_device *dev)
   >                                                    

uev->devpath =

Quoted 2 lines
Quoted 2 lines
   uev->envp[i] + 8;
   >                                    if (strcmp(name, 

"ACTION")

Quoted 8 lines
   == 0)
   >    >    >                                                    
   uev->action =
   >    >    uev->envp[i] + 7;
   >    >    > +                                  if (strcmp(name,
   "ID_SERIAL") ==
   >    0)
   >    >    > +                                                   

uev->wwid

Quoted 4 lines
   =
   >    >    uev->envp[i] + 10;
   >    >    >                                    i++;
   >    >    >                                    if (i == 

HOTPLUG_NUM_ENVP -

Quoted 2 lines
   1)
   >    >    >                                                     

break;

Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/libmultipath/uevent.h

Quoted 22 lines
Quoted 22 lines
Quoted 6 lines
Quoted 6 lines

index 9d22dcd..7bfccef 100644

libmultipath/uevent.h +0 -0
@@ -22,6 +22,7 @@ struct uevent {
                  char *devpath;
                  char *action;
Quoted 8 lines
Quoted 8 lines
libmultipath/uevent.h +1 -1
                  char *kernel;
+                 char *wwid;
                  unsigned long seqnum;
                  char *envp[HOTPLUG_NUM_ENVP];
 };
--

2.8.1.windows.1

   --
   dm-devel mailing list
   [email protected]
   [1][1]https://www.redhat.com/mailman/listinfo/dm-devel

References

Quoted 8 lines
Quoted 2 lines

Visible links
1. [2]https://www.redhat.com/mailman/listinfo/dm-devel

References

Visible links
1. https://www.redhat.com/mailman/listinfo/dm-devel
2. https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#12 lore raw

PATCH 2/12 libmultipath: add merge_node for "struct uevent" to record nodes of merged uevents

In reply to [email protected]

From: tang.junhui <[email protected]>

Add merged nodes list to store nodes of merged uevents. By Adding this member, after merging, the list of uevents would be linked like this:
uevent
---------------------------
|struct list_head node |----->list node of un-merged uevents
---------------------------

|struct list_head merge_node|----->list node of merged uevents, which
----------------------------       moved from the origin un-merged list
|...                        |

---------------------------

Change-Id I5fbfc7656ede77e03ca35c855212e2d2d60706b2
---
 libmultipath/uevent.c | 4 +++-
 libmultipath/uevent.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
libmultipath/uevent.c +3 -1
index ef1bafe..181b3b8 100644
@@ -72,8 +72,10 @@ struct uevent * alloc_uevent (void)
 {
 	struct uevent *uev = MALLOC(sizeof(struct uevent));
 
-	if (uev)
+	if (uev) {
 		INIT_LIST_HEAD(&uev->node);
+		INIT_LIST_HEAD(&uev->merge_node);
+	}
 
 	return uev;
 }
libmultipath/uevent.h +1 -0
index 7bfccef..61a4207 100644
@@ -17,6 +17,7 @@ struct udev;
 
 struct uevent {
 	struct list_head node;
+	struct list_head merge_node;
 	struct udev_device *udev;
 	char buffer[HOTPLUG_BUFFER_SIZE + OBJECT_SIZE];
 	char *devpath;
Signature · 1 line
2.8.1.windows.1
#13 lore raw

PATCH 3/12 libmultipath: add two list iteration macros

In reply to [email protected]

From: tang.junhui <[email protected]>

Add two list iteration macros, they are used to iterate list forwards or backwards from the given begin node to the given end node, which would be used in merging uevents.

Change-Id I8bb53fef9276bb62a5e0f4fdac6455086dc03d9b
---
 libmultipath/list.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
libmultipath/list.h +24 -0
index ceaa381..e728ff0 100644
@@ -294,6 +294,18 @@ static inline void list_splice_tail_init(struct list_head *list,
 	     pos = list_entry(pos->member.next, typeof(*pos), member))
 
 /**
+ * list_for_some_entry	-	iterate list of given interval
+ * @pos:	the type * to use as a loop counter.
+ * @from:	the begin node of the iteration.
+ * @to:		the end node of the iteration.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_some_entry(pos, from, to, member)				\
+	for (pos = list_entry((from)->next, typeof(*pos), member);	\
+	     &pos->member != (to);					\
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
  * list_for_each_entry_reverse - iterate backwards over list of given type.
  * @pos:	the type * to use as a loop counter.
  * @head:	the head for your list.
@@ -305,6 +317,18 @@ static inline void list_splice_tail_init(struct list_head *list,
 	     pos = list_entry(pos->member.prev, typeof(*pos), member))
 
 /**
+ * list_for_some_entry_reverse	-	iterate backwards list of given interval
+ * @pos:	the type * to use as a loop counter.
+ * @from:	the begin node of the iteration.
+ * @to:		the end node of the iteration.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_some_entry_reverse(pos, from, to, member)			\
+	for (pos = list_entry((from)->prev, typeof(*pos), member);	\
+	     &pos->member != (to);					\
+	     pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
  * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  * @pos:	the type * to use as a loop counter.
  * @n:		another type * to use as temporary storage
Signature · 1 line
2.8.1.windows.1
#14 lore raw

PATCH 4/12 multipathd: add need_do_map to indicate whether need calling domap() in ev_add_path()

In reply to [email protected]

From: tang.junhui <[email protected]>

Usually calling domap() in ev_add_path() is needed, but only last path need to call domap() in processing for merged uevents to reduce the count of calling domap() and promote efficiency. So add input parameter need_do_map to indicate whether need calling domap() in ev_add_path().

Change-Id I7f33de49a1d89d91180dcb95cd94e4944ae7ff36
---
 multipathd/cli_handlers.c |  3 ++-
 multipathd/main.c         | 25 ++++++++++++++++---------
 multipathd/main.h         |  2 +-
 3 files changed, 19 insertions(+), 11 deletions(-)
multipathd/cli_handlers.c +2 -1
index b0eeca6..3a46c09 100644
@@ -670,7 +670,8 @@ cli_add_path (void * v, char ** reply, int * len, void * data)
 		pp->checkint = conf->checkint;
 	}
 	put_multipath_config(conf);
-	return ev_add_path(pp, vecs);
+	return ev_add_path(pp, vecs, 1);
+
 blacklisted:
 	*reply = strdup("blacklisted\n");
 	*len = strlen(*reply) + 1;
multipathd/main.c +16 -9
index adc3258..34b1b64 100644
@@ -608,7 +608,7 @@ ev_remove_map (char * devname, char * alias, int minor, struct vectors * vecs)
 }
 
 static int
-uev_add_path (struct uevent *uev, struct vectors * vecs)
+uev_add_path (struct uevent *uev, struct vectors * vecs, int need_do_map)
 {
 	struct path *pp;
 	int ret = 0, i;
@@ -641,7 +641,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)
 				     DI_ALL | DI_BLACKLIST);
 			put_multipath_config(conf);
 			if (r == PATHINFO_OK)
-				ret = ev_add_path(pp, vecs);
+				ret = ev_add_path(pp, vecs, need_do_map);
 			else if (r == PATHINFO_SKIPPED) {
 				condlog(3, "%s: remove blacklisted path",
 					uev->kernel);
@@ -681,7 +681,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)
 		conf = get_multipath_config();
 		pp->checkint = conf->checkint;
 		put_multipath_config(conf);
-		ret = ev_add_path(pp, vecs);
+		ret = ev_add_path(pp, vecs, need_do_map);
 	} else {
 		condlog(0, "%s: failed to store path info, "
 			"dropping event",
@@ -699,7 +699,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)
  * 1: error
  */
 int
-ev_add_path (struct path * pp, struct vectors * vecs)
+ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map)
 {
 	struct multipath * mpp;
 	char params[PARAMS_SIZE] = {0};
@@ -767,6 +767,13 @@ rescan:
 	/* persistent reservation check*/
 	mpath_pr_event_handle(pp);
 
+	if (!need_do_map)
+		return 0;
+
+	if (!dm_map_present(mpp->alias)) {
+		mpp->action = ACT_CREATE;
+		start_waiter = 1;
+	}
 	/*
 	 * push the map to the device-mapper
 	 */
@@ -995,7 +1002,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
 		}
 
 		if (pp->initialized == INIT_REQUESTED_UDEV)
-			retval = uev_add_path(uev, vecs);
+			retval = uev_add_path(uev, vecs, 1);
 		else if (mpp && ro >= 0) {
 			condlog(2, "%s: update path write_protect to '%d' (uevent)", uev->kernel, ro);
 
@@ -1150,7 +1157,7 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 	put_multipath_config(conf);
 
 	if (!strncmp(uev->action, "add", 3)) {
-		r = uev_add_path(uev, vecs);
+		r = uev_add_path(uev, vecs, 1);
 		goto out;
 	}
 	if (!strncmp(uev->action, "remove", 6)) {
@@ -1570,7 +1577,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 			conf = get_multipath_config();
 			ret = pathinfo(pp, conf, DI_ALL | DI_BLACKLIST);
 			if (ret == PATHINFO_OK) {
-				ev_add_path(pp, vecs);
+				ev_add_path(pp, vecs, 1);
 				pp->tick = 1;
 			} else if (ret == PATHINFO_SKIPPED) {
 				put_multipath_config(conf);
@@ -1686,7 +1693,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 		}
 		if (!disable_reinstate && reinstate_path(pp, add_active)) {
 			condlog(3, "%s: reload map", pp->dev);
-			ev_add_path(pp, vecs);
+			ev_add_path(pp, vecs, 1);
 			pp->tick = 1;
 			return 0;
 		}
@@ -1709,7 +1716,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks)
 			/* Clear IO errors */
 			if (reinstate_path(pp, 0)) {
 				condlog(3, "%s: reload map", pp->dev);
-				ev_add_path(pp, vecs);
+				ev_add_path(pp, vecs, 1);
 				pp->tick = 1;
 				return 0;
 			}
multipathd/main.h +1 -1
index f72580d..f810d41 100644
@@ -22,7 +22,7 @@ void exit_daemon(void);
 const char * daemon_status(void);
 int need_to_delay_reconfig (struct vectors *);
 int reconfigure (struct vectors *);
-int ev_add_path (struct path *, struct vectors *);
+int ev_add_path (struct path *, struct vectors *, int);
 int ev_remove_path (struct path *, struct vectors *);
 int ev_add_map (char *, char *, struct vectors *);
 int ev_remove_map (char *, char *, int, struct vectors *);
Signature · 1 line
2.8.1.windows.1
#15 lore raw

PATCH 5/12 multipathd: add need_do_map to indicate whether need calling domap() in ev_remove_path()

In reply to [email protected]

From: tang.junhui <[email protected]>

Usually calling domap() in ev_remove_path() is needed, but only last path need to call domap() in processing for merged uevents to reduce the count of calling domap() and promote efficiency. So add input parameter need_do_map to indicate whether need calling domap() in ev_remove_path().

Change-Id I0a787330a249608396cc3e655465dc820f940539
---
 multipathd/cli_handlers.c |  2 +-
 multipathd/main.c         | 11 +++++++----
 multipathd/main.h         |  2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)
multipathd/cli_handlers.c +1 -1
index 3a46c09..302fd02 100644
@@ -693,7 +693,7 @@ cli_del_path (void * v, char ** reply, int * len, void * data)
 		condlog(0, "%s: path already removed", param);
 		return 1;
 	}
-	return ev_remove_path(pp, vecs);
+	return ev_remove_path(pp, vecs, 1);
 }
 
 int
multipathd/main.c +7 -4
index 34b1b64..68c8e17 100644
@@ -840,7 +840,7 @@ fail:
 }
 
 static int
-uev_remove_path (struct uevent *uev, struct vectors * vecs)
+uev_remove_path (struct uevent *uev, struct vectors * vecs, int need_do_map)
 {
 	struct path *pp;
 	int ret;
@@ -851,7 +851,7 @@ uev_remove_path (struct uevent *uev, struct vectors * vecs)
 	pthread_testcancel();
 	pp = find_path_by_dev(vecs->pathvec, uev->kernel);
 	if (pp)
-		ret = ev_remove_path(pp, vecs);
+		ret = ev_remove_path(pp, vecs, need_do_map);
 	lock_cleanup_pop(vecs->lock);
 	if (!pp) {
 		/* Not an error; path might have been purged earlier */
@@ -862,7 +862,7 @@ uev_remove_path (struct uevent *uev, struct vectors * vecs)
 }
 
 int
-ev_remove_path (struct path *pp, struct vectors * vecs)
+ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
 {
 	struct multipath * mpp;
 	int i, retval = 0;
@@ -884,6 +884,9 @@ ev_remove_path (struct path *pp, struct vectors * vecs)
 		if ((i = find_slot(mpp->paths, (void *)pp)) != -1)
 			vector_del_slot(mpp->paths, i);
 
+		if(!need_do_map)
+			goto out;
+
 		/*
 		 * remove the map IFF removing the last path
 		 */
@@ -1161,7 +1164,7 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 		goto out;
 	}
 	if (!strncmp(uev->action, "remove", 6)) {
-		r = uev_remove_path(uev, vecs);
+		r = uev_remove_path(uev, vecs, 1);
 		goto out;
 	}
 	if (!strncmp(uev->action, "change", 6)) {
multipathd/main.h +1 -1
index f810d41..094b04f 100644
@@ -23,7 +23,7 @@ const char * daemon_status(void);
 int need_to_delay_reconfig (struct vectors *);
 int reconfigure (struct vectors *);
 int ev_add_path (struct path *, struct vectors *, int);
-int ev_remove_path (struct path *, struct vectors *);
+int ev_remove_path (struct path *, struct vectors *, int);
 int ev_add_map (char *, char *, struct vectors *);
 int ev_remove_map (char *, char *, int, struct vectors *);
 void sync_map_state (struct multipath *);
Signature · 1 line
2.8.1.windows.1
#16 lore raw

PATCH 6/12 multipathd: move uev_discard() to uevent.c and change its name to uevent_can_discard()

In reply to [email protected]

From: tang.junhui <[email protected]>

Move uev_discard() form uevent processing thread to uevent listening thread to discard unnecessary uevents as soon as possible.

Change-Id Iaac159ffe3930e53c3325d1069c3ed497e440c0c
---
 libmultipath/uevent.c | 28 ++++++++++++++++++++++++++++
 multipathd/main.c     | 25 -------------------------
 2 files changed, 28 insertions(+), 25 deletions(-)
libmultipath/uevent.c +28 -0
index 181b3b8..ac49cac 100644
@@ -24,6 +24,7 @@
 
 #include <unistd.h>
 #include <stdio.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -80,6 +81,28 @@ struct uevent * alloc_uevent (void)
 	return uev;
 }
 
+bool
+uevent_can_discard(char *devpath)
+{
+	char *tmp;
+	char a[11], b[11];
+
+	/*
+	 * keep only block devices, discard partitions
+	 */
+	tmp = strstr(devpath, "/block/");
+	if (tmp == NULL){
+		condlog(4, "no /block/ in '%s'", devpath);
+		return true;
+	}
+	if (sscanf(tmp, "/block/%10s", a) != 1 ||
+	    sscanf(tmp, "/block/%10[^/]/%10s", a, b) == 2) {
+		condlog(4, "discard event on %s", devpath);
+		return true;
+	}
+	return false;
+}
+
 void
 service_uevq(struct list_head *tmpq)
 {
@@ -527,6 +550,11 @@ int uevent_listen(struct udev *udev)
 			uev = uevent_from_udev_device(dev);
 			if (!uev)
 				continue;
+			if (uevent_can_discard(uev->devpath)) {
+				 udev_device_unref(uev->udev);
+				 FREE(uev);
+				 continue;
+			}
 			list_add_tail(&uev->node, &uevlisten_tmp);
 			events++;
 			continue;
multipathd/main.c +0 -25
index 68c8e17..51f7b60 100644
@@ -1087,28 +1087,6 @@ uxsock_trigger (char * str, char ** reply, int * len, void * trigger_data)
 	return r;
 }
 
-static int
-uev_discard(char * devpath)
-{
-	char *tmp;
-	char a[11], b[11];
-
-	/*
-	 * keep only block devices, discard partitions
-	 */
-	tmp = strstr(devpath, "/block/");
-	if (tmp == NULL){
-		condlog(4, "no /block/ in '%s'", devpath);
-		return 1;
-	}
-	if (sscanf(tmp, "/block/%10s", a) != 1 ||
-	    sscanf(tmp, "/block/%10[^/]/%10s", a, b) == 2) {
-		condlog(4, "discard event on %s", devpath);
-		return 1;
-	}
-	return 0;
-}
-
 int
 uev_trigger (struct uevent * uev, void * trigger_data)
 {
@@ -1118,9 +1096,6 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 
 	vecs = (struct vectors *)trigger_data;
 
-	if (uev_discard(uev->devpath))
-		return 0;
-
 	pthread_cleanup_push(config_cleanup, NULL);
 	pthread_mutex_lock(&config_lock);
 	if (running_state != DAEMON_IDLE &&
Signature · 1 line
2.8.1.windows.1
#17 lore raw

PATCH 7/12 multipathd: move calling filter_devnode() from uev_trigger() to uevent_can_discard()

In reply to [email protected]

From: tang.junhui <[email protected]>

Move calling filter_devnode() from uev_trigger() to uevent_can_discard() since they do the similar work.

Change-Id I0322443fa551b21aa3211bf1ce3fad7d37aeeab4
---
 libmultipath/uevent.c | 25 +++++++++++++++++++++++--
 multipathd/main.c     |  9 ---------
 2 files changed, 23 insertions(+), 11 deletions(-)
libmultipath/uevent.c +23 -2
index ac49cac..cc10d65 100644
@@ -47,6 +47,9 @@
 #include "list.h"
 #include "uevent.h"
 #include "vector.h"
+#include "structs.h"
+#include "config.h"
+#include "blacklist.h"
 
 typedef int (uev_trigger)(struct uevent *, void * trigger_data);
 
@@ -82,10 +85,11 @@ struct uevent * alloc_uevent (void)
 }
 
 bool
-uevent_can_discard(char *devpath)
+uevent_can_discard(char *devpath, char *kernel)
 {
 	char *tmp;
 	char a[11], b[11];
+	struct config * conf;
 
 	/*
 	 * keep only block devices, discard partitions
@@ -100,6 +104,23 @@ uevent_can_discard(char *devpath)
 		condlog(4, "discard event on %s", devpath);
 		return true;
 	}
+
+	/* 
+	 * do not filter dm devices by devnode
+	 */
+	if (!strncmp(kernel, "dm-", 3))
+		return false;
+	/* 
+	 * filter paths devices by devnode
+	 */
+	conf = get_multipath_config();
+	if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
+			   kernel) > 0) {
+		put_multipath_config(conf);
+		return true;
+	}
+	put_multipath_config(conf);
+
 	return false;
 }
 
@@ -550,7 +571,7 @@ int uevent_listen(struct udev *udev)
 			uev = uevent_from_udev_device(dev);
 			if (!uev)
 				continue;
-			if (uevent_can_discard(uev->devpath)) {
+			if (uevent_can_discard(uev->devpath, uev->kernel)) {
 				 udev_device_unref(uev->udev);
 				 FREE(uev);
 				 continue;
multipathd/main.c +0 -9
index 51f7b60..15a6175 100644
@@ -1092,7 +1092,6 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 {
 	int r = 0;
 	struct vectors * vecs;
-	struct config *conf;
 
 	vecs = (struct vectors *)trigger_data;
 
@@ -1126,14 +1125,6 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 	/*
 	 * path add/remove event
 	 */
-	conf = get_multipath_config();
-	if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
-			   uev->kernel) > 0) {
-		put_multipath_config(conf);
-		goto out;
-	}
-	put_multipath_config(conf);
-
 	if (!strncmp(uev->action, "add", 3)) {
 		r = uev_add_path(uev, vecs, 1);
 		goto out;
Signature · 1 line
2.8.1.windows.1
#18 lore raw

PATCH 8/12 libmultipath: wait one seconds for more uevents in uevent_listen() in uevents burst situations

In reply to [email protected]

From: tang.junhui <[email protected]>

The more uevents are merged, the higher efficiency program will performs. So, do not process uevents after receiving immediately in uevents burst situations, but continue wait 1 seconds for more uevents except that too much uevents (2048) have already been received or too much time eclipse (60 seconds).

Change-Id I763d491540e8114a81d12d603281540a81502742
---
 libmultipath/uevent.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
libmultipath/uevent.c +33 -2
index cc10d65..b0b05e9 100644
@@ -39,6 +39,7 @@
 #include <linux/netlink.h>
 #include <pthread.h>
 #include <sys/mman.h>
+#include <sys/time.h>
 #include <libudev.h>
 #include <errno.h>
 
@@ -490,11 +491,37 @@ struct uevent *uevent_from_udev_device(struct udev_device *dev)
 	return uev;
 }
 
+bool uevent_burst(struct timeval *start_time, int events)
+{
+	struct timeval diff_time, end_time;
+	unsigned long speed;
+	unsigned long eclipse_ms;
+
+	gettimeofday(&end_time, NULL);
+	timersub(&end_time, start_time, &diff_time);
+
+	eclipse_ms = diff_time.tv_sec * 1000 + diff_time.tv_usec / 1000;
+	if (eclipse_ms == 0)
+		return true;
+	/* max wait 60s */
+	if (eclipse_ms > 60*1000) {
+		condlog(1, "burst continued =%lu ms, stoped", eclipse_ms);
+		return false;
+	}
+
+	speed = (events * 1000) / eclipse_ms;
+	if (speed > 10)
+		return true;
+
+	return false;
+}
+
 int uevent_listen(struct udev *udev)
 {
 	int err = 2;
 	struct udev_monitor *monitor = NULL;
 	int fd, socket_flags, events;
+	struct timeval start_time;
 	int need_failback = 1;
 	int timeout = 30;
 	LIST_HEAD(uevlisten_tmp);
@@ -548,6 +575,7 @@ int uevent_listen(struct udev *udev)
 	}
 
 	events = 0;
+	gettimeofday(&start_time, NULL);
 	while (1) {
 		struct uevent *uev;
 		struct udev_device *dev;
@@ -562,7 +590,8 @@ int uevent_listen(struct udev *udev)
 		errno = 0;
 		fdcount = poll(&ev_poll, 1, poll_timeout);
 		if (fdcount && ev_poll.revents & POLLIN) {
-			timeout = 0;
+			timeout = uevent_burst(&start_time, events + 1) ? 1:0;
+
 			dev = udev_monitor_receive_device(monitor);
 			if (!dev) {
 				condlog(0, "failed getting udev device");
@@ -578,7 +607,8 @@ int uevent_listen(struct udev *udev)
 			}
 			list_add_tail(&uev->node, &uevlisten_tmp);
 			events++;
-			continue;
+			if(events < 2048)
+				continue;
 		}
 		if (fdcount < 0) {
 			if (errno == EINTR)
@@ -600,6 +630,7 @@ int uevent_listen(struct udev *udev)
 			pthread_mutex_unlock(uevq_lockp);
 			events = 0;
 		}
+		gettimeofday(&start_time, NULL);
 		timeout = 30;
 	}
 	need_failback = 0;
Signature · 1 line
2.8.1.windows.1
#19 lore raw

Re: [PATCH 08/12] libmultipath: wait one seconds for more uevents in uevent_listen() in uevents burst situations

Quoted 11 lines · On Tue, 2016-12-27 at 16:03 +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

The more uevents are merged, the higher efficiency program will performs.
So, do not process uevents after receiving immediately in uevents burst
situations, but continue wait 1 seconds for more uevents except that too
much uevents (2048) have already been received or too much time eclipse
(60 seconds).

Hi Tang,

thanks for this impressive patch set. While I haven't had time to read through the more complex parts yet, one small nitpick on this patch:
please use named constants rather than explicit numbers in the code.

Regards,
Martin

Quoted 98 lines
Change-Id I763d491540e8114a81d12d603281540a81502742

---
 libmultipath/uevent.c | 35 +++++++++++++++++++++++++++++++++--

 1 file changed, 33 insertions(+), 2 deletions(-)
libmultipath/uevent.c +1 -0
index cc10d65..b0b05e9 100644
@@ -39,6 +39,7 @@
  #include <linux/netlink.h>
  #include <pthread.h>
  #include <sys/mman.h>
+#include <sys/time.h>
  #include <libudev.h>
  #include <errno.h>

libmultipath/uevent.c +0 -0
@@ -490,11 +491,37 @@ struct uevent *uevent_from_udev_device(struct
 udev_device *dev)
  	return uev;
  }

libmultipath/uevent.c +10 -0
+bool uevent_burst(struct timeval *start_time, int events)
+{
+	struct timeval diff_time, end_time;
+	unsigned long speed;
+	unsigned long eclipse_ms;
+
+	gettimeofday(&end_time, NULL);
+	timersub(&end_time, start_time, &diff_time);
+
+	eclipse_ms = diff_time.tv_sec * 1000 + diff_time.tv_usec /

1000;

libmultipath/uevent.c +5 -0
+	if (eclipse_ms == 0)
+		return true;
+	/* max wait 60s */
+	if (eclipse_ms > 60*1000) {
+		condlog(1, "burst continued =%lu ms, stoped",

eclipse_ms);

libmultipath/uevent.c +10 -0
+		return false;
+	}
+
+	speed = (events * 1000) / eclipse_ms;
+	if (speed > 10)
+		return true;
+
+	return false;
+}
+

 int uevent_listen(struct udev *udev)
 {
  int err = 2;
  struct udev_monitor *monitor = NULL;
  int fd, socket_flags, events;

libmultipath/uevent.c +1 -0
+	struct timeval start_time;

  int need_failback = 1;
  int timeout = 30;
  LIST_HEAD(uevlisten_tmp);

libmultipath/uevent.c +0 -0
@@ -548,6 +575,7 @@ int uevent_listen(struct udev *udev)
  	}


  events = 0;

libmultipath/uevent.c +1 -0
+	gettimeofday(&start_time, NULL);

  while (1) {
  struct uevent *uev;
  struct udev_device *dev;

libmultipath/uevent.c +2 -1
@@ -562,7 +590,8 @@ int uevent_listen(struct udev *udev)
  		errno = 0;
  		fdcount = poll(&ev_poll, 1, poll_timeout);
  		if (fdcount && ev_poll.revents & POLLIN) {
-			timeout = 0;
+			timeout = uevent_burst(&start_time, events +
 1) ? 1:0;
+
  			dev = udev_monitor_receive_device(monitor);
  			if (!dev) {

  condlog(0, "failed getting udev device");

libmultipath/uevent.c +3 -1
@@ -578,7 +607,8 @@ int uevent_listen(struct udev *udev)
  			}
  			list_add_tail(&uev->node, &uevlisten_tmp);
  			events++;
-			continue;
+			if(events < 2048)
+				continue;
  		}
  		if (fdcount < 0) {
  			if (errno == EINTR)
@@ -600,6 +630,7 @@ int uevent_listen(struct udev *udev)
  			pthread_mutex_unlock(uevq_lockp);
  			events = 0;
  		}
+		gettimeofday(&start_time, NULL);
  		timeout = 30;
  	}
  	need_failback = 0;
Signature · 8 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#20 lore raw

Re: [PATCH 08/12] libmultipath: wait one seconds for more uevents in uevent_listen() in uevents burst situations

Hi Martin,

Thank you for your respond, I will modify it and resend it later.

Regards,
Tang

发件人: Martin Wilck <[email protected]>
收件人: [email protected], [email protected],
[email protected], [email protected], [email protected],
抄送: [email protected], [email protected],
[email protected]
日期: 2016/12/29 04:26
主题: Re: [PATCH 08/12] libmultipath: wait one seconds for more uevents
in uevent_listen() in uevents burst situations

Quoted 11 lines · On Tue, 2016-12-27 at 16:03 +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

The more uevents are merged, the higher efficiency program will performs.
So, do not process uevents after receiving immediately in uevents burst
situations, but continue wait 1 seconds for more uevents except that too
much uevents (2048) have already been received or too much time eclipse
(60 seconds).

Hi Tang,

thanks for this impressive patch set. While I haven't had time to read through the more complex parts yet, one small nitpick on this patch:
please use named constants rather than explicit numbers in the code.

Regards,
Martin

Quoted 24 lines
Change-Id I763d491540e8114a81d12d603281540a81502742
---
 libmultipath/uevent.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
libmultipath/uevent.c +1 -0
index cc10d65..b0b05e9 100644
@@ -39,6 +39,7 @@
 #include <linux/netlink.h>
 #include <pthread.h>
 #include <sys/mman.h>
+#include <sys/time.h>
 #include <libudev.h>
 #include <errno.h>
 
@@ -490,11 +491,37 @@ struct uevent *uevent_from_udev_device(struct
 udev_device *dev)
               return uev;
 }
 

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct · line 504

Quoted 10 lines
libmultipath/uevent.c +10 -0
+bool uevent_burst(struct timeval *start_time, int events)
+{
+              struct timeval diff_time, end_time;
+              unsigned long speed;
+              unsigned long eclipse_ms;
+
+              gettimeofday(&end_time, NULL);
+              timersub(&end_time, start_time, &diff_time);
+
+              eclipse_ms = diff_time.tv_sec * 1000 + diff_time.tv_usec 

/

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct udev_device *dev)

Quoted 6 lines
libmultipath/uevent.c +5 -0
 1000;
+              if (eclipse_ms == 0)
+                              return true;
+              /* max wait 60s */
+              if (eclipse_ms > 60*1000) {
+                              condlog(1, "burst continued =%lu ms, 

stoped",

Quoted 29 lines
libmultipath/uevent.c +11 -0
 eclipse_ms);
+                              return false;
+              }
+
+              speed = (events * 1000) / eclipse_ms;
+              if (speed > 10)
+                              return true;
+
+              return false;
+}
+
 int uevent_listen(struct udev *udev)
 {
               int err = 2;
               struct udev_monitor *monitor = NULL;
               int fd, socket_flags, events;
+              struct timeval start_time;
               int need_failback = 1;
               int timeout = 30;
               LIST_HEAD(uevlisten_tmp);
libmultipath/uevent.c +1 -0
@@ -548,6 +575,7 @@ int uevent_listen(struct udev *udev)
               }
 
               events = 0;
+              gettimeofday(&start_time, NULL);
               while (1) {
                               struct uevent *uev;
                               struct udev_device *dev;

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 591

Quoted 2 lines
libmultipath/uevent.c +0 -0
@@ -562,7 +590,8 @@ int uevent_listen(struct udev *udev)
                               errno = 0;
                               fdcount = poll(&ev_poll, 1, 

poll_timeout);

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 592

Quoted 1 line
libmultipath/uevent.c +0 -0
                               if (fdcount && ev_poll.revents & POLLIN) 

{

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 593

Quoted 2 lines
libmultipath/uevent.c +1 -1
-                                              timeout = 0;
+                                              timeout = 

uevent_burst(&start_time, events +

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 596

Quoted 3 lines
libmultipath/uevent.c +1 -0
 1) ? 1:0;
+
                                               dev = 

udev_monitor_receive_device(monitor);

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 608

Quoted 6 lines
libmultipath/uevent.c +0 -0
                                               if (!dev) {

condlog(0, "failed getting udev
device");

libmultipath/uevent.c +0 -0
@@ -578,7 +607,8 @@ int uevent_listen(struct udev *udev)
                                               }
                                               list_add_tail(&uev->node, 

&uevlisten_tmp);

Quoted 15 lines
libmultipath/uevent.c +3 -1
                                               events++;
-                                              continue;
+                                              if(events < 2048)
+                                                              continue;
                               }
                               if (fdcount < 0) {
                                               if (errno == EINTR)
@@ -600,6 +630,7 @@ int uevent_listen(struct udev *udev)
  pthread_mutex_unlock(uevq_lockp);
                                               events = 0;
                               }
+                              gettimeofday(&start_time, NULL);
                               timeout = 30;
               }
               need_failback = 0;
Signature · 3 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
#21 lore raw

Re: [PATCH 08/12] libmultipath: wait one seconds for more uevents in uevent_listen() in uevents burst situations

In reply to [email protected]
Quoted 7 lines · On Tue, Dec 27, 2016 at 04:03:25PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

The more uevents are merged, the higher efficiency program will performs. So, do not process uevents after receiving immediately in uevents burst situations, but continue wait 1 seconds for more uevents except that too much uevents (2048) have already been received or too much time eclipse (60 seconds).

The issue I have with doing this in uevent_listen is that we seperated receiving the uevents from servicing the uevents specificially to make sure what we received them as fast as possible. The udev monitor code is all based on a NETLINK socket. If our socket's receive buffer fills up, there is no flow control. Events just start getting dropped, which does cut down on processing time, but not in a way we would like.

This issue applies to a lesser extent to you previous two patches. I don't really see the benefit of making sure that we drop the uevents as soon as possible. As long as we don't process them, that should be good enough, right?

Now, maybe you put a lot of thought into your timeouts, and feel confident that we will start processing well before the receive buffer fills up. But if so, some comments on that would be reassuring, because from the commit message, they seem fairly arbitrary to me.

-Ben

Quoted 96 lines
Change-Id I763d491540e8114a81d12d603281540a81502742
---
 libmultipath/uevent.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
libmultipath/uevent.c +33 -2
index cc10d65..b0b05e9 100644
@@ -39,6 +39,7 @@
 #include <linux/netlink.h>
 #include <pthread.h>
 #include <sys/mman.h>
+#include <sys/time.h>
 #include <libudev.h>
 #include <errno.h>
 
@@ -490,11 +491,37 @@ struct uevent *uevent_from_udev_device(struct udev_device *dev)
 	return uev;
 }
 
+bool uevent_burst(struct timeval *start_time, int events)
+{
+	struct timeval diff_time, end_time;
+	unsigned long speed;
+	unsigned long eclipse_ms;
+
+	gettimeofday(&end_time, NULL);
+	timersub(&end_time, start_time, &diff_time);
+
+	eclipse_ms = diff_time.tv_sec * 1000 + diff_time.tv_usec / 1000;
+	if (eclipse_ms == 0)
+		return true;
+	/* max wait 60s */
+	if (eclipse_ms > 60*1000) {
+		condlog(1, "burst continued =%lu ms, stoped", eclipse_ms);
+		return false;
+	}
+
+	speed = (events * 1000) / eclipse_ms;
+	if (speed > 10)
+		return true;
+
+	return false;
+}
+
 int uevent_listen(struct udev *udev)
 {
 	int err = 2;
 	struct udev_monitor *monitor = NULL;
 	int fd, socket_flags, events;
+	struct timeval start_time;
 	int need_failback = 1;
 	int timeout = 30;
 	LIST_HEAD(uevlisten_tmp);
@@ -548,6 +575,7 @@ int uevent_listen(struct udev *udev)
 	}
 
 	events = 0;
+	gettimeofday(&start_time, NULL);
 	while (1) {
 		struct uevent *uev;
 		struct udev_device *dev;
@@ -562,7 +590,8 @@ int uevent_listen(struct udev *udev)
 		errno = 0;
 		fdcount = poll(&ev_poll, 1, poll_timeout);
 		if (fdcount && ev_poll.revents & POLLIN) {
-			timeout = 0;
+			timeout = uevent_burst(&start_time, events + 1) ? 1:0;
+
 			dev = udev_monitor_receive_device(monitor);
 			if (!dev) {
 				condlog(0, "failed getting udev device");
@@ -578,7 +607,8 @@ int uevent_listen(struct udev *udev)
 			}
 			list_add_tail(&uev->node, &uevlisten_tmp);
 			events++;
-			continue;
+			if(events < 2048)
+				continue;
 		}
 		if (fdcount < 0) {
 			if (errno == EINTR)
@@ -600,6 +630,7 @@ int uevent_listen(struct udev *udev)
 			pthread_mutex_unlock(uevq_lockp);
 			events = 0;
 		}
+		gettimeofday(&start_time, NULL);
 		timeout = 30;
 	}
 	need_failback = 0;
Signature · 1 line
2.8.1.windows.1
#22 lore raw

Re: [PATCH 08/12] libmultipath: wait one seconds for more uevents in uevent_listen() in uevents burst situations

Hello Ben,

I know the issue of socket's buffer fills up,
but I think uevent_can_discard() totally process in memory, it is light-weight and low cpu consumption, and it reduce the iteration count in merging, the test result is also good in massive multipath devices scene.

But if you still stick to it, I will revert it to uevents processing thread, and call it in uevent_dispatch() before calling merge_uevq(), actually, I'm going to do that.

Regards
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/04 06:38
主题: Re: [dm-devel] [PATCH 08/12] libmultipath: wait one seconds for
more uevents in uevent_listen() in uevents burst situations 发件人: [email protected]

Quoted 3 lines · On Tue, Dec 27, 2016 at 04:03:25PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

The more uevents are merged, the higher efficiency program will

performs.

Quoted 4 lines

So, do not process uevents after receiving immediately in uevents burst situations, but continue wait 1 seconds for more uevents except that too much uevents (2048) have already been received or too much time eclipse (60 seconds).

The issue I have with doing this in uevent_listen is that we seperated receiving the uevents from servicing the uevents specificially to make sure what we received them as fast as possible. The udev monitor code is all based on a NETLINK socket. If our socket's receive buffer fills up, there is no flow control. Events just start getting dropped, which does cut down on processing time, but not in a way we would like.

This issue applies to a lesser extent to you previous two patches. I don't really see the benefit of making sure that we drop the uevents as soon as possible. As long as we don't process them, that should be good enough, right?

Now, maybe you put a lot of thought into your timeouts, and feel confident that we will start processing well before the receive buffer fills up. But if so, some comments on that would be reassuring, because from the commit message, they seem fairly arbitrary to me.

-Ben

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct

Quoted 20 lines
Change-Id I763d491540e8114a81d12d603281540a81502742
---
 libmultipath/uevent.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
libmultipath/uevent.c +1 -0
index cc10d65..b0b05e9 100644
@@ -39,6 +39,7 @@
 #include <linux/netlink.h>
 #include <pthread.h>
 #include <sys/mman.h>
+#include <sys/time.h>
 #include <libudev.h>
 #include <errno.h>
 
@@ -490,11 +491,37 @@ struct uevent *uevent_from_udev_device(struct 

udev_device *dev)

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct udev_device *dev)

Quoted 13 lines
libmultipath/uevent.c +10 -0
               return uev;
 }
 
+bool uevent_burst(struct timeval *start_time, int events)
+{
+              struct timeval diff_time, end_time;
+              unsigned long speed;
+              unsigned long eclipse_ms;
+
+              gettimeofday(&end_time, NULL);
+              timersub(&end_time, start_time, &diff_time);
+
+              eclipse_ms = diff_time.tv_sec * 1000 + diff_time.tv_usec 

/ 1000;

libmultipath/uevent.c struct uevent *uevent_from_udev_device(struct udev_device *dev)

Quoted 5 lines
libmultipath/uevent.c +5 -0
+              if (eclipse_ms == 0)
+                              return true;
+              /* max wait 60s */
+              if (eclipse_ms > 60*1000) {
+                              condlog(1, "burst continued =%lu ms, 

stoped", eclipse_ms);

Quoted 28 lines
libmultipath/uevent.c +12 -0
+                              return false;
+              }
+
+              speed = (events * 1000) / eclipse_ms;
+              if (speed > 10)
+                              return true;
+
+              return false;
+}
+
 int uevent_listen(struct udev *udev)
 {
               int err = 2;
               struct udev_monitor *monitor = NULL;
               int fd, socket_flags, events;
+              struct timeval start_time;
               int need_failback = 1;
               int timeout = 30;
               LIST_HEAD(uevlisten_tmp);
@@ -548,6 +575,7 @@ int uevent_listen(struct udev *udev)
               }
 
               events = 0;
+              gettimeofday(&start_time, NULL);
               while (1) {
                               struct uevent *uev;
                               struct udev_device *dev;

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 591

Quoted 2 lines
libmultipath/uevent.c +0 -0
@@ -562,7 +590,8 @@ int uevent_listen(struct udev *udev)
                               errno = 0;
                               fdcount = poll(&ev_poll, 1, 

poll_timeout);

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 592

Quoted 1 line
libmultipath/uevent.c +0 -0
                               if (fdcount && ev_poll.revents & POLLIN) 

{

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 593

Quoted 2 lines
libmultipath/uevent.c +1 -1
-                                              timeout = 0;
+                                              timeout = 

uevent_burst(&start_time, events + 1) ? 1:0;

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 595

Quoted 2 lines
libmultipath/uevent.c +1 -0
+
                                               dev = 

udev_monitor_receive_device(monitor);

libmultipath/uevent.c int uevent_listen(struct udev *udev) · line 608

Quoted 5 lines
libmultipath/uevent.c +0 -0
                                               if (!dev) {
 condlog(0, "failed getting udev device");
@@ -578,7 +607,8 @@ int uevent_listen(struct udev *udev)
                                               }
                                               list_add_tail(&uev->node, 

&uevlisten_tmp);

Quoted 18 lines
libmultipath/uevent.c +3 -1
                                               events++;
-                                              continue;
+                                              if(events < 2048)
+                                                              continue;
                               }
                               if (fdcount < 0) {
                                               if (errno == EINTR)
@@ -600,6 +630,7 @@ int uevent_listen(struct udev *udev)
 pthread_mutex_unlock(uevq_lockp);
                                               events = 0;
                               }
+                              gettimeofday(&start_time, NULL);
                               timeout = 30;
               }
               need_failback = 0;
Signature · 1 line
2.8.1.windows.1

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#23 lore raw

PATCH 9/12 multipathd: merge uevents before proccessing

In reply to [email protected]

From: tang.junhui <[email protected]>

These uevents are going to be merged:
1) uevents come from paths and
2) uevents type is same and
3) uevents type is addition or deletion and
4) uevents wwid is same.

Change-Id I05ee057391c092aa0c5f989b7a4f9cb550bb4d98
---
 libmultipath/uevent.c | 125 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 114 insertions(+), 11 deletions(-)
libmultipath/uevent.c +114 -11
index b0b05e9..114068c 100644
@@ -85,6 +85,20 @@ struct uevent * alloc_uevent (void)
 	return uev;
 }
 
+void
+uevq_cleanup(struct list_head *tmpq)
+{
+	struct uevent *uev, *tmp;
+
+	list_for_each_entry_safe(uev, tmp, tmpq, node) {
+		list_del_init(&uev->node);
+
+		if (uev->udev)
+			udev_device_unref(uev->udev);
+		FREE(uev);
+	}
+}
+
 bool
 uevent_can_discard(char *devpath, char *kernel)
 {
@@ -125,6 +139,103 @@ uevent_can_discard(char *devpath, char *kernel)
 	return false;
 }
 
+bool
+merge_need_stop(struct uevent *earlier, struct uevent *later)
+{
+	/*
+	 * dm uevent do not try to merge with left uevents
+	 */
+	if (!strncmp(later->kernel, "dm-", 3))
+		return true;
+
+	/*
+	 * we can not make a jugement without wwid,
+	 * so it is sensible to stop merging
+	 */
+	if (!earlier->wwid || !later->wwid)
+		return true;
+	/*
+	 * uevents merging stoped
+	 * when we meet an opposite action uevent from the same LUN to AVOID
+	 * "add path1 |remove path1 |add path2 |remove path2 |add path3"
+	 * to merge as "remove path1, path2" and "add path1, path2, path3"
+	 * OR
+	 * "remove path1 |add path1 |remove path2 |add path2 |remove path3"
+	 * to merge as "add path1, path2" and "remove path1, path2, path3"
+	 * SO
+	 * when we meet a non-change uevent from the same LUN
+	 * with the same wwid and different action
+	 * it would be better to stop merging.
+	 */
+	if (!strcmp(earlier->wwid, later->wwid) &&
+	    strcmp(earlier->action, later->action) &&
+	    strcmp(earlier->action, "change") &&
+	    strcmp(later->action, "change"))
+		return true;
+
+	return false;
+}
+
+bool
+uevent_can_merge(struct uevent *earlier, struct uevent *later)
+{
+	/* merge paths uevents
+	 * whose wwids exsit and are same
+	 * and actions are same,
+	 * and actions are addition or deletion
+	 */
+	if (earlier->wwid && later->wwid &&
+	    !strcmp(earlier->wwid, later->wwid) &&
+	    !strcmp(earlier->action, later->action) &&
+	    strncmp(earlier->action, "change", 6) &&
+	    strncmp(earlier->kernel, "dm-", 3)) {
+		return true;
+	}
+
+	return false;
+}
+
+void
+uevent_merge(struct uevent *later, struct list_head *tmpq)
+{
+	struct uevent *earlier, *temp;
+	/*
+	 * compare the uevent with earlier uevents
+	 */
+	list_for_some_entry_reverse(earlier, &later->node, tmpq, node) {
+next_earlier_node:
+		if (merge_need_stop(earlier, later))
+			break;
+		/*
+		 * try to merge earlier uevents to the later uevent
+		 */
+		if (uevent_can_merge(earlier, later)) {
+			condlog(3, "merged uevent: %s-%s-%s with uevent: %s-%s-%s",
+				earlier->action, earlier->kernel, earlier->wwid,
+				later->action, later->kernel, later->wwid);
+			temp = earlier;
+
+			earlier = list_entry(earlier->node.prev, typeof(struct uevent), node);
+			list_move(&temp->node, &later->merge_node);
+
+			if (earlier ==  list_entry(tmpq, typeof(struct uevent), node))
+				break;
+			else
+				goto next_earlier_node;
+		}
+	}
+}
+
+void
+merge_uevq(struct list_head *tmpq)
+{
+	struct uevent *later;
+
+	list_for_each_entry_reverse(later, tmpq, node) {
+		uevent_merge(later, tmpq);
+	}
+}
+
 void
 service_uevq(struct list_head *tmpq)
 {
@@ -136,6 +247,8 @@ service_uevq(struct list_head *tmpq)
 		if (my_uev_trigger && my_uev_trigger(uev, my_trigger_data))
 			condlog(0, "uevent trigger error");
 
+		uevq_cleanup(&uev->merge_node);
+
 		if (uev->udev)
 			udev_device_unref(uev->udev);
 		FREE(uev);
@@ -150,17 +263,6 @@ static void uevent_cleanup(void *arg)
 	udev_unref(udev);
 }
 
-void
-uevq_cleanup(struct list_head *tmpq)
-{
-	struct uevent *uev, *tmp;
-
-	list_for_each_entry_safe(uev, tmp, tmpq, node) {
-		list_del_init(&uev->node);
-		FREE(uev);
-	}
-}
-
 /*
  * Service the uevent queue.
  */
@@ -189,6 +291,7 @@ int uevent_dispatch(int (*uev_trigger)(struct uevent *, void * trigger_data),
 		pthread_mutex_unlock(uevq_lockp);
 		if (!my_uev_trigger)
 			break;
+		merge_uevq(&uevq_tmp);
 		service_uevq(&uevq_tmp);
 	}
 	condlog(3, "Terminating uev service queue");
Signature · 1 line
2.8.1.windows.1
#24 lore raw

Re: [PATCH 09/12] multipathd: merge uevents before proccessing

Quoted 7 lines · On Tue, Dec 27, 2016 at 04:03:26PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

These uevents are going to be merged:
1) uevents come from paths and
2) uevents type is same and
3) uevents type is addition or deletion and
4) uevents wwid is same.

This is just a nit, and I might be missing something subtle here, but it seems like instead of adding list_for_some_entry_reverse, and then breaking the abstraction to manually get previous entries, you could have just added list_for_some_entry_reverse_safe in your earlier patch, and hid the work of traversing a list while removing elements behind the well understood abstraction of a *_safe list traversal method.

-Ben

Quoted 174 lines
Change-Id I05ee057391c092aa0c5f989b7a4f9cb550bb4d98
---
 libmultipath/uevent.c | 125 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 114 insertions(+), 11 deletions(-)
libmultipath/uevent.c +114 -11
index b0b05e9..114068c 100644
@@ -85,6 +85,20 @@ struct uevent * alloc_uevent (void)
 	return uev;
 }
 
+void
+uevq_cleanup(struct list_head *tmpq)
+{
+	struct uevent *uev, *tmp;
+
+	list_for_each_entry_safe(uev, tmp, tmpq, node) {
+		list_del_init(&uev->node);
+
+		if (uev->udev)
+			udev_device_unref(uev->udev);
+		FREE(uev);
+	}
+}
+
 bool
 uevent_can_discard(char *devpath, char *kernel)
 {
@@ -125,6 +139,103 @@ uevent_can_discard(char *devpath, char *kernel)
 	return false;
 }
 
+bool
+merge_need_stop(struct uevent *earlier, struct uevent *later)
+{
+	/*
+	 * dm uevent do not try to merge with left uevents
+	 */
+	if (!strncmp(later->kernel, "dm-", 3))
+		return true;
+
+	/*
+	 * we can not make a jugement without wwid,
+	 * so it is sensible to stop merging
+	 */
+	if (!earlier->wwid || !later->wwid)
+		return true;
+	/*
+	 * uevents merging stoped
+	 * when we meet an opposite action uevent from the same LUN to AVOID
+	 * "add path1 |remove path1 |add path2 |remove path2 |add path3"
+	 * to merge as "remove path1, path2" and "add path1, path2, path3"
+	 * OR
+	 * "remove path1 |add path1 |remove path2 |add path2 |remove path3"
+	 * to merge as "add path1, path2" and "remove path1, path2, path3"
+	 * SO
+	 * when we meet a non-change uevent from the same LUN
+	 * with the same wwid and different action
+	 * it would be better to stop merging.
+	 */
+	if (!strcmp(earlier->wwid, later->wwid) &&
+	    strcmp(earlier->action, later->action) &&
+	    strcmp(earlier->action, "change") &&
+	    strcmp(later->action, "change"))
+		return true;
+
+	return false;
+}
+
+bool
+uevent_can_merge(struct uevent *earlier, struct uevent *later)
+{
+	/* merge paths uevents
+	 * whose wwids exsit and are same
+	 * and actions are same,
+	 * and actions are addition or deletion
+	 */
+	if (earlier->wwid && later->wwid &&
+	    !strcmp(earlier->wwid, later->wwid) &&
+	    !strcmp(earlier->action, later->action) &&
+	    strncmp(earlier->action, "change", 6) &&
+	    strncmp(earlier->kernel, "dm-", 3)) {
+		return true;
+	}
+
+	return false;
+}
+
+void
+uevent_merge(struct uevent *later, struct list_head *tmpq)
+{
+	struct uevent *earlier, *temp;
+	/*
+	 * compare the uevent with earlier uevents
+	 */
+	list_for_some_entry_reverse(earlier, &later->node, tmpq, node) {
+next_earlier_node:
+		if (merge_need_stop(earlier, later))
+			break;
+		/*
+		 * try to merge earlier uevents to the later uevent
+		 */
+		if (uevent_can_merge(earlier, later)) {
+			condlog(3, "merged uevent: %s-%s-%s with uevent: %s-%s-%s",
+				earlier->action, earlier->kernel, earlier->wwid,
+				later->action, later->kernel, later->wwid);
+			temp = earlier;
+
+			earlier = list_entry(earlier->node.prev, typeof(struct uevent), node);
+			list_move(&temp->node, &later->merge_node);
+
+			if (earlier ==  list_entry(tmpq, typeof(struct uevent), node))
+				break;
+			else
+				goto next_earlier_node;
+		}
+	}
+}
+
+void
+merge_uevq(struct list_head *tmpq)
+{
+	struct uevent *later;
+
+	list_for_each_entry_reverse(later, tmpq, node) {
+		uevent_merge(later, tmpq);
+	}
+}
+
 void
 service_uevq(struct list_head *tmpq)
 {
@@ -136,6 +247,8 @@ service_uevq(struct list_head *tmpq)
 		if (my_uev_trigger && my_uev_trigger(uev, my_trigger_data))
 			condlog(0, "uevent trigger error");
 
+		uevq_cleanup(&uev->merge_node);
+
 		if (uev->udev)
 			udev_device_unref(uev->udev);
 		FREE(uev);
@@ -150,17 +263,6 @@ static void uevent_cleanup(void *arg)
 	udev_unref(udev);
 }
 
-void
-uevq_cleanup(struct list_head *tmpq)
-{
-	struct uevent *uev, *tmp;
-
-	list_for_each_entry_safe(uev, tmp, tmpq, node) {
-		list_del_init(&uev->node);
-		FREE(uev);
-	}
-}
-
 /*
  * Service the uevent queue.
  */
@@ -189,6 +291,7 @@ int uevent_dispatch(int (*uev_trigger)(struct uevent *, void * trigger_data),
 		pthread_mutex_unlock(uevq_lockp);
 		if (!my_uev_trigger)
 			break;
+		merge_uevq(&uevq_tmp);
 		service_uevq(&uevq_tmp);
 	}
 	condlog(3, "Terminating uev service queue");
Signature · 1 line
2.8.1.windows.1
#25 lore raw

Re: [PATCH 09/12] multipathd: merge uevents before proccessing

Hello Ben,

Yes, a *_safe list traversal method can meet the needs, I will modify it and simplify the codes.

Thanks,
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/04 08:39
主题: Re: [dm-devel] [PATCH 09/12] multipathd: merge uevents before
proccessing
发件人: [email protected]

Quoted 7 lines · On Tue, Dec 27, 2016 at 04:03:26PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

These uevents are going to be merged:
1) uevents come from paths and
2) uevents type is same and
3) uevents type is addition or deletion and
4) uevents wwid is same.

This is just a nit, and I might be missing something subtle here, but it seems like instead of adding list_for_some_entry_reverse, and then breaking the abstraction to manually get previous entries, you could have just added list_for_some_entry_reverse_safe in your earlier patch, and hid the work of traversing a list while removing elements behind the well understood abstraction of a *_safe list traversal method.

-Ben

Quoted 5 lines
Change-Id I05ee057391c092aa0c5f989b7a4f9cb550bb4d98
---
 libmultipath/uevent.c | 125 

+++++++++++++++++++++++++++++++++++++++++++++-----

Quoted 39 lines
 1 file changed, 114 insertions(+), 11 deletions(-)
libmultipath/uevent.c +22 -0
index b0b05e9..114068c 100644
@@ -85,6 +85,20 @@ struct uevent * alloc_uevent (void)
               return uev;
 }
 
+void
+uevq_cleanup(struct list_head *tmpq)
+{
+              struct uevent *uev, *tmp;
+
+              list_for_each_entry_safe(uev, tmp, tmpq, node) {
+                              list_del_init(&uev->node);
+
+                              if (uev->udev)
+ udev_device_unref(uev->udev);
+                              FREE(uev);
+              }
+}
+
 bool
 uevent_can_discard(char *devpath, char *kernel)
 {
@@ -125,6 +139,103 @@ uevent_can_discard(char *devpath, char *kernel)
               return false;
 }
 
+bool
+merge_need_stop(struct uevent *earlier, struct uevent *later)
+{
+              /*
+               * dm uevent do not try to merge with left uevents
+               */
+              if (!strncmp(later->kernel, "dm-", 3))
+                              return true;

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 159

Quoted 10 lines
libmultipath/uevent.c +10 -0
+
+              /*
+               * we can not make a jugement without wwid,
+               * so it is sensible to stop merging
+               */
+              if (!earlier->wwid || !later->wwid)
+                              return true;
+              /*
+               * uevents merging stoped
+               * when we meet an opposite action uevent from the same 

LUN to AVOID

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 160

Quoted 1 line
libmultipath/uevent.c +1 -0
+               * "add path1 |remove path1 |add path2 |remove path2 |add 

path3"

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 161

Quoted 1 line
libmultipath/uevent.c +1 -0
+               * to merge as "remove path1, path2" and "add path1, 

path2, path3"

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 163

Quoted 2 lines
libmultipath/uevent.c +2 -0
+               * OR
+               * "remove path1 |add path1 |remove path2 |add path2 

|remove path3"

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 164

Quoted 1 line
libmultipath/uevent.c +1 -0
+               * to merge as "add path1, path2" and "remove path1, 

path2, path3"

Quoted 31 lines
libmultipath/uevent.c +31 -0
+               * SO
+               * when we meet a non-change uevent from the same LUN
+               * with the same wwid and different action
+               * it would be better to stop merging.
+               */
+              if (!strcmp(earlier->wwid, later->wwid) &&
+                  strcmp(earlier->action, later->action) &&
+                  strcmp(earlier->action, "change") &&
+                  strcmp(later->action, "change"))
+                              return true;
+
+              return false;
+}
+
+bool
+uevent_can_merge(struct uevent *earlier, struct uevent *later)
+{
+              /* merge paths uevents
+               * whose wwids exsit and are same
+               * and actions are same,
+               * and actions are addition or deletion
+               */
+              if (earlier->wwid && later->wwid &&
+                  !strcmp(earlier->wwid, later->wwid) &&
+                  !strcmp(earlier->action, later->action) &&
+                  strncmp(earlier->action, "change", 6) &&
+                  strncmp(earlier->kernel, "dm-", 3)) {
+                              return true;
+              }
+
+              return false;

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel)

Quoted 10 lines
libmultipath/uevent.c +10 -0
+}
+
+void
+uevent_merge(struct uevent *later, struct list_head *tmpq)
+{
+              struct uevent *earlier, *temp;
+              /*
+               * compare the uevent with earlier uevents
+               */
+              list_for_some_entry_reverse(earlier, &later->node, tmpq, 

node) {

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel)

Quoted 5 lines
libmultipath/uevent.c +5 -0
+next_earlier_node:
+                              if (merge_need_stop(earlier, later))
+                                              break;
+                              /*
+                               * try to merge earlier uevents to the 

later uevent

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel)

Quoted 3 lines
libmultipath/uevent.c +3 -0
+                               */
+                              if (uevent_can_merge(earlier, later)) {
+                                              condlog(3, "merged 

uevent: %s-%s-%s with uevent: %s-%s-%s",

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel)

Quoted 5 lines
libmultipath/uevent.c +5 -0
+ earlier->action, earlier->kernel, earlier->wwid,
+ later->action, later->kernel, later->wwid);
+                                              temp = earlier;
+
+                                              earlier = 

list_entry(earlier->node.prev, typeof(struct uevent), node);

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 219

Quoted 1 line
libmultipath/uevent.c +1 -0
+                                              list_move(&temp->node, 

&later->merge_node);

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 221

Quoted 2 lines
libmultipath/uevent.c +2 -0
+
+                                              if (earlier == 

list_entry(tmpq, typeof(struct uevent), node))

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel)

Quoted 3 lines
libmultipath/uevent.c +3 -0
+                                                              break;
+                                              else
+                                                              goto 

next_earlier_node;

Quoted 18 lines
libmultipath/uevent.c +14 -0
+                              }
+              }
+}
+
+void
+merge_uevq(struct list_head *tmpq)
+{
+              struct uevent *later;
+
+              list_for_each_entry_reverse(later, tmpq, node) {
+                              uevent_merge(later, tmpq);
+              }
+}
+
 void
 service_uevq(struct list_head *tmpq)
 {

libmultipath/uevent.c service_uevq(struct list_head *tmpq) · line 247

Quoted 1 line
libmultipath/uevent.c +0 -0
@@ -136,6 +247,8 @@ service_uevq(struct list_head *tmpq)
                               if (my_uev_trigger && my_uev_trigger(uev, 

my_trigger_data))

libmultipath/uevent.c service_uevq(struct list_head *tmpq) · line 248

Quoted 1 line
libmultipath/uevent.c +0 -0
                                               condlog(0, "uevent 

trigger error");

libmultipath/uevent.c int uevent_dispatch(int (*uev_trigger)(struct uevent

Quoted 25 lines
libmultipath/uevent.c +2 -11
+                              uevq_cleanup(&uev->merge_node);
+
                               if (uev->udev)
 udev_device_unref(uev->udev);
                               FREE(uev);
@@ -150,17 +263,6 @@ static void uevent_cleanup(void *arg)
               udev_unref(udev);
 }
 
-void
-uevq_cleanup(struct list_head *tmpq)
-{
-              struct uevent *uev, *tmp;
-
-              list_for_each_entry_safe(uev, tmp, tmpq, node) {
-                              list_del_init(&uev->node);
-                              FREE(uev);
-              }
-}
-
 /*
  * Service the uevent queue.
  */
@@ -189,6 +291,7 @@ int uevent_dispatch(int (*uev_trigger)(struct uevent 

*, void * trigger_data),

Quoted 10 lines
libmultipath/uevent.c +1 -0
                               pthread_mutex_unlock(uevq_lockp);
                               if (!my_uev_trigger)
                                               break;
+                              merge_uevq(&uevq_tmp);
                               service_uevq(&uevq_tmp);
               }
               condlog(3, "Terminating uev service queue");
Signature · 1 line
2.8.1.windows.1

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#26 lore raw

PATCH 10/12 libmultipath: filter uevents before proccessing

In reply to [email protected]

From: tang.junhui <[email protected]>

Before merging uevents, these uevents are going to be filtered:
Change or addition uevent of a removed path (it indicate by an deletion uevent occurred later).

Change-Id If00c2c2e23ea466c1d4643c541ed2d8f9a0c8dea
---
 libmultipath/uevent.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
libmultipath/uevent.c +55 -0
index 114068c..424f272 100644
@@ -140,6 +140,28 @@ uevent_can_discard(char *devpath, char *kernel)
 }
 
 bool
+uevent_can_filter(struct uevent *earlier, struct uevent *later)
+{
+
+	/*
+	 * filter earlier uvents if path has removed later, eg:
+	 * "add path3 |chang path3 |add path2 |remove path3"
+	 * can filter as:
+	 * "add path2 |remove path3"
+	 * uevent "add path3" and "chang path3" are filtered out
+	 */
+	if (earlier->wwid && later->wwid &&
+		!strcmp(earlier->wwid, later->wwid) &&
+		strncmp(later->kernel, "dm-", 3) &&
+		!strcmp(later->action, "remove") &&
+		!strcmp(earlier->kernel, later->kernel)) {
+		return true;
+	}
+
+	return false;
+}
+
+bool
 merge_need_stop(struct uevent *earlier, struct uevent *later)
 {
 	/*
@@ -196,6 +218,38 @@ uevent_can_merge(struct uevent *earlier, struct uevent *later)
 }
 
 void
+uevent_filter(struct uevent *later, struct list_head *tmpq)
+{
+	struct uevent *earlier, *temp;
+	/*
+	 * compare the uevent with earlier uevents
+	 */
+	list_for_some_entry_reverse(earlier, &later->node, tmpq, node) {
+next_earlier_node:
+		/*
+		 * filter unnessary earlier uevents by the later uevent
+		 */
+		if (uevent_can_filter(earlier, later)) {
+			condlog(2, "uevent: %s-%s-%s has removed by uevent: %s-%s-%s, filtered",
+				earlier->action, earlier->kernel, earlier->wwid,
+				later->action, later->kernel, later->wwid);
+
+			temp = earlier;
+			earlier = list_entry(earlier->node.prev, typeof(struct uevent), node);
+			list_del_init(&temp->node);
+			if (temp->udev)
+				udev_device_unref(temp->udev);
+			FREE(temp);
+
+			if (earlier ==  list_entry(tmpq, typeof(struct uevent), node))
+				break;
+			else
+				goto next_earlier_node;
+		}
+	}
+}
+
+void
 uevent_merge(struct uevent *later, struct list_head *tmpq)
 {
 	struct uevent *earlier, *temp;
@@ -232,6 +286,7 @@ merge_uevq(struct list_head *tmpq)
 	struct uevent *later;
 
 	list_for_each_entry_reverse(later, tmpq, node) {
+		uevent_filter(later, tmpq);
 		uevent_merge(later, tmpq);
 	}
 }
Signature · 1 line
2.8.1.windows.1
#27 lore raw

Re: [PATCH 10/12] libmultipath: filter uevents before proccessing

Quoted 6 lines · On Tue, Dec 27, 2016 at 04:03:27PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

Before merging uevents, these uevents are going to be filtered:
Change or addition uevent of a removed path (it indicate by an deletion uevent occurred later).

I think it's safe to remove add and change uevents if they are followed by a remove event, regardless of whether or not they have a wwid, as long as the kernel name is the same. We only get the remove event when the device is gone. Processing the add and change events will never get us anything in these cases, because there is no device to act on.

-Ben

Quoted 89 lines
Change-Id If00c2c2e23ea466c1d4643c541ed2d8f9a0c8dea
---
 libmultipath/uevent.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
libmultipath/uevent.c +55 -0
index 114068c..424f272 100644
@@ -140,6 +140,28 @@ uevent_can_discard(char *devpath, char *kernel)
 }
 
 bool
+uevent_can_filter(struct uevent *earlier, struct uevent *later)
+{
+
+	/*
+	 * filter earlier uvents if path has removed later, eg:
+	 * "add path3 |chang path3 |add path2 |remove path3"
+	 * can filter as:
+	 * "add path2 |remove path3"
+	 * uevent "add path3" and "chang path3" are filtered out
+	 */
+	if (earlier->wwid && later->wwid &&
+		!strcmp(earlier->wwid, later->wwid) &&
+		strncmp(later->kernel, "dm-", 3) &&
+		!strcmp(later->action, "remove") &&
+		!strcmp(earlier->kernel, later->kernel)) {
+		return true;
+	}
+
+	return false;
+}
+
+bool
 merge_need_stop(struct uevent *earlier, struct uevent *later)
 {
 	/*
@@ -196,6 +218,38 @@ uevent_can_merge(struct uevent *earlier, struct uevent *later)
 }
 
 void
+uevent_filter(struct uevent *later, struct list_head *tmpq)
+{
+	struct uevent *earlier, *temp;
+	/*
+	 * compare the uevent with earlier uevents
+	 */
+	list_for_some_entry_reverse(earlier, &later->node, tmpq, node) {
+next_earlier_node:
+		/*
+		 * filter unnessary earlier uevents by the later uevent
+		 */
+		if (uevent_can_filter(earlier, later)) {
+			condlog(2, "uevent: %s-%s-%s has removed by uevent: %s-%s-%s, filtered",
+				earlier->action, earlier->kernel, earlier->wwid,
+				later->action, later->kernel, later->wwid);
+
+			temp = earlier;
+			earlier = list_entry(earlier->node.prev, typeof(struct uevent), node);
+			list_del_init(&temp->node);
+			if (temp->udev)
+				udev_device_unref(temp->udev);
+			FREE(temp);
+
+			if (earlier ==  list_entry(tmpq, typeof(struct uevent), node))
+				break;
+			else
+				goto next_earlier_node;
+		}
+	}
+}
+
+void
 uevent_merge(struct uevent *later, struct list_head *tmpq)
 {
 	struct uevent *earlier, *temp;
@@ -232,6 +286,7 @@ merge_uevq(struct list_head *tmpq)
 	struct uevent *later;
 
 	list_for_each_entry_reverse(later, tmpq, node) {
+		uevent_filter(later, tmpq);
 		uevent_merge(later, tmpq);
 	}
 }
Signature · 1 line
2.8.1.windows.1
#28 lore raw

Re: [PATCH 10/12] libmultipath: filter uevents before proccessing

Hello Ben,

I add wwid judgment for safe.
I think twice, and as you say, it is safe enough without this judgment, I will delete these wwid judgment.

Tanks
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/04 09:28
主题: Re: [dm-devel] [PATCH 10/12] libmultipath: filter uevents before
proccessing
发件人: [email protected]

Quoted 6 lines · On Tue, Dec 27, 2016 at 04:03:27PM +0800, [email protected] wrote:

From: tang.junhui <[email protected]>

Before merging uevents, these uevents are going to be filtered:
Change or addition uevent of a removed path (it indicate by an deletion uevent occurred later).

I think it's safe to remove add and change uevents if they are followed by a remove event, regardless of whether or not they have a wwid, as long as the kernel name is the same. We only get the remove event when the device is gone. Processing the add and change events will never get us anything in these cases, because there is no device to act on.

-Ben

Quoted 4 lines
Change-Id If00c2c2e23ea466c1d4643c541ed2d8f9a0c8dea
---
 libmultipath/uevent.c | 55 

+++++++++++++++++++++++++++++++++++++++++++++++++++

Quoted 15 lines
 1 file changed, 55 insertions(+)
libmultipath/uevent.c +5 -0
index 114068c..424f272 100644
@@ -140,6 +140,28 @@ uevent_can_discard(char *devpath, char *kernel)
 }
 
 bool
+uevent_can_filter(struct uevent *earlier, struct uevent *later)
+{
+
+              /*
+               * filter earlier uvents if path has removed later, eg:

libmultipath/uevent.c uevent_can_discard(char *devpath, char *kernel) · line 157

Quoted 10 lines
libmultipath/uevent.c +10 -0
+               * "add path3 |chang path3 |add path2 |remove path3"
+               * can filter as:
+               * "add path2 |remove path3"
+               * uevent "add path3" and "chang path3" are filtered out
+               */
+              if (earlier->wwid && later->wwid &&
+                              !strcmp(earlier->wwid, later->wwid) &&
+                              strncmp(later->kernel, "dm-", 3) &&
+                              !strcmp(later->action, "remove") &&
+                              !strcmp(earlier->kernel, later->kernel)) 

{

libmultipath/uevent.c uevent_can_merge(struct uevent *earlier, struct

Quoted 11 lines
libmultipath/uevent.c +7 -0
+                              return true;
+              }
+
+              return false;
+}
+
+bool
 merge_need_stop(struct uevent *earlier, struct uevent *later)
 {
               /*
@@ -196,6 +218,38 @@ uevent_can_merge(struct uevent *earlier, struct 

uevent *later)

libmultipath/uevent.c uevent_can_merge(struct uevent *earlier, struct uevent *later)

Quoted 10 lines
libmultipath/uevent.c +7 -0
 }
 
 void
+uevent_filter(struct uevent *later, struct list_head *tmpq)
+{
+              struct uevent *earlier, *temp;
+              /*
+               * compare the uevent with earlier uevents
+               */
+              list_for_some_entry_reverse(earlier, &later->node, tmpq, 

node) {

libmultipath/uevent.c uevent_can_merge(struct uevent *earlier, struct uevent *later)

Quoted 3 lines
libmultipath/uevent.c +3 -0
+next_earlier_node:
+                              /*
+                               * filter unnessary earlier uevents by 

the later uevent

libmultipath/uevent.c uevent_can_merge(struct uevent *earlier, struct uevent *later)

Quoted 3 lines
libmultipath/uevent.c +3 -0
+                               */
+                              if (uevent_can_filter(earlier, later)) {
+                                              condlog(2, "uevent: 

%s-%s-%s has removed by uevent: %s-%s-%s, filtered",

libmultipath/uevent.c uevent_can_merge(struct uevent *earlier, struct uevent *later)

Quoted 5 lines
libmultipath/uevent.c +5 -0
+ earlier->action, earlier->kernel, earlier->wwid,
+ later->action, later->kernel, later->wwid);
+
+                                              temp = earlier;
+                                              earlier = 

list_entry(earlier->node.prev, typeof(struct uevent), node);

libmultipath/uevent.c uevent_can_merge(struct uevent *earlier, struct uevent *later)

Quoted 6 lines
libmultipath/uevent.c +6 -0
+ list_del_init(&temp->node);
+                                              if (temp->udev)
+ udev_device_unref(temp->udev);
+                                              FREE(temp);
+
+                                              if (earlier == 

list_entry(tmpq, typeof(struct uevent), node))

libmultipath/uevent.c uevent_can_merge(struct uevent *earlier, struct uevent *later)

Quoted 3 lines
libmultipath/uevent.c +3 -0
+                                                              break;
+                                              else
+                                                              goto 

next_earlier_node;

Quoted 19 lines
libmultipath/uevent.c +6 -0
+                              }
+              }
+}
+
+void
 uevent_merge(struct uevent *later, struct list_head *tmpq)
 {
               struct uevent *earlier, *temp;
@@ -232,6 +286,7 @@ merge_uevq(struct list_head *tmpq)
               struct uevent *later;
 
               list_for_each_entry_reverse(later, tmpq, node) {
+                              uevent_filter(later, tmpq);
                               uevent_merge(later, tmpq);
               }
 }
Signature · 1 line
2.8.1.windows.1

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#29 lore raw

PATCH 11/12 multipathd: proccess merged uevents

In reply to [email protected]

From: "tang.junhui" <[email protected]>

After filtering and merging, then uevents are processed in uev_trigger(), firstly, each of merged uevents would be processed one by one with need_do_map in value of 0. Finally, the node “uev” itself would be processed with need_do_map in value of 1, which would reload kernel table, and create or remove the dm device.

Change-Id Ifb4de0ca36180a8af16729c2f70bc250858877bd
---
 multipathd/main.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
multipathd/main.c +15 -13
index 15a6175..0b18f6c 100644
@@ -1092,6 +1092,7 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 {
 	int r = 0;
 	struct vectors * vecs;
+	struct uevent *merge_uev, *tmp;
 
 	vecs = (struct vectors *)trigger_data;
 
@@ -1123,20 +1124,21 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 	}
 
 	/*
-	 * path add/remove event
+	 * path add/remove/change event, add/remove maybe merged
 	 */
-	if (!strncmp(uev->action, "add", 3)) {
-		r = uev_add_path(uev, vecs, 1);
-		goto out;
-	}
-	if (!strncmp(uev->action, "remove", 6)) {
-		r = uev_remove_path(uev, vecs, 1);
-		goto out;
-	}
-	if (!strncmp(uev->action, "change", 6)) {
-		r = uev_update_path(uev, vecs);
-		goto out;
-	}
+	list_for_each_entry_safe(merge_uev, tmp, &uev->merge_node, node) {
+		if (!strncmp(merge_uev->action, "add", 3))
+			r += uev_add_path(merge_uev, vecs, 0);
+		if (!strncmp(merge_uev->action, "remove", 6))
+			r += uev_remove_path(merge_uev, vecs, 0);
+	}
+
+	if (!strncmp(uev->action, "add", 3))
+		r += uev_add_path(uev, vecs, 1);
+	if (!strncmp(uev->action, "remove", 6))
+		r += uev_remove_path(uev, vecs, 1);
+	if (!strncmp(uev->action, "change", 6))
+		r += uev_update_path(uev, vecs);
 
 out:
 	return r;
Signature · 8 lines
2.8.1.windows.1



--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#30 lore raw

Re: [PATCH 11/12] multipathd: proccess merged uevents

Quoted 7 lines · On Tue, Dec 27, 2016 at 04:03:28PM +0800, [email protected] wrote:

From: "tang.junhui" <[email protected]>

After filtering and merging, then uevents are processed in uev_trigger(), firstly, each of merged uevents would be processed one by one with need_do_map in value of 0. Finally, the node “uev” itself would be processed with need_do_map in value of 1, which would reload kernel table, and create or remove the dm device.

Wait, doesn't this mean that you would change

"add path1 | change path1 | add path2"

to

"change path1 | add path1, path2"

It doesn't make sense to process a change event before an add event. Looking at uev_update_path, the three things it currently does all can be safely ignored if you don't process the add event until after you receive the change event. They are:

disable path on changed wwid: the multipath device hasn't been created yet, so it will simply be created with the new wwid. That's fine.

attempt to get the pathinfo again if you failed when adding it: Either you don't have the necessary udev information in the add event, in which case that uevent won't get merged in the first place and they will remain in order, or you do have the information, and there's no point in processing the change event in that case.

change the Read-Only state of the device: since both events (the change and the add event) have already happened, when you look at the device for the add event, you will already get the current read-only state.

So, as far as I can tell, if you have change events in your queue as well as an add event for the same device, you might as well just filter out the change events, since processing it immediately after the add event will never actually change anything, and processing it beforehand makes no sense.

-Ben

Quoted 57 lines
Change-Id Ifb4de0ca36180a8af16729c2f70bc250858877bd
---
 multipathd/main.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
multipathd/main.c +15 -13
index 15a6175..0b18f6c 100644
@@ -1092,6 +1092,7 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 {
 	int r = 0;
 	struct vectors * vecs;
+	struct uevent *merge_uev, *tmp;
 
 	vecs = (struct vectors *)trigger_data;
 
@@ -1123,20 +1124,21 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 	}
 
 	/*
-	 * path add/remove event
+	 * path add/remove/change event, add/remove maybe merged
 	 */
-	if (!strncmp(uev->action, "add", 3)) {
-		r = uev_add_path(uev, vecs, 1);
-		goto out;
-	}
-	if (!strncmp(uev->action, "remove", 6)) {
-		r = uev_remove_path(uev, vecs, 1);
-		goto out;
-	}
-	if (!strncmp(uev->action, "change", 6)) {
-		r = uev_update_path(uev, vecs);
-		goto out;
-	}
+	list_for_each_entry_safe(merge_uev, tmp, &uev->merge_node, node) {
+		if (!strncmp(merge_uev->action, "add", 3))
+			r += uev_add_path(merge_uev, vecs, 0);
+		if (!strncmp(merge_uev->action, "remove", 6))
+			r += uev_remove_path(merge_uev, vecs, 0);
+	}
+
+	if (!strncmp(uev->action, "add", 3))
+		r += uev_add_path(uev, vecs, 1);
+	if (!strncmp(uev->action, "remove", 6))
+		r += uev_remove_path(uev, vecs, 1);
+	if (!strncmp(uev->action, "change", 6))
+		r += uev_update_path(uev, vecs);
 
 out:
 	return r;
Signature · 1 line
2.8.1.windows.1

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#31 lore raw

Re: [PATCH 11/12] multipathd: proccess merged uevents

Hello Ben

Good idea,
I will modify the patch to filter these change uevents.

Thanks
Tang Junhui

发件人: "Benjamin Marzinski" <[email protected]>
收件人: [email protected],
抄送: [email protected], [email protected],
[email protected], [email protected], [email protected]
日期: 2017/01/04 09:10
主题: Re: [dm-devel] [PATCH 11/12] multipathd: proccess merged uevents
发件人: [email protected]

Quoted 7 lines · On Tue, Dec 27, 2016 at 04:03:28PM +0800, [email protected] wrote:

From: "tang.junhui" <[email protected]>

After filtering and merging, then uevents are processed in uev_trigger(), firstly, each of merged uevents would be processed one by one with need_do_map in value of 0. Finally, the node “uev” itself would be processed with need_do_map in value of 1, which would reload kernel table, and create or remove the dm device.

Wait, doesn't this mean that you would change

"add path1 | change path1 | add path2"

to

"change path1 | add path1, path2"

It doesn't make sense to process a change event before an add event. Looking at uev_update_path, the three things it currently does all can be safely ignored if you don't process the add event until after you receive the change event. They are:

disable path on changed wwid: the multipath device hasn't been created yet, so it will simply be created with the new wwid. That's fine.

attempt to get the pathinfo again if you failed when adding it: Either you don't have the necessary udev information in the add event, in which case that uevent won't get merged in the first place and they will remain in order, or you do have the information, and there's no point in processing the change event in that case.

change the Read-Only state of the device: since both events (the change and the add event) have already happened, when you look at the device for the add event, you will already get the current read-only state.

So, as far as I can tell, if you have change events in your queue as well as an add event for the same device, you might as well just filter out the change events, since processing it immediately after the add event will never actually change anything, and processing it beforehand makes no sense.

-Ben

multipathd/main.c uev_trigger (struct uevent * uev, void *

Quoted 12 lines
Change-Id Ifb4de0ca36180a8af16729c2f70bc250858877bd
---
 multipathd/main.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
multipathd/main.c +0 -0
index 15a6175..0b18f6c 100644
@@ -1092,6 +1092,7 @@ uev_trigger (struct uevent * uev, void * 

trigger_data)

multipathd/main.c uev_trigger (struct uevent * uev, void *

Quoted 8 lines
multipathd/main.c +1 -0
 {
               int r = 0;
               struct vectors * vecs;
+              struct uevent *merge_uev, *tmp;
 
               vecs = (struct vectors *)trigger_data;
 
@@ -1123,20 +1124,21 @@ uev_trigger (struct uevent * uev, void * 

trigger_data)

Quoted 9 lines
multipathd/main.c +1 -4
               }
 
               /*
-               * path add/remove event
+               * path add/remove/change event, add/remove maybe merged
                */
-              if (!strncmp(uev->action, "add", 3)) {
-                              r = uev_add_path(uev, vecs, 1);
-                              goto out;

multipathd/main.c uev_trigger (struct uevent * uev, void * trigger_data)

Quoted 10 lines
multipathd/main.c +1 -9
-              }
-              if (!strncmp(uev->action, "remove", 6)) {
-                              r = uev_remove_path(uev, vecs, 1);
-                              goto out;
-              }
-              if (!strncmp(uev->action, "change", 6)) {
-                              r = uev_update_path(uev, vecs);
-                              goto out;
-              }
+              list_for_each_entry_safe(merge_uev, tmp, 

&uev->merge_node, node) {

multipathd/main.c uev_trigger (struct uevent * uev, void * · line 1130

Quoted 1 line
multipathd/main.c +1 -0
+                              if (!strncmp(merge_uev->action, "add", 

3))

multipathd/main.c uev_trigger (struct uevent * uev, void * · line 1131

Quoted 1 line
multipathd/main.c +1 -0
+                                              r += 

uev_add_path(merge_uev, vecs, 0);

multipathd/main.c uev_trigger (struct uevent * uev, void * · line 1132

Quoted 1 line
multipathd/main.c +1 -0
+                              if (!strncmp(merge_uev->action, "remove", 

6))

multipathd/main.c uev_trigger (struct uevent * uev, void * · line 1133

Quoted 1 line
multipathd/main.c +1 -0
+                                              r += 

uev_remove_path(merge_uev, vecs, 0);

Quoted 14 lines
multipathd/main.c +8 -0
+              }
+
+              if (!strncmp(uev->action, "add", 3))
+                              r += uev_add_path(uev, vecs, 1);
+              if (!strncmp(uev->action, "remove", 6))
+                              r += uev_remove_path(uev, vecs, 1);
+              if (!strncmp(uev->action, "change", 6))
+                              r += uev_update_path(uev, vecs);
 
 out:
               return r;
Signature · 1 line
2.8.1.windows.1

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#32 lore raw

PATCH 12/12 libmultipath: use existing wwid when wwid has already been existed in uevent

In reply to [email protected]

From: tang.junhui <[email protected]>

Use existing wwid when wwid has already been existed in uevent, it avoids to get wwid again in pathinfo(), and reduces the count of calling getuid(), which would promote processing efficiency.

Change-Id Ia0c7273d33a220e5b415ec42d6b72660018cf4d9
---
 libmultipath/discovery.c | 9 ++++++---
 libmultipath/discovery.h | 4 +++-
 multipathd/main.c        | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)
libmultipath/discovery.c +6 -3
index d1aec31..4985e03 100644
@@ -32,7 +32,7 @@
 #include "defaults.h"
 
 int
-alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
+alloc_path_with_pathinfo (struct config *conf, struct uevent *uev,
 			  int flag, struct path **pp_ptr)
 {
 	int err = PATHINFO_FAILED;
@@ -42,7 +42,7 @@ alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
 	if (pp_ptr)
 		*pp_ptr = NULL;
 
-	devname = udev_device_get_sysname(udevice);
+	devname = udev_device_get_sysname(uev->udev);
 	if (!devname)
 		return PATHINFO_FAILED;
 
@@ -51,10 +51,13 @@ alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
 	if (!pp)
 		return PATHINFO_FAILED;
 
+	if(uev->wwid)
+		strncpy(pp->wwid, uev->wwid, sizeof(pp->wwid));
+
 	if (safe_sprintf(pp->dev, "%s", devname)) {
 		condlog(0, "pp->dev too small");
 	} else {
-		pp->udev = udev_device_ref(udevice);
+		pp->udev = udev_device_ref(uev->udev);
 		err = pathinfo(pp, conf, flag | DI_BLACKLIST);
 	}
 
libmultipath/discovery.h +3 -1
index 3039268..df7de0f 100644
@@ -1,6 +1,8 @@
 #ifndef DISCOVERY_H
 #define DISCOVERY_H
 
+#include "uevent.h"
+
 #define SYSFS_PATH_SIZE 255
 #define INQUIRY_CMDLEN  6
 #define INQUIRY_CMD     0x12
@@ -36,7 +38,7 @@ int do_tur (char *);
 int path_offline (struct path *);
 int get_state (struct path * pp, struct config * conf, int daemon);
 int pathinfo (struct path * pp, struct config * conf, int mask);
-int alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
+int alloc_path_with_pathinfo (struct config *conf, struct uevent *uev,
 			      int flag, struct path **pp_ptr);
 int store_pathinfo (vector pathvec, struct config *conf,
 		    struct udev_device *udevice, int flag,
multipathd/main.c +2 -2
index 0b18f6c..7a1cd09 100644
@@ -664,7 +664,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs, int need_do_map)
 	 * get path vital state
 	 */
 	conf = get_multipath_config();
-	ret = alloc_path_with_pathinfo(conf, uev->udev,
+	ret = alloc_path_with_pathinfo(conf, uev,
 				       DI_ALL, &pp);
 	put_multipath_config(conf);
 	if (!pp) {
@@ -1026,7 +1026,7 @@ out:
 			int flag = DI_SYSFS | DI_WWID;
 
 			conf = get_multipath_config();
-			retval = alloc_path_with_pathinfo(conf, uev->udev, flag, NULL);
+			retval = alloc_path_with_pathinfo(conf, uev, flag, NULL);
 			put_multipath_config(conf);
 
 			if (retval == PATHINFO_SKIPPED) {
Signature · 1 line
2.8.1.windows.1