From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Wilck Subject: Re: [PATCH 01/14] multipathd: return if dm_get_major_minor failed in, cli_add_map Date: Fri, 04 Sep 2020 15:13:55 +0200 Message-ID: References: <37544d4c-950f-4281-3b66-e4d1884c5167@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: lixiaokeng , Benjamin Marzinski , Christophe Varoqui , dm-devel mailing list Cc: linfeilong , "liuzhiqiang (I)" List-Id: dm-devel.ids On Fri, 2020-09-04 at 10:48 +0800, lixiaokeng wrote: > > On 2020/9/4 1:26, Martin Wilck wrote: > > Why not just quit the "do" loop in the error case > > for dm_get_major_minor()? > > > > Martin > > If dm_get_major failed at first time, it will be executed again > for some reason I don't know in the original code. Quiting the > "do" loop in the error case for dm_get_major_minor() is against > the twice attempt rule. Right. Then, to solve the problem you're concerned about, it should be sufficient to initialize both major and minor to -1, or simply refrain from printing them in the log message in the first place. At a closer look, the logic of the function is flawed; at least if get_refwwid() doesn't return a usable refwwid, there's no point in trying again. Thanks, Martin > > Lixiaokeng > > > else { > > > sprintf(dev_path, "dm-%d", minor); > > > alias = dm_mapname(major, minor); > > > + if (!alias) > > > + condlog(2, "%s: mapname not found for > > > %d:%d", > > > + param, major, minor); > > > } > > > /*if there is no mapname found, we first create the > > > device*/ > > > if (!alias && !count) { > > > - condlog(2, "%s: mapname not found for %d:%d", > > > - param, major, minor); > > > get_refwwid(CMD_NONE, param, DEV_DEVMAP, > > > vecs->pathvec, &refwwid); > > > if (refwwid) { > > > > > > . > >