Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1411420pxb; Thu, 21 Oct 2021 23:50:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyySEcCrJNLgHQLiSQTjfG2i+tqTehaDJEWl/gjGy1K384FFCfTCze6U0KbupgogovKFW0B X-Received: by 2002:a17:906:754:: with SMTP id z20mr12372037ejb.365.1634885416088; Thu, 21 Oct 2021 23:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634885416; cv=none; d=google.com; s=arc-20160816; b=ssYzzS5iNOm/hL8najvORYcIyJJBBApRuxVE+rgUylIFaWNxqI/QfHcuWONPVDQeXw 0duMRo8kDQd/mPAD3pnE1TeIpHVoWNzoNXZnnCTx0m71L+AxcGbekrfsQRUYFZw6XsRU mZFmFudh+WUX+UaRlJj2T2RVYmREQjZS2F/NAkVRw3ni+FVoZqqZna9FJte6+6os95dT NaU01gn6cuunU7t029nqMtiNwn6l6AfKU9xz2vFkzf2ZqQqqWTlbr0UmiDF1EJDDfbcx dFvMUwo6eUhGA3XQ2kafzRY91dPylVuObv+gnZpWazb/I/ORc2Ip0MINZBGvlOAizYih H9tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=XBYXxMtyPKJ6Qc/7n3qdZ7tHuPiIBv8ZE/e1scRvEOk=; b=XtMeuGqwvEXR9vpPnjNF/3gai5z+Uq4Ocd7472Plx7+fgFHFw5Wj5EDp59jlfQSmfb +krkpGTWWKW/NYppCi5MOdR4oPiv6uCCJJEVUL+WeJPcc/bo/RJ/+fHsCAjLn+eid67D IxelfBiIB4t8OvgX2TIte2FHMf3Ucd781DHiaEFOjad+Vnm88ydxXKcK1Ut6lzAxQu8s swjAgvlx2Zmh4KGcjmQeZ5fVVqJzJRb2E1y3XBEV0cGDn7Cp+K+4ipOFDuPbjcPRf51S 8E4qJn6IjtvgqXjKdFuxkXI0Cx3Bbhmq8LQHcLcILK4OOxP3KviRTqyV2yaBilUdSgqO cVFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p15si12722534edj.83.2021.10.21.23.49.52; Thu, 21 Oct 2021 23:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232099AbhJVGuM (ORCPT + 99 others); Fri, 22 Oct 2021 02:50:12 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:51966 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229609AbhJVGuL (ORCPT ); Fri, 22 Oct 2021 02:50:11 -0400 X-UUID: 20354e85a0004b9fb8d70903f573a057-20211022 X-UUID: 20354e85a0004b9fb8d70903f573a057-20211022 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1306938713; Fri, 22 Oct 2021 14:47:52 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 22 Oct 2021 14:47:50 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 22 Oct 2021 14:47:50 +0800 From: Mark-PK Tsai To: , , CC: , , , , , , Subject: [PATCH] dm: add module parameter bdev_wait Date: Fri, 22 Oct 2021 14:47:47 +0800 Message-ID: <20211022064748.30136-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dm_early_create() fail if the target block device not found in the late init stage. The block device is created in mmc_rescan() which kernel do it async by queue it into system_freezable_wq. Add module param bdev_wait to support waiting the block device ready before dm_early_create() like prepare_namespace() does. Signed-off-by: Mark-PK Tsai --- drivers/md/dm-init.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c index b0c45c6ebe0b..a3d24cafa4f4 100644 --- a/drivers/md/dm-init.c +++ b/drivers/md/dm-init.c @@ -8,11 +8,13 @@ */ #include +#include #include #include #include #include #include +#include #define DM_MSG_PREFIX "init" #define DM_MAX_DEVICES 256 @@ -20,6 +22,7 @@ #define DM_MAX_STR_SIZE 4096 static char *create; +static char *bdev_wait; /* * Format: dm-mod.create=,,,,[,
+][;,,,,
[,
+]+] @@ -286,6 +289,12 @@ static int __init dm_init_init(void) DMINFO("waiting for all devices to be available before creating mapped devices"); wait_for_device_probe(); + if (bdev_wait) { + DMINFO("Waiting for block device %s...", bdev_wait); + while (!name_to_dev_t(bdev_wait)) + msleep(5); + } + list_for_each_entry(dev, &devices, list) { if (dm_early_create(&dev->dmi, dev->table, dev->target_args_array)) @@ -301,3 +310,5 @@ late_initcall(dm_init_init); module_param(create, charp, 0); MODULE_PARM_DESC(create, "Create a mapped device in early boot"); +module_param(bdev_wait, charp, 0); +MODULE_PARM_DESC(bdev_wait, "Wait until the block device ready before dm_early_create"); -- 2.18.0