Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp851393rwd; Wed, 31 May 2023 06:22:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6vtyJMoFwOf65TJYjNjONGNjDyeJQvyRXFvIcHHkzqL9gn314igNo7R4sn+PTmoH4IlAIL X-Received: by 2002:a05:6a00:aca:b0:64b:43d8:a57d with SMTP id c10-20020a056a000aca00b0064b43d8a57dmr5562977pfl.13.1685539344895; Wed, 31 May 2023 06:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685539344; cv=none; d=google.com; s=arc-20160816; b=tR1hxLPBDzt0LqeEK5Ij+L1vgTHj6an8ov3ZXoqhOFyXh1tffn/p3xtrkw8TF/vMaq hXGQRewODCdnWC4E32rtH9Gtv7i1uVYBF0gFzBlPIMXQD+cOTAa+Tg7qGwvpH4Vq0A12 zmc2Y+ycb/kcTWJ4NT0wfSEmB64Mmbds5ykYn5IILR6YUNhcU6Z4spIDBVodCcppw49e EHgOqRp1d2RAyaUaERirNqAa10Kw4BqVOUsY8/5LO6nfzWoyb+yF3/j8Qh/ZxM9RiOhe u/zbh7jFmlJ3iXHWGgYL0s1i0sbwDRw/vtlZGNgCJIM2KiqypQRyvopbHurgSSpgw4hP AH0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=reP2l+XnVvInA21X0v/lOVTqA4QVG6IJjXgHOwFE+V4=; b=aJ2Cln1Br317E4W+s30Mlewq3Ezu0rtbAVTFvTA9hOkZfyHrta45lkuciYEHNH3FO+ bELzp/cdqeeio6kedmkzedg3lguZvWlFZEVTUjHOUzFjlV5smiQ9PRYfnhW20ZqAqCLE 4LLGyK0ZyScm9JfOwZ8IjHAe2n70EoTmSZONOcnoM3nQUppAY9Hg/8eR0NWE2JuASi7y 3PrC5g+NY8y448dAB8zWT3ez8rODlvdHzkXcLhe8irw4O7wOvbM38N/nNBA4lkukGEIM g/81g9xMMjNqMWiz3kExGkCpt6/KWh6IjC9aGGAUCGQW8N4SvMwSD86Qwaqld7zfGmjZ raIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=zHQT7WkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020aa79e8a000000b0064672de37cesi3515647pfq.192.2023.05.31.06.22.10; Wed, 31 May 2023 06:22:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=zHQT7WkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236114AbjEaM5u (ORCPT + 99 others); Wed, 31 May 2023 08:57:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236218AbjEaM5L (ORCPT ); Wed, 31 May 2023 08:57:11 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 725C610DB; Wed, 31 May 2023 05:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=reP2l+XnVvInA21X0v/lOVTqA4QVG6IJjXgHOwFE+V4=; b=zHQT7WkLH4/2+QmcTap/9HUZxO fGcJEH3MtJF/dzVQZgvXFF7T7KTvpWks0AyqJpSi3yJDpBB9bPrke3I4rEdrEAZ5K863+C/pFKuyy XObT+5KyINbSRqi+3DMuaVtCD803v3gZ87pyERnOyN3spVyaI4ngjmIbLyxD9sXFW77lZGbMB6SP4 O1qksXTMAGK7B7y1fC7FpxyZleKxgIJcQXR8yacRliG7OM+vnJjEGZdL7rnRfGNu3ac360YSrbCju f60volXJkFsx76hmh2fLbodl+Pi3is9gAzkHuEhlPz4L8QqmRY8CXhB/T+wAHb0uWkvrNENmuTYKT XDOoYbsg==; Received: from [2001:4bb8:182:6d06:2e49:a56:513a:92ee] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4LNX-00HRRM-1M; Wed, 31 May 2023 12:56:40 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Mike Snitzer , Joern Engel , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Pavel Machek , Loic Poulain , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH 11/24] init: factor the root_wait logic in prepare_namespace into a helper Date: Wed, 31 May 2023 14:55:22 +0200 Message-Id: <20230531125535.676098-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531125535.676098-1-hch@lst.de> References: <20230531125535.676098-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The root_wait logic is a bit obsfucated right now. Expand it and move it into a helper. Signed-off-by: Christoph Hellwig --- init/do_mounts.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/init/do_mounts.c b/init/do_mounts.c index be6d14733ba02f..d5c06c1546e82c 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -606,6 +606,26 @@ void __init mount_root(char *root_device_name) } } +/* wait for any asynchronous scanning to complete */ +static void __init wait_for_root(char *root_device_name) +{ + if (ROOT_DEV != 0) + return; + + pr_info("Waiting for root device %s...\n", root_device_name); + + for (;;) { + if (driver_probe_done()) { + ROOT_DEV = name_to_dev_t(root_device_name); + if (ROOT_DEV) + break; + } + msleep(5); + } + async_synchronize_full(); + +} + static dev_t __init parse_root_device(char *root_device_name) { if (!strncmp(root_device_name, "mtd", 3) || @@ -642,16 +662,8 @@ void __init prepare_namespace(void) if (initrd_load(saved_root_name)) goto out; - /* wait for any asynchronous scanning to complete */ - if ((ROOT_DEV == 0) && root_wait) { - printk(KERN_INFO "Waiting for root device %s...\n", - saved_root_name); - while (!driver_probe_done() || - (ROOT_DEV = name_to_dev_t(saved_root_name)) == 0) - msleep(5); - async_synchronize_full(); - } - + if (root_wait) + wait_for_root(saved_root_name); mount_root(saved_root_name); out: devtmpfs_mount(); -- 2.39.2