decruft the early init / initrd / initramfs code
Subsystems (8)
Hi all,
this series starts to move the early init code away from requiring KERNEL_DS to be implicitly set during early startup. It does so by first removing legacy unused cruft, and the switches away the code from struct file based APIs to our more usual in-kernel APIs.
PATCH 1/16 init: remove the bstat helper
The only caller of the bstat function becomes cleaner and simpler when open coding the function.
--- init/do_mounts.h | 10 ---------- init/do_mounts_md.c | 8 ++++---- 2 files changed, 4 insertions(+), 14 deletions(-)
init/do_mounts.h +0 -10
@@ -20,16 +20,6 @@ static inline int create_dev(char *name, dev_t dev)return ksys_mknod (name,S_IFBLK |0600 ,new_encode_dev (dev)); } -static inline u32 bstat (char *name) -{ -struct kstat stat; -if (vfs_stat (name, &stat) !=0 ) -return 0 ; -if (!S_ISBLK (stat.mode)) -return 0 ; -return stat.rdev; -} -#ifdef CONFIG_BLK_DEV_RAM int __init rd_load_disk (int n);
init/do_mounts_md.c +4 -4
@@ -138,9 +138,9 @@ static void __init md_setup_drive(void) dev =MKDEV (MD_MAJOR , minor);create_dev (name, dev);for (i =0 ; i <MD_SB_DISKS && devname !=NULL ; i++) { +struct kstat stat;char *p;char comp_name[64 ]; -u32 rdev; p =strchr (devname,',' );if (p)
@@ -150,9 +150,9 @@ static void __init md_setup_drive(void)if (strncmp (devname,"/dev/" ,5 ) ==0 ) devname +=5 ;snprintf (comp_name,63 ,"/dev/%s" , devname); - rdev =bstat (comp_name); -if (rdev) - dev =new_decode_dev (rdev); +if (vfs_stat (comp_name, &stat) ==0 && +S_ISBLK (stat.mode)) + dev =new_decode_dev (stat.rdev);if (!dev) {printk (KERN_WARNING "md: Unknown device name: %s\n" , devname);break ;
Signature · 1 line
2.26.2
Song Liu
maintainerRe: [PATCH 01/16] init: remove the bstat helper
Hi Christoph,
Quoted 5 lines · Christoph Hellwig
The only caller of the bstat function becomes cleaner and simpler when open coding the function.
Signed-off-by Christoph Hellwig <[email protected]>
Thanks for the set. md parts of the set look good to me.
How should we route this set, as it touches multiple subsystems?
Thanks,
Song
Re: [PATCH 01/16] init: remove the bstat helper
Quoted 4 lines · Song Liu
Hi Christoph,
Quoted 1 line · Christoph Hellwig
Quoted 8 lines
Quoted 4 lines
The only caller of the bstat function becomes cleaner and simpler when open coding the function.
Signed-off-by Christoph Hellwig <[email protected]>Thanks for the set. md parts of the set look good to me.
How should we route this set, as it touches multiple subsystems?
Good question as there is no really applicable tree. One option would the vfs tree as it toucheѕ some VFS stuff, and the follow on series that depends on it is all about VFS bits. Alternatively I could set up a tree just for these bits. The important bit is that it doesn't go into the -mm tree as the usual catchall, as I have more stuff that depends on it and requires a git tree.
Song Liu
maintainerRe: [PATCH 01/16] init: remove the bstat helper
Quoted 13 lines · Christoph Hellwig
Quoted 11 lines · Song Liu
Hi Christoph,
Quoted 5 lines · Christoph Hellwig
The only caller of the bstat function becomes cleaner and simpler when open coding the function.
Signed-off-by Christoph Hellwig <[email protected]>Thanks for the set. md parts of the set look good to me.
Quoted 8 lines
Quoted 1 line
How should we route this set, as it touches multiple subsystems?
Good question as there is no really applicable tree. One option would the vfs tree as it toucheѕ some VFS stuff, and the follow on series that depends on it is all about VFS bits. Alternatively I could set up a tree just for these bits. The important bit is that it doesn't go into the -mm tree as the usual catchall, as I have more stuff that depends on it and requires a git tree.
Would this official mm tree work?
T: git git://github.com/hnaz/linux-mm.git
If not, I am OK with either vfs tree or a dedicated tree.
Thanks,
Song
Re: [PATCH 01/16] init: remove the bstat helper
Quoted 5 lines · Song Liu
Would this official mm tree work?
T: git
git://github.com/hnaz/linux-mm.gitIf not, I am OK with either vfs tree or a dedicated tree.
That is a constantly rebased tree, so I don't think it helps.
PATCH 2/16 md: move the early init autodetect code to drivers/md/
In reply to Christoph HellwigJust like the NFS and CIFS root code this better lives with the driver it is tightly integrated with.
--- 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%)
drivers/md/Makefile +3 -0
@@ -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
drivers/md/md-autodetect.c renamed from init/do_mounts_md.c +13 -2
@@ -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
@@ -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;
include/linux/raid/detect.h +8 -0
@@ -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
init/Makefile +0 -1
@@ -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
init/do_mounts.c +1 -0
@@ -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"
init/do_mounts.h +0 -10
@@ -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
Signature · 1 line
2.26.2
kernel test robot
build botRe: [PATCH 02/16] md: move the early init autodetect code to drivers/md/
I love your patch! Perhaps something to improve:
Hi Christoph,
I love your patch! Perhaps something to improve:
[auto build test WARNING on song-md/md-next]
[also build test WARNING on sparc-next/master sparc/master linus/master v5.8-rc1 next-20200615] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Christoph-Hellwig/init-remove-the-bstat-helper/20200615-215324 base: git://git.kernel.org/pub/scm/linux/kernel/git/song/md.git md-next config: i386-randconfig-s001-20200615 (attached as .config) compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.2-rc1-3-g55607964-dirty # save the attached .config to linux build tree make W=1 C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> drivers/md/md-autodetect.c:164:38: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *filename @@ got char * @@ >> drivers/md/md-autodetect.c:164:38: sparse: expected char const [noderef] <asn:1> *filename >> drivers/md/md-autodetect.c:164:38: sparse: got char *
drivers/md/md-autodetect.c:185:32: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *filename @@ got char * @@
drivers/md/md-autodetect.c:185:32: sparse: expected char const [noderef] <asn:1> *filename
drivers/md/md-autodetect.c:185:32: sparse: got char *
drivers/md/md-autodetect.c:249:40: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *filename @@ got char * @@
drivers/md/md-autodetect.c:249:40: sparse: expected char const [noderef] <asn:1> *filename
drivers/md/md-autodetect.c:249:40: sparse: got char *
drivers/md/md-autodetect.c:299:24: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *filename @@ got char * @@
drivers/md/md-autodetect.c:299:24: sparse: expected char const [noderef] <asn:1> *filename
drivers/md/md-autodetect.c:299:24: sparse: got char *
drivers/md/md-autodetect.c:124:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *pathname @@ got char *name @@
drivers/md/md-autodetect.c:124:21: sparse: expected char const [noderef] <asn:1> *pathname
drivers/md/md-autodetect.c:124:21: sparse: got char *name
drivers/md/md-autodetect.c:125:27: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *filename @@ got char *name @@
drivers/md/md-autodetect.c:125:27: sparse: expected char const [noderef] <asn:1> *filename
drivers/md/md-autodetect.c:125:27: sparse: got char *name
drivers/md/md-autodetect.c:124:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *pathname @@ got char *name @@
drivers/md/md-autodetect.c:124:21: sparse: expected char const [noderef] <asn:1> *pathname
drivers/md/md-autodetect.c:124:21: sparse: got char *name
drivers/md/md-autodetect.c:125:27: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const [noderef] <asn:1> *filename @@ got char *name @@
drivers/md/md-autodetect.c:125:27: sparse: expected char const [noderef] <asn:1> *filename
drivers/md/md-autodetect.c:125:27: sparse: got char *name
vim +164 drivers/md/md-autodetect.c
6fc96eea53684d drivers/md/md-autodetect.c Christoph Hellwig 2020-06-15 127
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 128 static void __init md_setup_drive(void)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 129 {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 130 int minor, i, ent, partitioned;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 131 dev_t dev;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 132 dev_t devices[MD_SB_DISKS+1];
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 133
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 134 for (ent = 0; ent < md_setup_ents ; ent++) {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 135 int fd;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 136 int err = 0;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 137 char *devname;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 138 mdu_disk_info_t dinfo;
bdaf8529385d51 init/do_mounts_md.c Greg Kroah-Hartman 2005-06-20 139 char name[16];
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 140
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 141 minor = md_setup_args[ent].minor;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 142 partitioned = md_setup_args[ent].partitioned;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 143 devname = md_setup_args[ent].device_names;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 144
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 145 sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 146 if (partitioned)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 147 dev = MKDEV(mdp_major, minor << MdpMinorShift);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 148 else
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 149 dev = MKDEV(MD_MAJOR, minor);
bdaf8529385d51 init/do_mounts_md.c Greg Kroah-Hartman 2005-06-20 150 create_dev(name, dev);
d613c3e2d84188 init/do_mounts_md.c Harvey Harrison 2008-04-28 151 for (i = 0; i < MD_SB_DISKS && devname != NULL; i++) {
86a04656f6cbe2 init/do_mounts_md.c Christoph Hellwig 2020-06-15 152 struct kstat stat;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 153 char *p;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 154 char comp_name[64];
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 155
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 156 p = strchr(devname, ',');
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 157 if (p)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 158 *p++ = 0;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 159
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 160 dev = name_to_dev_t(devname);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 161 if (strncmp(devname, "/dev/", 5) == 0)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 162 devname += 5;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 163 snprintf(comp_name, 63, "/dev/%s", devname);
86a04656f6cbe2 init/do_mounts_md.c Christoph Hellwig 2020-06-15 @164 if (vfs_stat(comp_name, &stat) == 0 &&
86a04656f6cbe2 init/do_mounts_md.c Christoph Hellwig 2020-06-15 165 S_ISBLK(stat.mode))
86a04656f6cbe2 init/do_mounts_md.c Christoph Hellwig 2020-06-15 166 dev = new_decode_dev(stat.rdev);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 167 if (!dev) {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 168 printk(KERN_WARNING "md: Unknown device name: %s\n", devname);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 169 break;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 170 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 171
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 172 devices[i] = dev;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 173
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 174 devname = p;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 175 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 176 devices[i] = 0;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 177
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 178 if (!i)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 179 continue;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 180
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 181 printk(KERN_INFO "md: Loading md%s%d: %s\n",
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 182 partitioned ? "_d" : "", minor,
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 183 md_setup_args[ent].device_names);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 184
bae217ea8c7e12 init/do_mounts_md.c Dominik Brodowski 2018-03-11 185 fd = ksys_open(name, 0, 0);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 186 if (fd < 0) {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 187 printk(KERN_ERR "md: open failed - cannot start "
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 188 "array %s\n", name);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 189 continue;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 190 }
cbb60b924b9f3e init/do_mounts_md.c Dominik Brodowski 2018-03-13 191 if (ksys_ioctl(fd, SET_ARRAY_INFO, 0) == -EBUSY) {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 192 printk(KERN_WARNING
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 193 "md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n",
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 194 minor);
2ca2a09d6215fd init/do_mounts_md.c Dominik Brodowski 2018-03-11 195 ksys_close(fd);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 196 continue;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 197 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 198
2604b703b6b3db init/do_mounts_md.c NeilBrown 2006-01-06 199 if (md_setup_args[ent].level != LEVEL_NONE) {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 200 /* non-persistent */
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 201 mdu_array_info_t ainfo;
2604b703b6b3db init/do_mounts_md.c NeilBrown 2006-01-06 202 ainfo.level = md_setup_args[ent].level;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 203 ainfo.size = 0;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 204 ainfo.nr_disks =0;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 205 ainfo.raid_disks =0;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 206 while (devices[ainfo.raid_disks])
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 207 ainfo.raid_disks++;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 208 ainfo.md_minor =minor;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 209 ainfo.not_persistent = 1;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 210
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 211 ainfo.state = (1 << MD_SB_CLEAN);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 212 ainfo.layout = 0;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 213 ainfo.chunk_size = md_setup_args[ent].chunk;
cbb60b924b9f3e init/do_mounts_md.c Dominik Brodowski 2018-03-13 214 err = ksys_ioctl(fd, SET_ARRAY_INFO, (long)&ainfo);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 215 for (i = 0; !err && i <= MD_SB_DISKS; i++) {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 216 dev = devices[i];
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 217 if (!dev)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 218 break;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 219 dinfo.number = i;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 220 dinfo.raid_disk = i;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 221 dinfo.state = (1<<MD_DISK_ACTIVE)|(1<<MD_DISK_SYNC);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 222 dinfo.major = MAJOR(dev);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 223 dinfo.minor = MINOR(dev);
cbb60b924b9f3e init/do_mounts_md.c Dominik Brodowski 2018-03-13 224 err = ksys_ioctl(fd, ADD_NEW_DISK,
cbb60b924b9f3e init/do_mounts_md.c Dominik Brodowski 2018-03-13 225 (long)&dinfo);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 226 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 227 } else {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 228 /* persistent */
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 229 for (i = 0; i <= MD_SB_DISKS; i++) {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 230 dev = devices[i];
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 231 if (!dev)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 232 break;
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 233 dinfo.major = MAJOR(dev);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 234 dinfo.minor = MINOR(dev);
cbb60b924b9f3e init/do_mounts_md.c Dominik Brodowski 2018-03-13 235 ksys_ioctl(fd, ADD_NEW_DISK, (long)&dinfo);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 236 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 237 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 238 if (!err)
cbb60b924b9f3e init/do_mounts_md.c Dominik Brodowski 2018-03-13 239 err = ksys_ioctl(fd, RUN_ARRAY, 0);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 240 if (err)
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 241 printk(KERN_WARNING "md: starting md%d failed\n", minor);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 242 else {
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 243 /* reread the partition table.
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 244 * I (neilb) and not sure why this is needed, but I cannot
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 245 * boot a kernel with devfs compiled in from partitioned md
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 246 * array without it
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 247 */
2ca2a09d6215fd init/do_mounts_md.c Dominik Brodowski 2018-03-11 248 ksys_close(fd);
bae217ea8c7e12 init/do_mounts_md.c Dominik Brodowski 2018-03-11 249 fd = ksys_open(name, 0, 0);
cbb60b924b9f3e init/do_mounts_md.c Dominik Brodowski 2018-03-13 250 ksys_ioctl(fd, BLKRRPART, 0);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 251 }
2ca2a09d6215fd init/do_mounts_md.c Dominik Brodowski 2018-03-11 252 ksys_close(fd);
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 253 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 254 }
^1da177e4c3f41 init/do_mounts_md.c Linus Torvalds 2005-04-16 255 :::::: The code@line 164 was first introduced by commit
:::::: 86a04656f6cbe246b402b55ce114ff7a59ba68ea init: remove the bstat helper
:::::: TO: Christoph Hellwig <[email protected]>
:::::: CC: 0day robot <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 02/16] md: move the early init autodetect code to drivers/md/
Quoted 3 lines · kernel test robot
Hi Christoph,
I love your patch! Perhaps something to improve:
Well, this just moves the warnings from the old to the new place. Is there a way to detect file moves and not warn?
(they also get fixed later in the series).
Re: [PATCH 02/16] md: move the early init autodetect code to drivers/md/
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · kernel test robot
Hi Christoph,
I love your patch! Perhaps something to improve:
Well, this just moves the warnings from the old to the new place. Is there a way to detect file moves and not warn?
Hi Christoph,
Sorry for the inconvenience, we have no good solution to detect file moves, and we don't know the new warning is due to the moving or other new code.
Best Regards,
Rong Chen
PATCH 3/16 md: replace the RAID_AUTORUN ioctl with a direct function call
In reply to Christoph HellwigInstead of using a spcial RAID_AUTORUN ioctl that only exists for non-modular builds and is only called from the early init code, just call the actual function directly.
--- drivers/md/md-autodetect.c | 10 ++-------- drivers/md/md.c | 14 +------------- drivers/md/md.h | 3 +++ 3 files changed, 6 insertions(+), 21 deletions(-)
drivers/md/md-autodetect.c +2 -8
@@ -9,6 +9,7 @@#include <linux/raid/detect.h> #include <linux/raid/md_u.h> #include <linux/raid/md_p.h> +#include "md.h" /* * When md (and any require personalities) are compiled into the kernel
@@ -285,8 +286,6 @@ __setup("md=", md_setup);static void __init autodetect_raid (void ) { -int fd; -/* * Since we don't want to detect and use half a raid array, we need to * wait for the known devices to complete their probing
@@ -295,12 +294,7 @@ static void __init autodetect_raid(void)printk (KERN_INFO "md: If you don't use raid, use raid=noautodetect\n" );wait_for_device_probe (); - - fd =ksys_open ("/dev/md0" ,0 ,0 ); -if (fd >=0 ) { -ksys_ioctl (fd,RAID_AUTORUN , raid_autopart); -ksys_close (fd); - } +md_autostart_arrays (raid_autopart); }void __init md_run_setup (void )
drivers/md/md.c +1 -13
@@ -68,10 +68,6 @@#include "md-bitmap.h" #include "md-cluster.h" -#ifndef MODULE -static void autostart_arrays (int part); -#endif -/* pers_list is a list of registered personalities protected * by pers_lock. * pers_lock does extra service to protect accesses to
@@ -7421,7 +7417,6 @@ static inline bool md_ioctl_valid(unsigned int cmd)case GET_DISK_INFO :case HOT_ADD_DISK :case HOT_REMOVE_DISK : -case RAID_AUTORUN :case RAID_VERSION :case RESTART_ARRAY_RW :case RUN_ARRAY :
@@ -7467,13 +7462,6 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,case RAID_VERSION : err =get_version (argp); goto out; - -#ifndef MODULE -case RAID_AUTORUN : - err =0 ; -autostart_arrays (arg); - goto out; -#endif default :; }
@@ -9721,7 +9709,7 @@ void md_autodetect_dev(dev_t dev) } } -static void autostart_arrays (int part) +void md_autostart_arrays (int part) {struct md_rdev *rdev;struct detected_devices_node *node_detected_dev;
drivers/md/md.h +3 -0
@@ -800,4 +800,7 @@ static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio *bio !bio->bi_disk->queue->limits.max_write_zeroes_sectors) mddev->queue->limits.max_write_zeroes_sectors = 0; } + +void md_autostart_arrays (int part); +#endif /* _MD_MD_H */
Signature · 1 line
2.26.2
PATCH 4/16 md: remove the autoscan partition re-read
In reply to Christoph Hellwigdevfs is long gone, and autoscan works just fine without this these days.
--- drivers/md/md-autodetect.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/md/md-autodetect.c +0 -10
@@ -240,16 +240,6 @@ static void __init md_setup_drive(void) err =ksys_ioctl (fd,RUN_ARRAY ,0 );if (err)printk (KERN_WARNING "md: starting md%d failed\n" , minor); -else { -/* reread the partition table. -* I (neilb) and not sure why this is needed, but I cannot -* boot a kernel with devfs compiled in from partitioned md -* array without it -*/ -ksys_close (fd); - fd =ksys_open (name,0 ,0 ); -ksys_ioctl (fd,BLKRRPART ,0 ); - }ksys_close (fd); } }
Signature · 1 line
2.26.2
PATCH 5/16 md: remove the kernel version of md_u.h
In reply to Christoph Hellwigmdp_major can just move to drivers/md/md.h.
--- drivers/md/md.h | 1 + include/linux/raid/md_u.h | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 include/linux/raid/md_u.h
drivers/md/md.h +1 -0
@@ -801,6 +801,7 @@ static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio *bio mddev->queue->limits.max_write_zeroes_sectors = 0; } +extern int mdp_major;void md_autostart_arrays (int part);#endif /* _MD_MD_H */
include/linux/raid/md_u.h deleted +0 -13
@@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -md_u.h : user <=> kernel API between Linux raidtools and RAID drivers -Copyright (C) 1998 Ingo Molnar -- */ -#ifndef _MD_U_H -#define _MD_U_H - -#include <uapi/linux/raid/md_u.h> - -extern int mdp_major; -#endif
Signature · 1 line
2.26.2
PATCH 6/16 md: simplify md_setup_drive
In reply to Christoph HellwigMove the loop over the possible arrays into the caller to remove a level of indentation for the whole function.
--- drivers/md/md-autodetect.c | 203 ++++++++++++++++++------------------- 1 file changed, 101 insertions(+), 102 deletions(-)
drivers/md/md-autodetect.c +101 -102
@@ -27,7 +27,7 @@ static int __initdata raid_noautodetect=1;#endif static int __initdata raid_autopart; -static struct { +static struct md_setup_args { int minor; int partitioned; int level;
@@ -126,122 +126,117 @@ static inline int create_dev(char *name, dev_t dev)return ksys_mknod (name,S_IFBLK |0600 ,new_encode_dev (dev)); } -static void __init md_setup_drive (void ) +static void __init md_setup_drive (struct md_setup_args *args) { -int minor, i, ent, partitioned; +int minor, i, partitioned;dev_t dev;dev_t devices[MD_SB_DISKS +1 ]; +int fd; +int err =0 ; +char *devname; +mdu_disk_info_t dinfo; +char name[16 ]; -for (ent =0 ; ent < md_setup_ents ; ent++) { -int fd; -int err =0 ; -char *devname; -mdu_disk_info_t dinfo; -char name[16 ]; + minor = args->minor; + partitioned = args->partitioned; + devname = args->device_names; - minor = md_setup_args[ent].minor; - partitioned = md_setup_args[ent].partitioned; - devname = md_setup_args[ent].device_names; +sprintf (name,"/dev/md%s%d" , partitioned?"_d" :"" , minor); +if (partitioned) + dev =MKDEV (mdp_major, minor << MdpMinorShift); +else + dev =MKDEV (MD_MAJOR , minor); +create_dev (name, dev); +for (i =0 ; i <MD_SB_DISKS && devname !=NULL ; i++) { +struct kstat stat; +char *p; +char comp_name[64 ]; -sprintf (name,"/dev/md%s%d" , partitioned?"_d" :"" , minor); -if (partitioned) - dev =MKDEV (mdp_major, minor << MdpMinorShift); -else - dev =MKDEV (MD_MAJOR , minor); -create_dev (name, dev); -for (i =0 ; i <MD_SB_DISKS && devname !=NULL ; i++) { -struct kstat stat; -char *p; -char comp_name[64 ]; + p =strchr (devname,',' ); +if (p) + *p++ =0 ; - p =strchr (devname,',' ); -if (p) - *p++ =0 ; + dev =name_to_dev_t (devname); +if (strncmp (devname,"/dev/" ,5 ) ==0 ) + devname +=5 ; +snprintf (comp_name,63 ,"/dev/%s" , devname); +if (vfs_stat (comp_name, &stat) ==0 &&S_ISBLK (stat.mode)) + dev =new_decode_dev (stat.rdev); +if (!dev) { +printk (KERN_WARNING "md: Unknown device name: %s\n" , devname); +break ; + } - dev =name_to_dev_t (devname); -if (strncmp (devname,"/dev/" ,5 ) ==0 ) - devname +=5 ; -snprintf (comp_name,63 ,"/dev/%s" , devname); -if (vfs_stat (comp_name, &stat) ==0 && -S_ISBLK (stat.mode)) - dev =new_decode_dev (stat.rdev); -if (!dev) { -printk (KERN_WARNING "md: Unknown device name: %s\n" , devname); -break ; - } + devices[i] = dev; + devname = p; + } + devices[i] =0 ; - devices[i] = dev; +if (!i) +return ; - devname = p; - } - devices[i] =0 ; +printk (KERN_INFO "md: Loading md%s%d: %s\n" , + partitioned ?"_d" :"" , minor, + args->device_names); -if (!i) -continue ; + fd =ksys_open (name,0 ,0 ); +if (fd <0 ) { +printk (KERN_ERR "md: open failed - cannot start " +"array %s\n" , name); +return ; + } +if (ksys_ioctl (fd,SET_ARRAY_INFO ,0 ) == -EBUSY ) { +printk (KERN_WARNING +"md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n" , + minor); +ksys_close (fd); +return ; + } -printk (KERN_INFO "md: Loading md%s%d: %s\n" , - partitioned ?"_d" :"" , minor, - md_setup_args[ent].device_names); +if (args->level !=LEVEL_NONE ) { +/* non-persistent */ +mdu_array_info_t ainfo; + ainfo.level = args->level; + ainfo.size =0 ; + ainfo.nr_disks =0 ; + ainfo.raid_disks =0 ; +while (devices[ainfo.raid_disks]) + ainfo.raid_disks++; + ainfo.md_minor =minor; + ainfo.not_persistent =1 ; - fd =ksys_open (name,0 ,0 ); -if (fd <0 ) { -printk (KERN_ERR "md: open failed - cannot start " -"array %s\n" , name); -continue ; - } -if (ksys_ioctl (fd,SET_ARRAY_INFO ,0 ) == -EBUSY ) { -printk (KERN_WARNING -"md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n" , - minor); -ksys_close (fd); -continue ; + ainfo.state = (1 <<MD_SB_CLEAN ); + ainfo.layout =0 ; + ainfo.chunk_size = args->chunk; + err =ksys_ioctl (fd,SET_ARRAY_INFO , (long )&ainfo); +for (i =0 ; !err && i <=MD_SB_DISKS ; i++) { + dev = devices[i]; +if (!dev) +break ; + dinfo.number = i; + dinfo.raid_disk = i; + dinfo.state = (1 <<MD_DISK_ACTIVE )|(1 <<MD_DISK_SYNC ); + dinfo.major =MAJOR (dev); + dinfo.minor =MINOR (dev); + err =ksys_ioctl (fd,ADD_NEW_DISK , + (long )&dinfo); } - -if (md_setup_args[ent].level !=LEVEL_NONE ) { -/* non-persistent */ -mdu_array_info_t ainfo; - ainfo.level = md_setup_args[ent].level; - ainfo.size =0 ; - ainfo.nr_disks =0 ; - ainfo.raid_disks =0 ; -while (devices[ainfo.raid_disks]) - ainfo.raid_disks++; - ainfo.md_minor =minor; - ainfo.not_persistent =1 ; - - ainfo.state = (1 <<MD_SB_CLEAN ); - ainfo.layout =0 ; - ainfo.chunk_size = md_setup_args[ent].chunk; - err =ksys_ioctl (fd,SET_ARRAY_INFO , (long )&ainfo); -for (i =0 ; !err && i <=MD_SB_DISKS ; i++) { - dev = devices[i]; -if (!dev) -break ; - dinfo.number = i; - dinfo.raid_disk = i; - dinfo.state = (1 <<MD_DISK_ACTIVE )|(1 <<MD_DISK_SYNC ); - dinfo.major =MAJOR (dev); - dinfo.minor =MINOR (dev); - err =ksys_ioctl (fd,ADD_NEW_DISK , - (long )&dinfo); - } - }else { -/* persistent */ -for (i =0 ; i <=MD_SB_DISKS ; i++) { - dev = devices[i]; -if (!dev) -break ; - dinfo.major =MAJOR (dev); - dinfo.minor =MINOR (dev); -ksys_ioctl (fd,ADD_NEW_DISK , (long )&dinfo); - } + }else { +/* persistent */ +for (i =0 ; i <=MD_SB_DISKS ; i++) { + dev = devices[i]; +if (!dev) +break ; + dinfo.major =MAJOR (dev); + dinfo.minor =MINOR (dev); +ksys_ioctl (fd,ADD_NEW_DISK , (long )&dinfo); } -if (!err) - err =ksys_ioctl (fd,RUN_ARRAY ,0 ); -if (err) -printk (KERN_WARNING "md: starting md%d failed\n" , minor); -ksys_close (fd); } +if (!err) + err =ksys_ioctl (fd,RUN_ARRAY ,0 ); +if (err) +printk (KERN_WARNING "md: starting md%d failed\n" , minor); +ksys_close (fd); }static int __init raid_setup (char *str)
@@ -289,11 +284,15 @@ static void __init autodetect_raid(void)void __init md_run_setup (void ) { +int ent; +create_dev ("/dev/md0" ,MKDEV (MD_MAJOR ,0 ));if (raid_noautodetect)printk (KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=autodetect will force)\n" );else autodetect_raid (); -md_setup_drive (); + +for (ent =0 ; ent < md_setup_ents; ent++) +md_setup_drive (&md_setup_args[ent]); }
Signature · 1 line
2.26.2
PATCH 7/16 md: rewrite md_setup_drive to avoid ioctls
In reply to Christoph Hellwigmd_setup_drive knows it works with md devices, so it is rather pointless to open a file descriptor and issue ioctls. Just call directly into the relevant low-level md routines after getting a handle to the device using blkdev_get_by_dev instead.
--- drivers/md/md-autodetect.c | 127 ++++++++++++++++--------------------- drivers/md/md.c | 20 +++--- drivers/md/md.h | 6 ++ 3 files changed, 71 insertions(+), 82 deletions(-)
drivers/md/md-autodetect.c +56 -71
@@ -2,7 +2,6 @@#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>
@@ -120,37 +119,29 @@ 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 (struct md_setup_args *args) { -int minor, i, partitioned; -dev_t dev; -dev_t devices[MD_SB_DISKS +1 ]; -int fd; -int err =0 ; -char *devname; -mdu_disk_info_t dinfo; +char *devname = args->device_names; +dev_t devices[MD_SB_DISKS +1 ], mdev; +struct mdu_array_info_s ainfo = { }; +struct block_device *bdev; +struct mddev *mddev; +int err =0 , i;char name[16 ]; - minor = args->minor; - partitioned = args->partitioned; - devname = args->device_names; +if (args->partitioned) { + mdev =MKDEV (mdp_major, args->minor << MdpMinorShift); +sprintf (name,"md_d%d" , args->minor); + }else { + mdev =MKDEV (MD_MAJOR , args->minor); +sprintf (name,"md%d" , args->minor); + } -sprintf (name,"/dev/md%s%d" , partitioned?"_d" :"" , minor); -if (partitioned) - dev =MKDEV (mdp_major, minor << MdpMinorShift); -else - dev =MKDEV (MD_MAJOR , minor); -create_dev (name, dev);for (i =0 ; i <MD_SB_DISKS && devname !=NULL ; i++) {struct kstat stat;char *p;char comp_name[64 ]; +dev_t dev; p =strchr (devname,',' );if (p)
@@ -163,7 +154,7 @@ static void __init md_setup_drive(struct md_setup_args *args)if (vfs_stat (comp_name, &stat) ==0 &&S_ISBLK (stat.mode)) dev =new_decode_dev (stat.rdev);if (!dev) { -printk (KERN_WARNING "md: Unknown device name: %s\n" , devname); +pr_warn ("md: Unknown device name: %s\n" , devname);break ; }
@@ -175,68 +166,64 @@ static void __init md_setup_drive(struct md_setup_args *args)if (!i)return ; -printk (KERN_INFO "md: Loading md%s%d: %s\n" , - partitioned ?"_d" :"" , minor, - args->device_names); +pr_info ("md: Loading %s: %s\n" , name, args->device_names); - fd =ksys_open (name,0 ,0 ); -if (fd <0 ) { -printk (KERN_ERR "md: open failed - cannot start " -"array %s\n" , name); + bdev =blkdev_get_by_dev (mdev,FMODE_READ ,NULL ); +if (IS_ERR (bdev)) { +pr_err ("md: open failed - cannot start array %s\n" , name);return ; } -if (ksys_ioctl (fd,SET_ARRAY_INFO ,0 ) == -EBUSY ) { -printk (KERN_WARNING -"md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n" , - minor); -ksys_close (fd); -return ; + mddev = bdev->bd_disk->private_data; + + err =mddev_lock (mddev); +if (err) { +pr_err ("md: failed to lock array %s\n" , name); + goto out_blkdev_put; + } + +if (!list_empty (&mddev->disks) || mddev->raid_disks) { +pr_warn ("md: Ignoring %s, already autodetected. (Use raid=noautodetect)\n" , + name); + goto out_unlock; }if (args->level !=LEVEL_NONE ) {/* non-persistent */ -mdu_array_info_t ainfo; ainfo.level = args->level; - ainfo.size =0 ; - ainfo.nr_disks =0 ; - ainfo.raid_disks =0 ; -while (devices[ainfo.raid_disks]) - ainfo.raid_disks++; - ainfo.md_minor =minor; + ainfo.md_minor = args->minor; ainfo.not_persistent =1 ; - ainfo.state = (1 <<MD_SB_CLEAN ); - ainfo.layout =0 ; ainfo.chunk_size = args->chunk; - err =ksys_ioctl (fd,SET_ARRAY_INFO , (long )&ainfo); -for (i =0 ; !err && i <=MD_SB_DISKS ; i++) { - dev = devices[i]; -if (!dev) -break ; +while (devices[ainfo.raid_disks]) + ainfo.raid_disks++; + } + + err =md_set_array_info (mddev, &ainfo); + +for (i =0 ; i <=MD_SB_DISKS && devices[i]; i++) { +struct mdu_disk_info_s dinfo = { + .major =MAJOR (devices[i]), + .minor =MINOR (devices[i]), + }; + +if (args->level !=LEVEL_NONE ) { dinfo.number = i; dinfo.raid_disk = i; - dinfo.state = (1 <<MD_DISK_ACTIVE )|(1 <<MD_DISK_SYNC ); - dinfo.major =MAJOR (dev); - dinfo.minor =MINOR (dev); - err =ksys_ioctl (fd,ADD_NEW_DISK , - (long )&dinfo); - } - }else { -/* persistent */ -for (i =0 ; i <=MD_SB_DISKS ; i++) { - dev = devices[i]; -if (!dev) -break ; - dinfo.major =MAJOR (dev); - dinfo.minor =MINOR (dev); -ksys_ioctl (fd,ADD_NEW_DISK , (long )&dinfo); + dinfo.state = + (1 <<MD_DISK_ACTIVE ) | (1 <<MD_DISK_SYNC ); } + +md_add_new_disk (mddev, &dinfo); } +if (!err) - err =ksys_ioctl (fd,RUN_ARRAY ,0 ); + err =do_md_run (mddev);if (err) -printk (KERN_WARNING "md: starting md%d failed\n" , minor); -ksys_close (fd); +pr_warn ("md: starting %s failed\n" , name); +out_unlock: +mddev_unlock (mddev); +out_blkdev_put: +blkdev_put (bdev,FMODE_READ ); }static int __init raid_setup (char *str)
@@ -286,8 +273,6 @@ void __init md_run_setup(void) {int ent; -create_dev ("/dev/md0" ,MKDEV (MD_MAJOR ,0 )); -if (raid_noautodetect)printk (KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=autodetect will force)\n" );else
drivers/md/md.c +9 -11
@@ -4368,7 +4368,6 @@ array_state_show(struct mddev *mddev, char *page)static int do_md_stop (struct mddev *mddev,int ro,struct block_device *bdev);static int md_set_readonly (struct mddev *mddev,struct block_device *bdev); -static int do_md_run (struct mddev *mddev);static int restart_array (struct mddev *mddev); static ssize_t
@@ -6015,7 +6014,7 @@ int md_run(struct mddev *mddev) }EXPORT_SYMBOL_GPL (md_run); -static int do_md_run (struct mddev *mddev) +int do_md_run (struct mddev *mddev) {int err;
@@ -6651,7 +6650,7 @@ static int get_disk_info(struct mddev *mddev, void __user * arg)return 0 ; } -static int add_new_disk (struct mddev *mddev,mdu_disk_info_t *info) +int md_add_new_disk (struct mddev *mddev,struct mdu_disk_info_s *info) {char b[BDEVNAME_SIZE ], b2[BDEVNAME_SIZE ];struct md_rdev *rdev;
@@ -6697,7 +6696,7 @@ static int add_new_disk(struct mddev *mddev, mdu_disk_info_t *info) }/* -* add_new_disk can be used once the array is assembled +* md_add_new_disk can be used once the array is assembled * to add "hot spares". They must already have a superblock * written */
@@ -6810,7 +6809,7 @@ static int add_new_disk(struct mddev *mddev, mdu_disk_info_t *info)return err; } -/* otherwise, add_new_disk is only allowed +/* otherwise, md_add_new_disk is only allowed * for major_version==0 superblocks */ if (mddev->major_version !=0 ) {
@@ -7055,7 +7054,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd) }/* -* set_array_info is used two different ways +* md_set_array_info is used two different ways * The original usage is when creating a new array. * In this usage, raid_disks is > 0 and it together with * level, size, not_persistent,layout,chunksize determine the
@@ -7067,9 +7066,8 @@ static int set_bitmap_file(struct mddev *mddev, int fd)* The minor and patch _version numbers are also kept incase the * super_block handler wishes to interpret them. */ -static int set_array_info (struct mddev *mddev,mdu_array_info_t *info) +int md_set_array_info (struct mddev *mddev,struct mdu_array_info_s *info) { -if (info->raid_disks ==0 ) {/* just setting version number for superblock loading */ if (info->major_version < 0 ||
@@ -7560,7 +7558,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, err = -EBUSY ; goto unlock; } - err =set_array_info (mddev, &info); + err =md_set_array_info (mddev, &info);if (err) {pr_warn ("md: couldn't set array info. %d\n" , err); goto unlock;
@@ -7614,7 +7612,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,/* Need to clear read-only for this */ break ; else - err =add_new_disk (mddev, &info); + err =md_add_new_disk (mddev, &info); goto unlock; }break ;
@@ -7682,7 +7680,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,if (copy_from_user (&info, argp,sizeof (info))) err = -EFAULT ;else - err =add_new_disk (mddev, &info); + err =md_add_new_disk (mddev, &info); goto unlock; }
drivers/md/md.h +6 -0
@@ -801,7 +801,13 @@ static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio *bio mddev->queue->limits.max_write_zeroes_sectors = 0; } +struct mdu_array_info_s ; +struct mdu_disk_info_s ; +extern int mdp_major;void md_autostart_arrays (int part); +int md_set_array_info (struct mddev *mddev,struct mdu_array_info_s *info); +int md_add_new_disk (struct mddev *mddev,struct mdu_disk_info_s *info); +int do_md_run (struct mddev *mddev);#endif /* _MD_MD_H */
Signature · 1 line
2.26.2
PATCH 8/16 initrd: remove support for multiple floppies
In reply to Christoph HellwigRemove the special handling for multiple floppies in the initrd code. No one should be using floppies for booting these days. (famous last words..)
--- arch/arm/kernel/atags_parse.c | 2 - arch/sh/kernel/setup.c | 2 - arch/sparc/kernel/setup_32.c | 2 - arch/sparc/kernel/setup_64.c | 2 - arch/x86/kernel/setup.c | 2 - include/linux/initrd.h | 6 --- init/do_mounts.c | 69 ++++------------------------------- init/do_mounts.h | 1 - init/do_mounts_rd.c | 20 +++------- 9 files changed, 12 insertions(+), 94 deletions(-)
arch/arm/kernel/atags_parse.c +0 -2
@@ -91,8 +91,6 @@ __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);static int __init parse_tag_ramdisk (const struct tag *tag) { rd_image_start = tag->u.ramdisk.start; - rd_doload = (tag->u.ramdisk.flags &1 ) ==0 ; - rd_prompt = (tag->u.ramdisk.flags &2 ) ==0 ;if (tag->u.ramdisk.size) rd_size = tag->u.ramdisk.size;
arch/sh/kernel/setup.c +0 -2
@@ -290,8 +290,6 @@ void __init setup_arch(char **cmdline_p)#ifdef CONFIG_BLK_DEV_RAM rd_image_start =RAMDISK_FLAGS &RAMDISK_IMAGE_START_MASK ; - rd_prompt = ((RAMDISK_FLAGS &RAMDISK_PROMPT_FLAG ) !=0 ); - rd_doload = ((RAMDISK_FLAGS &RAMDISK_LOAD_FLAG ) !=0 );#endif if (!MOUNT_ROOT_RDONLY )
arch/sparc/kernel/setup_32.c +0 -2
@@ -353,8 +353,6 @@ void __init setup_arch(char **cmdline_p)ROOT_DEV =old_decode_dev (root_dev);#ifdef CONFIG_BLK_DEV_RAM rd_image_start = ram_flags &RAMDISK_IMAGE_START_MASK ; - rd_prompt = ((ram_flags &RAMDISK_PROMPT_FLAG ) !=0 ); - rd_doload = ((ram_flags &RAMDISK_LOAD_FLAG ) !=0 );#endif prom_setsync (prom_sync_me);
arch/sparc/kernel/setup_64.c +0 -2
@@ -659,8 +659,6 @@ void __init setup_arch(char **cmdline_p)ROOT_DEV =old_decode_dev (root_dev);#ifdef CONFIG_BLK_DEV_RAM rd_image_start = ram_flags &RAMDISK_IMAGE_START_MASK ; - rd_prompt = ((ram_flags &RAMDISK_PROMPT_FLAG ) !=0 ); - rd_doload = ((ram_flags &RAMDISK_LOAD_FLAG ) !=0 );#endif task_thread_info (&init_task)->kregs = &fake_swapper_regs;
arch/x86/kernel/setup.c +0 -2
@@ -870,8 +870,6 @@ void __init setup_arch(char **cmdline_p)#ifdef CONFIG_BLK_DEV_RAM rd_image_start = boot_params.hdr.ram_size &RAMDISK_IMAGE_START_MASK ; - rd_prompt = ((boot_params.hdr.ram_size &RAMDISK_PROMPT_FLAG ) !=0 ); - rd_doload = ((boot_params.hdr.ram_size &RAMDISK_LOAD_FLAG ) !=0 );#endif #ifdef CONFIG_EFI if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
include/linux/initrd.h +0 -6
@@ -2,12 +2,6 @@#define INITRD_MINOR 250/* shouldn't collide with /dev/ram* too soon ... */ -/* 1 = load ramdisk, 0 = don't load */ -extern int rd_doload; - -/* 1 = prompt for ramdisk, 0 = don't prompt */ -extern int rd_prompt; -/* starting block # of image */ extern int rd_image_start;
init/do_mounts.c +7 -62
107 lines not on this page · raw message
init/do_mounts.h +0 -1
@@ -9,7 +9,6 @@#include <linux/major.h> #include <linux/root_dev.h> -void change_floppy (char *fmt, ...);void mount_block_root (char *name,int flags);void mount_root (void );extern int root_mountflags;
init/do_mounts_rd.c +5 -15
@@ -15,11 +15,9 @@#include <linux/decompress/generic.h> -int __initdata rd_prompt =1 ;/* 1 = prompt for RAM disk, 0 = don't prompt */ -static int __init prompt_ramdisk (char *str) { - rd_prompt =simple_strtol (str,NULL ,0 ) &1 ; +pr_warn ("ignoring the depreated prompt_ramdisk= option\n" );return 1 ; }__setup ("prompt_ramdisk=" , prompt_ramdisk);
@@ -178,7 +176,7 @@ int __init rd_load_image(char *from)int res =0 ;int in_fd, out_fd;unsigned long rd_blocks, devblocks; -int nblocks, i, disk; +int nblocks, i;char *buf =NULL ;unsigned short rotate =0 ;decompress_fn decompressor =NULL ;
@@ -243,21 +241,15 @@ int __init rd_load_image(char *from)printk (KERN_NOTICE "RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... " , nblocks, ((nblocks-1 )/devblocks)+1 , nblocks>devblocks ?"s" :"" ); -for (i =0 , disk =1 ; i < nblocks; i++) { +for (i =0 ; i < nblocks; i++) {if (i && (i % devblocks ==0 )) { -pr_cont ("done disk #%d.\n" , disk++); +pr_cont ("done disk #1.\n" ); rotate =0 ;if (ksys_close (in_fd)) {printk ("Error closing the disk.\n" ); goto noclose_input; } -change_floppy ("disk #%d" , disk); - in_fd =ksys_open (from,O_RDONLY ,0 ); -if (in_fd <0 ) { -printk ("Error opening disk.\n" ); - goto noclose_input; - } -printk ("Loading disk #%d... " , disk); +break ; }ksys_read (in_fd, buf,BLOCK_SIZE );ksys_write (out_fd, buf,BLOCK_SIZE );
@@ -284,8 +276,6 @@ int __init rd_load_image(char *from)int __init rd_load_disk (int n) { -if (rd_prompt) -change_floppy ("root floppy disk to be loaded into RAM disk" );create_dev ("/dev/root" ,ROOT_DEV );create_dev ("/dev/ram" ,MKDEV (RAMDISK_MAJOR , n));return rd_load_image ("/dev/root" );
Signature · 1 line
2.26.2
PATCH 9/16 initrd: remove the BLKFLSBUF call in handle_initrd
In reply to Christoph HellwigBLKFLSBUF used to be overloaded for the ramdisk driver to free the whole ramdisk, which was completely different behavior compared to all other drivers. But this magic overload got removed in commit ff26956875c2 ("brd: remove support for BLKFLSBUF"), so this call is entirely pointless now.
--- init/do_mounts_initrd.c | 9 --------- 1 file changed, 9 deletions(-)
init/do_mounts_initrd.c +0 -9
@@ -115,21 +115,12 @@ static void __init handle_initrd(void)if (!error)printk ("okay\n" );else { -int fd =ksys_open ("/dev/root.old" ,O_RDWR ,0 );if (error == -ENOENT )printk ("/initrd does not exist. Ignored.\n" );else printk ("failed\n" );printk (KERN_NOTICE "Unmounting old root\n" );ksys_umount ("/old" ,MNT_DETACH ); -printk (KERN_NOTICE "Trying to free ramdisk memory ... " ); -if (fd <0 ) { - error = fd; - }else { - error =ksys_ioctl (fd,BLKFLSBUF ,0 ); -ksys_close (fd); - } -printk (!error ?"okay\n" :"failed\n" ); } }
Signature · 1 line
2.26.2
H. Peter Anvin
reviewerRe: [PATCH 09/16] initrd: remove the BLKFLSBUF call in handle_initrd
Quoted 7 lines · Christoph Hellwig
BLKFLSBUF used to be overloaded for the ramdisk driver to free the whole ramdisk, which was completely different behavior compared to all other drivers. But this magic overload got removed in commit
ff26956875c2("brd: remove support for BLKFLSBUF"), so this call is entirely pointless now.Signed-off-by Christoph Hellwig <[email protected]>
Does *anyone* use initrd as opposed to initramfs anymore? It would seem like a good candidate for deprecation/removal.
-hpa
Re: [PATCH 09/16] initrd: remove the BLKFLSBUF call in handle_initrd
Quoted 7 lines · H. Peter Anvin
Quoted 6 lines · Christoph Hellwig
BLKFLSBUF used to be overloaded for the ramdisk driver to free the whole ramdisk, which was completely different behavior compared to all other drivers. But this magic overload got removed in commit
ff26956875c2("brd: remove support for BLKFLSBUF"), so this call is entirely pointless now.
Quoted 5 lines
Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>Does *anyone* use initrd as opposed to initramfs anymore? It would seem like a good candidate for deprecation/removal.
Reading the gentoo mailing list, it seems there's a fair few people who don't use initramfs. I get the impression they don't use initrd either, though.
I don't know too much about booting without an initramfs - I switched ages ago - so what is possible and what they're actually doing, I don't know.
Cheers,
Wol
[email protected]
reviewerRe: [PATCH 09/16] initrd: remove the BLKFLSBUF call in handle_initrd
Quoted 22 lines · antlists
Quoted 2 lines · H. Peter Anvin
Quoted 1 line · Christoph Hellwig
BLKFLSBUF used to be overloaded for the ramdisk driver to free the
whole
Quoted 1 line
Quoted 1 line
ramdisk, which was completely different behavior compared to all
other
Quoted 7 lines
Quoted 5 lines
drivers. But this magic overload got removed in commit
ff26956875c2("brd: remove support for BLKFLSBUF"), so this call is entirely pointless now.Signed-off-by Christoph Hellwig <[email protected]>Does *anyone* use initrd as opposed to initramfs anymore? It would
seem
Quoted 2 lines
like a good candidate for deprecation/removal.
Reading the gentoo mailing list, it seems there's a fair few people who
don't use initramfs. I get the impression they don't use initrd either,
though.
Quoted 7 lines
I don't know too much about booting without an initramfs - I switched ages ago - so what is possible and what they're actually doing, I don't
know.
Cheers,
Wol
Not using any init userspace at all is an entirely different issue.
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Re: [PATCH 09/16] initrd: remove the BLKFLSBUF call in handle_initrd
In reply to H. Peter AnvinQuoted 11 lines · H. Peter Anvin
Quoted 7 lines · Christoph Hellwig
BLKFLSBUF used to be overloaded for the ramdisk driver to free the whole ramdisk, which was completely different behavior compared to all other drivers. But this magic overload got removed in commit
ff26956875c2("brd: remove support for BLKFLSBUF"), so this call is entirely pointless now.Signed-off-by Christoph Hellwig <[email protected]>Does *anyone* use initrd as opposed to initramfs anymore? It would seem like a good candidate for deprecation/removal.
I thought about that as well. I think deprecating it at least is a good idea and can add a patch doing that to the next version.
PATCH 10/16 initrd: switch initrd loading to struct file based APIs
In reply to Christoph HellwigThere is no good reason to mess with file descriptors from in-kernel code, switch the initrd loading to struct file based read and writes instead.
--- fs/read_write.c | 2 +- include/linux/syscalls.h | 1 - init/do_mounts_rd.c | 82 ++++++++++++++++++++-------------------- 3 files changed, 43 insertions(+), 42 deletions(-)
fs/read_write.c +1 -1
@@ -301,7 +301,7 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int whence) }EXPORT_SYMBOL (vfs_llseek); -off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence) +static off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence) {off_t retval;struct fd f =fdget_pos (fd);
include/linux/syscalls.h +0 -1
@@ -1246,7 +1246,6 @@ int ksys_fchown(unsigned int fd, uid_t user, gid_t group);int ksys_getdents64 (unsigned int fd,struct linux_dirent64 __user *dirent,unsigned int count);int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg); -off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence);ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count);void ksys_sync (void );int ksys_unshare (unsigned long unshare_flags);
init/do_mounts_rd.c +42 -40
197 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 11/16 initrd: mark init_linuxrc as __init
In reply to Christoph Hellwig--- init/do_mounts_initrd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init/do_mounts_initrd.c +1 -1
@@ -56,7 +56,7 @@ static int __init early_initrd(char *p) }early_param ("initrd" , early_initrd); -static int init_linuxrc (struct subprocess_info *info,struct cred *new) +static int __init init_linuxrc (struct subprocess_info *info,struct cred *new) {ksys_unshare (CLONE_FS |CLONE_FILES );console_on_rootfs ();
Signature · 1 line
2.26.2
PATCH 12/16 initramfs: remove the populate_initrd_image and clean_rootfs stubs
In reply to Christoph HellwigIf initrd support is not enable just print the warning directly instead of hiding the fact that we just failed behind two stub functions.
--- init/initramfs.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
init/initramfs.c +4 -11
@@ -618,13 +618,7 @@ static void __init clean_rootfs(void)ksys_close (fd);kfree (buf); } -#else -static inline void clean_rootfs (void ) -{ -} -#endif /* CONFIG_BLK_DEV_RAM */ -#ifdef CONFIG_BLK_DEV_RAM static void __init populate_initrd_image (char *err) {ssize_t written;
@@ -644,11 +638,6 @@ static void __init populate_initrd_image(char *err) written, initrd_end - initrd_start); ksys_close(fd); } -#else -static void __init populate_initrd_image (char *err) -{ -printk (KERN_EMERG "Initramfs unpacking failed: %s\n" , err); -}#endif /* CONFIG_BLK_DEV_RAM */ static int __init populate_rootfs (void )
@@ -668,8 +657,12 @@ static int __init populate_rootfs(void) err =unpack_to_rootfs ((char *)initrd_start, initrd_end - initrd_start);if (err) { +#ifdef CONFIG_BLK_DEV_RAM clean_rootfs ();populate_initrd_image (err); +#else +printk (KERN_EMERG "Initramfs unpacking failed: %s\n" , err); +#endif } done:
Signature · 1 line
2.26.2
PATCH 13/16 initramfs: simplify clean_rootfs
In reply to Christoph HellwigJust use d_genocide instead of iterating through the root directory with cumbersome userspace-like APIs. This also ensures we actually remove files that are not direct children of the root entry, which the old code failed to do.
--- fs/readdir.c | 11 ++-------- include/linux/syscalls.h | 2 -- init/initramfs.c | 46 +++++----------------------------------- 3 files changed, 7 insertions(+), 52 deletions(-)
fs/readdir.c +2 -9
@@ -348,8 +348,8 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,return -EFAULT ; } -int ksys_getdents64 (unsigned int fd,struct linux_dirent64 __user *dirent, -unsigned int count) +SYSCALL_DEFINE3(getdents64, unsigned int, fd, + struct linux_dirent64 __user *, dirent, unsigned int, count) {struct fd f;struct getdents_callback64 buf = {
@@ -380,13 +380,6 @@ int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,return error; } - -SYSCALL_DEFINE3(getdents64, unsigned int, fd, - struct linux_dirent64 __user *, dirent, unsigned int, count) -{ -return ksys_getdents64 (fd, dirent, count); -} - #ifdef CONFIG_COMPAT struct compat_old_linux_dirent { compat_ulong_t d_ino;
include/linux/syscalls.h +0 -2
@@ -1243,8 +1243,6 @@ ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);int ksys_chdir (const char __user *filename);int ksys_fchmod (unsigned int fd,umode_t mode);int ksys_fchown (unsigned int fd,uid_t user,gid_t group); -int ksys_getdents64 (unsigned int fd,struct linux_dirent64 __user *dirent, -unsigned int count);int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg);ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count);void ksys_sync (void );
init/initramfs.c +5 -41
62 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 14/16 initramfs: switch initramfs unpacking to struct file based APIs
In reply to Christoph HellwigThere is no good reason to mess with file descriptors from in-kernel code, switch the initramfs unpacking to struct file based write instead. As we don't have nice helper for chmod or chown on a struct file or struct path use the pathname based ones instead there. This causes additional (cached) lookups, but keeps the code much simpler.
--- fs/open.c | 7 +------ include/linux/syscalls.h | 1 - init/initramfs.c | 42 ++++++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 28 deletions(-)
fs/open.c +1 -6
@@ -602,7 +602,7 @@ static int chmod_common(const struct path *path, umode_t mode)return error; } -int ksys_fchmod (unsigned int fd,umode_t mode) +SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) {struct fd f =fdget (fd);int err = -EBADF ;
@@ -615,11 +615,6 @@ int ksys_fchmod(unsigned int fd, umode_t mode)return err; } -SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) -{ -return ksys_fchmod (fd, mode); -} -int do_fchmodat (int dfd,const char __user *filename,umode_t mode) {struct path path;
include/linux/syscalls.h +0 -1
@@ -1241,7 +1241,6 @@ int ksys_dup(unsigned int fildes);int ksys_chroot (const char __user *filename);ssize_t ksys_write (unsigned int fd,const char __user *buf,size_t count);int ksys_chdir (const char __user *filename); -int ksys_fchmod (unsigned int fd,umode_t mode);int ksys_fchown (unsigned int fd,uid_t user,gid_t group);int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg);ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count);
init/initramfs.c +21 -21
94 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 15/16 init: open code setting up stdin/stdout/stderr
In reply to Christoph HellwigDon't rely on the implicit set_fs(KERNEL_DS) for ksys_open to work, but instead open a struct file for /dev/console and then install it as FD 0/1/2 manually.
--- fs/file.c | 7 +------ include/linux/syscalls.h | 1 - init/main.c | 16 ++++++++++------ 3 files changed, 11 insertions(+), 13 deletions(-)
fs/file.c +1 -6
@@ -985,7 +985,7 @@ SYSCALL_DEFINE2(dup2, unsigned int, oldfd, unsigned int, newfd)return ksys_dup3 (oldfd, newfd,0 ); } -int ksys_dup (unsigned int fildes) +SYSCALL_DEFINE1(dup, unsigned int, fildes) {int ret = -EBADF ;struct file *file =fget_raw (fildes);
@@ -1000,11 +1000,6 @@ int ksys_dup(unsigned int fildes)return ret; } -SYSCALL_DEFINE1(dup, unsigned int, fildes) -{ -return ksys_dup (fildes); -} -int f_dupfd (unsigned int from,struct file *file,unsigned flags) {int err;
include/linux/syscalls.h +0 -1
@@ -1237,7 +1237,6 @@ asmlinkage long sys_ni_syscall(void);*/ int ksys_umount (char __user *name,int flags); -int ksys_dup (unsigned int fildes);int ksys_chroot (const char __user *filename);ssize_t ksys_write (unsigned int fd,const char __user *buf,size_t count);int ksys_chdir (const char __user *filename);
init/main.c +10 -6
@@ -1457,15 +1457,19 @@ static int __ref kernel_init(void *unused) "See Linux Documentation/admin-guide/init.rst for guidance."); } +/* Open /dev/console, for stdin/stdout/stderr, this should never fail */ void console_on_rootfs (void ) { -/* Open the /dev/console as stdin, this should never fail */ -if (ksys_open ((const char __user *)"/dev/console" ,O_RDWR ,0 ) <0 ) -pr_err ("Warning: unable to open an initial console.\n" ); +struct file *file =filp_open ("/dev/console" ,O_RDWR ,0 ); -/* create stdout/stderr */ - (void )ksys_dup (0 ); - (void )ksys_dup (0 ); +if (IS_ERR (file)) { +pr_err ("Warning: unable to open an initial console.\n" ); +return ; + } +get_file_rcu_many (file,2 ); +fd_install (get_unused_fd_flags (0 ), file); +fd_install (get_unused_fd_flags (0 ), file); +fd_install (get_unused_fd_flags (0 ), file); } static noinline void __init kernel_init_freeable(void)
Signature · 1 line
2.26.2
PATCH 16/16 fs: remove ksys_open
In reply to Christoph HellwigJust open code it in the two callers.
--- fs/open.c | 11 ++++++++--- include/linux/syscalls.h | 11 ----------- 2 files changed, 8 insertions(+), 14 deletions(-)
fs/open.c +8 -3
@@ -1193,7 +1193,9 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) { -return ksys_open (filename, flags, mode); +if (force_o_largefile ()) + flags |=O_LARGEFILE ; +return do_sys_open (AT_FDCWD , filename, flags, mode); } SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
@@ -1255,9 +1257,12 @@ COMPAT_SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, fla*/ SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode) { -return ksys_open (pathname,O_CREAT |O_WRONLY |O_TRUNC , mode); -} +int flags =O_CREAT |O_WRONLY |O_TRUNC ; +if (force_o_largefile ()) + flags |=O_LARGEFILE ; +return do_sys_open (AT_FDCWD , pathname, flags, mode); +}#endif /*
include/linux/syscalls.h +0 -11
@@ -1372,17 +1372,6 @@ static inline int ksys_close(unsigned int fd)return __close_fd (current->files, fd); } -extern long do_sys_open (int dfd,const char __user *filename,int flags, -umode_t mode); - -static inline long ksys_open (const char __user *filename,int flags, -umode_t mode) -{ -if (force_o_largefile ()) - flags |=O_LARGEFILE ; -return do_sys_open (AT_FDCWD , filename, flags, mode); -} -extern long do_sys_truncate (const char __user *pathname,loff_t length);static inline long ksys_truncate (const char __user *pathname,loff_t length)
Signature · 1 line
2.26.2
Quoted 6 lines · Christoph Hellwig
Hi all,
this series starts to move the early init code away from requiring
KERNEL_DSto be implicitly set during early startup. It does so by first removing legacy unused cruft, and the switches away the code from struct file based APIs to our more usual in-kernel APIs.
Hi,
Would it be possible to get a series diffstat in your patch cover letters as a regular thing, please?
thanks.
Signature · 1 line
~Randy