Skip to content

Commit

Permalink
md: move the early init autodetect code to drivers/md/
Browse files Browse the repository at this point in the history
Just like the NFS and CIFS root code this better lives with the
driver it is tightly integrated with.

Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Song Liu <[email protected]>
Acked-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Hellwig committed Jul 16, 2020
1 parent 881627f commit 4f5b246
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
3 changes: 3 additions & 0 deletions drivers/md/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions init/do_mounts_md.c → drivers/md/md-autodetect.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/syscalls.h>
#include <linux/mount.h>
#include <linux/major.h>
#include <linux/delay.h>
#include <linux/raid/detect.h>
#include <linux/raid/md_u.h>
#include <linux/raid/md_p.h>

#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
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions include/linux/raid/detect.h
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion init/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions init/do_mounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/nfs_fs.h>
#include <linux/nfs_fs_sb.h>
#include <linux/nfs_mount.h>
#include <linux/raid/detect.h>
#include <uapi/linux/mount.h>

#include "do_mounts.h"
Expand Down
10 changes: 0 additions & 10 deletions init/do_mounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4f5b246

Please sign in to comment.