From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mY1M3-00021q-Ue for mharc-grub-devel@gnu.org; Wed, 06 Oct 2021 03:28:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mY1M2-00020t-3g for grub-devel@gnu.org; Wed, 06 Oct 2021 03:28:42 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:53560) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mY1Lx-0000WN-22 for grub-devel@gnu.org; Wed, 06 Oct 2021 03:28:41 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DAA9B20322; Wed, 6 Oct 2021 07:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1633505313; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qBlfI9quILNlSs38GFoq9ULN+YL/rkyjsvhBwKnKRec=; b=167E0A5vU+0pCEMwoqUCJBao5bdm86AKGqrowESJwpq2tHx9VPVrxHq2dqQsHUY6OSlsUE wmSw+EUyHDAsSemsM5Qx+AdISkoaLV9sOSMGiianvRSUCh9cPC9xWrp4wd/CrhNfZvN4Wi Slbx7gL0k5AmGTbS6usOQVPVgWUIMI4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1633505313; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qBlfI9quILNlSs38GFoq9ULN+YL/rkyjsvhBwKnKRec=; b=arPW3CsWfKARdI/RpZcQmm+XgHGBAkX8ShrkqpKzQSdSt9l2m+zMi9b5u9zv7L10gDIlN/ faYth5uwsYrXhCBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B3BB813E20; Wed, 6 Oct 2021 07:28:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FqiQKiFQXWEODAAAMHmgww (envelope-from ); Wed, 06 Oct 2021 07:28:33 +0000 Date: Wed, 6 Oct 2021 09:28:32 +0200 From: Petr Vorel To: Daniel Kiper , kees@ubuntu.com Cc: grub-devel@gnu.org Subject: Re: [PATCH] osdep/linux: Fix md array device enumeration Message-ID: Reply-To: Petr Vorel References: <20210926020335.2346634-1-kees@ubuntu.com> <20211005163813.3osmfiey5icpltrf@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211005163813.3osmfiey5icpltrf@tomti.i.net-space.pl> Received-SPF: pass client-ip=195.135.220.29; envelope-from=pvorel@suse.cz; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2021 07:28:42 -0000 Hi Kees, Daniel, > On Sat, Sep 25, 2021 at 07:03:35PM -0700, kees@ubuntu.com wrote: > > From: Kees Cook > > GET_ARRAY_INFO's info.nr_disks does not map to GET_DISK_INFO's > > disk.number, which is an internal kernel index. If an array has had drives > > added, removed, etc, there may be gaps in GET_DISK_INFO's results. But > > since the consumer of devicelist cannot tolerate gaps (it expects to walk > > a NULL-terminated list of device name strings), the devicelist index (j) > > must be tracked separately from the disk.number index (i). But grub > > wants to only examine active (i.e. present and non-failed) disks, so how > > many disks are left to be queried must be also separately tracked > > (remaining). Kees, thanks a lot for taking care for this. > > + /* Skip empty slot: MD_DISK_REMOVED slots don't count toward nr_disks. */ > > if (disk.state & (1 << MD_DISK_REMOVED)) > > continue; > > + remaining--; > > - if (disk.state & (1 << MD_DISK_ACTIVE)) > > - devicelist[j] = grub_find_device (NULL, > > - makedev (disk.major, disk.minor)); > > - else > > - devicelist[j] = NULL; > > - j++; > > + /* Only examine disks that are actively participating in the array. */ > > + if (!(disk.state & (1 << MD_DISK_ACTIVE))) > > + continue; > > + > > + devicelist[j++] = grub_find_device (NULL, makedev (disk.major, > > + disk.minor)); > I would prefer if you leave original if statement as is and update > grub_find_device() call accordingly... And of course drop else as > needed... :-) I suppose you'll need to send v2 due this, but for now: Reviewed-by: Petr Vorel Kind regards, Petr