Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp313639pxj; Thu, 17 Jun 2021 03:23:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuYbR4xRynRZT5HXKKxi3QqVRfnxruolmLoW9bBcrV/ILZRFvAUFD7cFNt4rK7rA8UDfxW X-Received: by 2002:aa7:d642:: with SMTP id v2mr3540794edr.267.1623925405735; Thu, 17 Jun 2021 03:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623925405; cv=none; d=google.com; s=arc-20160816; b=RL2UMxgs8IDr2SnHILwHPfeYmFEfeABaQC4gMj52o5EaFvafYJFvslexX/l66DmCwy Sn6tM+X8M5vxv62WWCQaJ/J5s7ZkTZSGCVpVazFpb4DyJPg87ADENXgoqFn0o8D1byUo K8mSsna5eKD3Z9insWfWFqwEdcx2gdChRdUTxF0ii8uZ4ebgXHdtK5DSQo0kDjwdVRdy hhPshxHTKqpDd8taul5ib4T1DTW0tw1XfnaSxorMxudcCWEETgmy7awMEmw8WbY/i4Di nN9RG9N+JLIjueW76qmMQbeXeQZcmTLogIs25vaI1IbFsxTj/SI0TctDxCIk4wXaUh33 wQjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1rcaBiYMmxbTIzBSP4Lkyvlkc2KdB5uGKfAUxQ6B2a4=; b=lHoYqv6xgntaZuuRWNrRglsTmCYNzF5XdiM17zkLGvga5civcHv0XPC96RQh42WUQg nAhZKrC9wx++gvskJjG5nl3xW+3vJzIaDFNenp1GjB7I4vdKybrzVIHPoa6qx3+AbUvk td89z4Rz4swRpzJb+5yrKmXwBUAqRgqkUaHVd7YyRDR1J+rNoohLsEw99+PaVZzBTfzu yE+1jG0bvH2WFQ5J2vtm0XILNQtFeG9uVqcRzFI97x2/p3o7hSuZ/5Yq0xXUJFZqc6vf hYMqr6j1CEJZ8SRZG4Qiz3tIzvI5cGubL5nrRLBibxo9GKWFU5qv6exhx+cKVIOo5Avj nzjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nTtzOYyH; 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 bz26si1593407ejc.672.2021.06.17.03.23.02; Thu, 17 Jun 2021 03:23:25 -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=pass header.i=@infradead.org header.s=casper.20170209 header.b=nTtzOYyH; 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 S229891AbhFQKQc (ORCPT + 99 others); Thu, 17 Jun 2021 06:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbhFQKQX (ORCPT ); Thu, 17 Jun 2021 06:16:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E82C061574; Thu, 17 Jun 2021 03:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1rcaBiYMmxbTIzBSP4Lkyvlkc2KdB5uGKfAUxQ6B2a4=; b=nTtzOYyH5nOB+rP0PzOPnj6I+b Kznx/IAocBctaMmCDpRBXcNsJOFm5Rx3yGsLm+PWWxWHDhmzH2k4knlIjyqz0MxafD79FV3ZF6Dp1 Vx2s7YvaIQb+zKW4icpwpqz9MhyVR/6AWFOkICqel2DCojYafEI3tTZadCaGq8y08Kl9ybex3TajK qBTiX7TxTBkTKx5ClUNwC+i5dm/NVFXzhWnmUauAfJR3DgZy4hWMn3tOFJiL/w0rLP5boCXZN9vB8 CTEExFY0i1HAry95jafbWjRvtbwQn/snQQYYccuM4Y3dngmmwxqibc25LV8ViDP1qTT+6XSdSVZ+f vdNdIovw==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltp28-0090SY-Ou; Thu, 17 Jun 2021 10:14:04 +0000 Date: Thu, 17 Jun 2021 11:14:00 +0100 From: Christoph Hellwig To: Vivek Goyal Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, virtio-fs@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, viro@zeniv.linux.org.uk, dhowells@redhat.com, richard.weinberger@gmail.com, hch@infradead.org, asmadeus@codewreck.org, v9fs-developer@lists.sourceforge.net Subject: Re: [PATCH v2 0/2] Add support to boot virtiofs and 9pfs as rootfs Message-ID: References: <20210614174454.903555-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210614174454.903555-1-vgoyal@redhat.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Why not something like the version below that should work for all nodev file systems? diff --git a/init/do_mounts.c b/init/do_mounts.c index 74aede860de7..3c5676603fef 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -530,6 +530,39 @@ static int __init mount_cifs_root(void) } #endif +static int __init mount_nodev_root(void) +{ + struct file_system_type *fs = get_fs_type(root_fs_names); + char *fs_names, *p; + int err = -ENODEV; + + if (!fs) + goto out; + if (fs->fs_flags & FS_REQUIRES_DEV) + goto out_put_filesystem; + + fs_names = (void *)__get_free_page(GFP_KERNEL); + if (!fs_names) + goto out_put_filesystem; + get_fs_names(fs_names); + + for (p = fs_names; *p; p += strlen(p) + 1) { + err = do_mount_root(root_device_name, p, root_mountflags, + root_mount_data); + if (!err) + break; + if (err != -EACCES && err != -EINVAL) + panic("VFS: Unable to mount root \"%s\" (%s), err=%d\n", + root_device_name, p, err); + } + + free_page((unsigned long)fs_names); +out_put_filesystem: + put_filesystem(fs); +out: + return err; +} + void __init mount_root(void) { #ifdef CONFIG_ROOT_NFS @@ -546,6 +579,8 @@ void __init mount_root(void) return; } #endif + if (ROOT_DEV == 0 && mount_nodev_root() == 0) + return; #ifdef CONFIG_BLOCK { int err = create_dev("/dev/root", ROOT_DEV);