Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1980269ybh; Tue, 14 Jul 2020 12:11:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCZjNvBndd9B5YS2zBjokROcgZM0z9w71PfHGIv9LcgX9v9GsOZJB27RB1tuCKHSopR1pm X-Received: by 2002:a50:fe0c:: with SMTP id f12mr5910338edt.360.1594753898926; Tue, 14 Jul 2020 12:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594753898; cv=none; d=google.com; s=arc-20160816; b=031QwyLUxePJpXsTOEAVv2evNjmqK4/vCgdWeQFSlYnjSGHiOymX62fhhwd7jPViqV OZEQ6XqtHfqnDjsJ6r9wSNzLDOnmquvWgjBVHgRCQoJO6YY6sVP1Ug5HLPT+MjOjsIAk iSqRdhe8LkplTgFJ55VVCdpy5NrizPWeMIUdxtYgw1kCsTPkgCz8glKFqtADzp6REk7U mU/QE8eozQMJCoHHJYYnEKtt5kJRjT5lATBbyrYgA9eKeJvdzUNOC1E8fNTlvwR5VglA GWK1I7nrFXKrYOqGF+itMVaJDj5Qv/SkOxEP66JKzAs4blvv/v66LxAPrAPZPkJZNm6t hhIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jLnNS2iTfKAlsojBbZTaLr2xSlY0SBshpAX/GMxDj/c=; b=UUcSBc+5TxIx2pxH4l7Mr3ImINnF3J1uYvUynCysHpZaejS0F+EN+xw3GnrvwU4OdV UWLDiHVYE/Noj3bos9BLB+Gr52m9W56U7lx9w4ZLFB4GpQJSb49XVldQwD4QMK4BEweh 9trKJmXoEyb+Qwv27yoZx9A7LZKV1wljbjKjDu8u/hhsuz0UKJcduHORt0U9Dz3ene6D aFSXRiT0CZpW3dlh/HIMNInkoT/h0HeLwDNcljCZQA14K2DWoKfM5TO57EsiGdQ4VAFl Cub9HgNgKNZ/NlAWxcYgzd64jh4w5MR0JCH/bCJn2y5QLLvbCbLgKkIM+topeETsNnfd yTRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="WE4h/hbq"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si11434224ejx.563.2020.07.14.12.11.15; Tue, 14 Jul 2020 12:11:38 -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; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="WE4h/hbq"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731262AbgGNTLL (ORCPT + 99 others); Tue, 14 Jul 2020 15:11:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730235AbgGNTIz (ORCPT ); Tue, 14 Jul 2020 15:08:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1BAC061755; Tue, 14 Jul 2020 12:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=jLnNS2iTfKAlsojBbZTaLr2xSlY0SBshpAX/GMxDj/c=; b=WE4h/hbqZeHCQuMg6xjxotr8pQ BzkkqyRg8XGkHV6KH/R7f36RbDz5ax6wL4WIpbNdth+Q2kC3O70+11RJsTGHlCREqNZpbqYU35rEl MONHMDPVOW2BHmrpKx/9RpZ7RQydqb27g04/WzXHH0BPO/hCR9KZJ/02A25aUuioRSTEnapdQ1VjA zovwJhINU54N8/9Ny3fThlg1tKsRcLDNDCxNy7AydwWzSnaTr/TDp5Bhgjkinw0kF675dMkYTJWY6 Q1nAyo/o9BXlnkn6kp5HyBIWTOUUCsg6iR3YpJOoHWOEyufw0tMPiGtHLzhUhZ5t7OWtPS1ZhHE0y H0iFpRig==; Received: from [2001:4bb8:188:5f50:f037:8cfe:627e:7028] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvQIP-0005pU-N0; Tue, 14 Jul 2020 19:08:54 +0000 From: Christoph Hellwig To: linux-kernel@vger.kernel.org Cc: "H. Peter Anvin" , Song Liu , Al Viro , Linus Torvalds , linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 04/23] md: move the early init autodetect code to drivers/md/ Date: Tue, 14 Jul 2020 21:04:08 +0200 Message-Id: <20200714190427.4332-5-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714190427.4332-1-hch@lst.de> References: <20200714190427.4332-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just like the NFS and CIFS root code this better lives with the driver it is tightly integrated with. Signed-off-by: Christoph Hellwig Acked-by: Song Liu --- drivers/md/Makefile | 3 +++ init/do_mounts_md.c => drivers/md/md-autodetect.c | 15 +++++++++++++-- include/linux/raid/detect.h | 8 ++++++++ init/Makefile | 1 - init/do_mounts.c | 1 + init/do_mounts.h | 10 ---------- 6 files changed, 25 insertions(+), 13 deletions(-) rename init/do_mounts_md.c => drivers/md/md-autodetect.c (96%) diff --git a/drivers/md/Makefile b/drivers/md/Makefile index 31840f95cd408b..6d3e234dc46a5d 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile @@ -43,6 +43,9 @@ obj-$(CONFIG_MD_FAULTY) += faulty.o obj-$(CONFIG_MD_CLUSTER) += md-cluster.o obj-$(CONFIG_BCACHE) += bcache/ obj-$(CONFIG_BLK_DEV_MD) += md-mod.o +ifeq ($(CONFIG_BLK_DEV_MD),y) +obj-y += md-autodetect.o +endif obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o obj-$(CONFIG_BLK_DEV_DM_BUILTIN) += dm-builtin.o obj-$(CONFIG_DM_UNSTRIPED) += dm-unstripe.o diff --git a/init/do_mounts_md.c b/drivers/md/md-autodetect.c similarity index 96% rename from init/do_mounts_md.c rename to drivers/md/md-autodetect.c index 359363e85ccd0b..fe806f7b9759a1 100644 --- a/init/do_mounts_md.c +++ b/drivers/md/md-autodetect.c @@ -1,10 +1,15 @@ // SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include #include +#include #include #include -#include "do_mounts.h" - /* * When md (and any require personalities) are compiled into the kernel * (not a module), arrays can be assembles are boot time using with AUTODETECT @@ -114,6 +119,12 @@ static int __init md_setup(char *str) return 1; } +static inline int create_dev(char *name, dev_t dev) +{ + ksys_unlink(name); + return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev)); +} + static void __init md_setup_drive(void) { int minor, i, ent, partitioned; diff --git a/include/linux/raid/detect.h b/include/linux/raid/detect.h index 37dd3f40cd316e..1f029a71c3ef05 100644 --- a/include/linux/raid/detect.h +++ b/include/linux/raid/detect.h @@ -1,3 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0 */ void md_autodetect_dev(dev_t dev); + +#ifdef CONFIG_BLK_DEV_MD +void md_run_setup(void); +#else +static inline void md_run_setup(void) +{ +} +#endif diff --git a/init/Makefile b/init/Makefile index 57499b1ff4714d..6bc37f64b3617c 100644 --- a/init/Makefile +++ b/init/Makefile @@ -18,7 +18,6 @@ obj-y += init_task.o mounts-y := do_mounts.o mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o -mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o # dependencies on generated files need to be listed explicitly $(obj)/version.o: include/generated/compile.h diff --git a/init/do_mounts.c b/init/do_mounts.c index 29d326b6c29d2d..1a4dfa17fb2899 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "do_mounts.h" diff --git a/init/do_mounts.h b/init/do_mounts.h index 7513d1c14d13fe..50d6c8941e15a1 100644 --- a/init/do_mounts.h +++ b/init/do_mounts.h @@ -41,13 +41,3 @@ bool __init initrd_load(void); static inline bool initrd_load(void) { return false; } #endif - -#ifdef CONFIG_BLK_DEV_MD - -void md_run_setup(void); - -#else - -static inline void md_run_setup(void) {} - -#endif -- 2.27.0