From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christophe Varoqui Subject: Re: [PATCH] libmultipath:fix loop traversed partly Date: Fri, 22 Jul 2016 11:44:52 +0200 Message-ID: References: <1468498173-8328-1-git-send-email-zhang.kai16@zte.com.cn> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3089685155611004478==" Return-path: In-Reply-To: <1468498173-8328-1-git-send-email-zhang.kai16@zte.com.cn> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: zhang.kai16@zte.com.cn Cc: device-mapper development , tang.junhui@zte.com.cn, christophe varoqui List-Id: dm-devel.ids --===============3089685155611004478== Content-Type: multipart/alternative; boundary=001a1142bc6c5230490538364912 --001a1142bc6c5230490538364912 Content-Type: text/plain; charset=UTF-8 Your fix is now merged. Thanks. On Thu, Jul 14, 2016 at 2:09 PM, wrote: > From: "zhang.kai" > > Problem: > With each iteration of the vector_foreach_slot() loop statement, > some slots couldn't be traversed when a slot is deleted from vector. > > Reasons: > Currently,loop's index 'i' is not decremented correspondingly when a slot > is > deleted from vector.Meanwhile, in the vector_foreach_slot() loop, mpp is > assigned > from vector newmp directly, so find_slot() could be omitted. > > Signed-off-by: zhang.kai > --- > libmultipath/configure.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libmultipath/configure.c b/libmultipath/configure.c > index a9b9cf0..c06a3df 100644 > --- a/libmultipath/configure.c > +++ b/libmultipath/configure.c > @@ -924,16 +924,14 @@ coalesce_paths (struct vectors * vecs, vector newmp, > char * refwwid, int force_r > if (newmp) { > vector_foreach_slot (newmp, mpp, i) { > char alias[WWID_SIZE]; > - int j; > > if (!deadmap(mpp)) > continue; > > strncpy(alias, mpp->alias, WWID_SIZE - 1); > > - if ((j = find_slot(newmp, (void *)mpp)) != -1) > - vector_del_slot(newmp, j); > - > + vector_del_slot(newmp, i); > + i--; > remove_map(mpp, vecs, 0); > > if (dm_flush_map(alias)) > -- > 2.8.1.windows.1 > > -------------------------------------------------------- > ZTE Information Security Notice: The information contained in this mail > (and any attachment transmitted herewith) is privileged and confidential > and is intended for the exclusive use of the addressee(s). If you are not > an intended recipient, any disclosure, reproduction, distribution or other > dissemination or use of the information contained is strictly prohibited. > If you have received this mail in error, please delete it and notify us > immediately. > > -- > dm-devel mailing list > dm-devel@redhat.com > https://www.redhat.com/mailman/listinfo/dm-devel > --001a1142bc6c5230490538364912 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Your fix is now merged.
Thanks.

On Thu, Jul 14, 2016 at 2:0= 9 PM, <zhang.kai16@zte.com.cn> wrote:
From: "zhang.kai" <zhang.kai16@zte.com.cn>

Problem:
With each iteration of the vector_foreach_slot() loop statement,
some slots couldn't be traversed when a slot is deleted from vector.
Reasons:
Currently,loop's index 'i' is not decremented correspondingly w= hen a slot is
deleted from vector.Meanwhile, in the vector_foreach_slot() loop, mpp is as= signed
from vector newmp directly, so find_slot() could be omitted.

Signed-off-by: zhang.kai <zhan= g.kai16@zte.com.cn>
---
=C2=A0libmultipath/configure.c | 6 ++----
=C2=A01 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index a9b9cf0..c06a3df 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -924,16 +924,14 @@ coalesce_paths (struct vectors * vecs, vector newmp, = char * refwwid, int force_r
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (newmp) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vector_foreach_slot= (newmp, mpp, i) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 char alias[WWID_SIZE];
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0int j;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 if (!deadmap(mpp))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 continue;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 strncpy(alias, mpp->alias, WWID_SIZE - 1);

-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if ((j =3D find_slot(newmp, (void *)mpp)) !=3D -1)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vector_del_slot(newmp, j);
-
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0vector_del_slot(newmp, i);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0i--;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 remove_map(mpp, vecs, 0);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 if (dm_flush_map(alias))
--
2.8.1.windows.1

--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (an= d any attachment transmitted herewith) is privileged and confidential and i= s intended for the exclusive use of the addressee(s).=C2=A0 If you are not = an intended recipient, any disclosure, reproduction, distribution or other = dissemination or use of the information contained is strictly prohibited.= =C2=A0 If you have received this mail in error, please delete it and notify= us immediately.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel=

--001a1142bc6c5230490538364912-- --===============3089685155611004478== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============3089685155611004478==--