License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1995, 1996 Gero Kuhlmann <gero@gkminix.han.de>
|
|
|
|
*
|
|
|
|
* Allow an NFS filesystem to be mounted as root. The way this works is:
|
|
|
|
* (1) Use the IP autoconfig mechanism to set local IP addresses and routes.
|
2010-09-17 14:54:37 +00:00
|
|
|
* (2) Construct the device string and the options string using DHCP
|
|
|
|
* option 17 and/or kernel command line options.
|
|
|
|
* (3) When mount_root() sets up the root file system, pass these strings
|
|
|
|
* to the NFS client's regular mount interface via sys_mount().
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
*
|
|
|
|
* Alan Cox : Removed get_address name clash with FPU.
|
|
|
|
* Alan Cox : Reformatted a bit.
|
|
|
|
* Gero Kuhlmann : Code cleanup
|
|
|
|
* Michael Rausch : Fixed recognition of an incoming RARP answer.
|
|
|
|
* Martin Mares : (2.0) Auto-configuration via BOOTP supported.
|
|
|
|
* Martin Mares : Manual selection of interface & BOOTP/RARP.
|
|
|
|
* Martin Mares : Using network routes instead of host routes,
|
|
|
|
* allowing the default configuration to be used
|
|
|
|
* for normal operation of the host.
|
|
|
|
* Martin Mares : Randomized timer with exponential backoff
|
|
|
|
* installed to minimize network congestion.
|
|
|
|
* Martin Mares : Code cleanup.
|
|
|
|
* Martin Mares : (2.1) BOOTP and RARP made configuration options.
|
|
|
|
* Martin Mares : Server hostname generation fixed.
|
|
|
|
* Gerd Knorr : Fixed wired inode handling
|
|
|
|
* Martin Mares : (2.2) "0.0.0.0" addresses from command line ignored.
|
|
|
|
* Martin Mares : RARP replies not tested for server address.
|
|
|
|
* Gero Kuhlmann : (2.3) Some bug fixes and code cleanup again (please
|
|
|
|
* send me your new patches _before_ bothering
|
|
|
|
* Linus so that I don' always have to cleanup
|
|
|
|
* _afterwards_ - thanks)
|
|
|
|
* Gero Kuhlmann : Last changes of Martin Mares undone.
|
|
|
|
* Gero Kuhlmann : RARP replies are tested for specified server
|
|
|
|
* again. However, it's now possible to have
|
|
|
|
* different RARP and NFS servers.
|
|
|
|
* Gero Kuhlmann : "0.0.0.0" addresses from command line are
|
|
|
|
* now mapped to INADDR_NONE.
|
|
|
|
* Gero Kuhlmann : Fixed a bug which prevented BOOTP path name
|
|
|
|
* from being used (thanks to Leo Spiekman)
|
|
|
|
* Andy Walker : Allow to specify the NFS server in nfs_root
|
|
|
|
* without giving a path name
|
2007-10-19 21:21:04 +00:00
|
|
|
* Swen Thümmler : Allow to specify the NFS options in nfs_root
|
2005-04-16 22:20:36 +00:00
|
|
|
* without giving a path name. Fix BOOTP request
|
|
|
|
* for domainname (domainname is NIS domain, not
|
|
|
|
* DNS domain!). Skip dummy devices for BOOTP.
|
|
|
|
* Jacek Zapala : Fixed a bug which prevented server-ip address
|
|
|
|
* from nfsroot parameter from being used.
|
|
|
|
* Olaf Kirch : Adapted to new NFS code.
|
|
|
|
* Jakub Jelinek : Free used code segment.
|
|
|
|
* Marko Kohtala : Fixed some bugs.
|
|
|
|
* Martin Mares : Debug message cleanup
|
|
|
|
* Martin Mares : Changed to use the new generic IP layer autoconfig
|
|
|
|
* code. BOOTP and RARP moved there.
|
|
|
|
* Martin Mares : Default path now contains host name instead of
|
|
|
|
* host IP address (but host name defaults to IP
|
|
|
|
* address anyway).
|
|
|
|
* Martin Mares : Use root_server_addr appropriately during setup.
|
|
|
|
* Martin Mares : Rewrote parameter parsing, now hopefully giving
|
|
|
|
* correct overriding.
|
|
|
|
* Trond Myklebust : Add in preliminary support for NFSv3 and TCP.
|
|
|
|
* Fix bug in root_nfs_addr(). nfs_data.namlen
|
|
|
|
* is NOT for the length of the hostname.
|
|
|
|
* Hua Qin : Support for mounting root file system via
|
|
|
|
* NFS over TCP.
|
|
|
|
* Fabian Frederick: Option parser rebuilt (using parser lib)
|
2010-09-17 14:54:37 +00:00
|
|
|
* Chuck Lever : Use super.c's text-based mount option parsing
|
2010-09-17 14:54:37 +00:00
|
|
|
* Chuck Lever : Add "nfsrootdebug".
|
2010-09-17 14:54:37 +00:00
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/nfs.h>
|
|
|
|
#include <linux/nfs_fs.h>
|
|
|
|
#include <linux/utsname.h>
|
|
|
|
#include <linux/root_dev.h>
|
|
|
|
#include <net/ipconfig.h>
|
|
|
|
|
2008-12-23 20:21:34 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define NFSDBG_FACILITY NFSDBG_ROOT
|
|
|
|
|
|
|
|
/* Default path we try to mount. "%s" gets replaced by our IP address */
|
|
|
|
#define NFS_ROOT "/tftpboot/%s"
|
|
|
|
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
/* Default NFSROOT mount options. */
|
2020-10-16 10:13:00 +00:00
|
|
|
#if defined(CONFIG_NFS_V2)
|
2020-03-25 03:50:13 +00:00
|
|
|
#define NFS_DEF_OPTIONS "vers=2,tcp,rsize=4096,wsize=4096"
|
2020-10-16 10:13:00 +00:00
|
|
|
#elif defined(CONFIG_NFS_V3)
|
|
|
|
#define NFS_DEF_OPTIONS "vers=3,tcp,rsize=4096,wsize=4096"
|
|
|
|
#else
|
|
|
|
#define NFS_DEF_OPTIONS "vers=4,tcp,rsize=4096,wsize=4096"
|
|
|
|
#endif
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Parameters passed from the kernel command line */
|
2015-09-24 02:19:09 +00:00
|
|
|
static char nfs_root_parms[NFS_MAXPATHLEN + 1] __initdata = "";
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-09-17 14:54:37 +00:00
|
|
|
/* Text-based mount options passed to super.c */
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
static char nfs_root_options[256] __initdata = NFS_DEF_OPTIONS;
|
2010-09-17 14:54:37 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Address of NFS server */
|
2010-09-17 14:54:37 +00:00
|
|
|
static __be32 servaddr __initdata = htonl(INADDR_NONE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Name of directory to mount */
|
2010-09-17 14:54:37 +00:00
|
|
|
static char nfs_export_path[NFS_MAXPATHLEN + 1] __initdata = "";
|
|
|
|
|
|
|
|
/* server:export path string passed to super.c */
|
|
|
|
static char nfs_root_device[NFS_MAXPATHLEN + 1] __initdata = "";
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-03-18 18:07:42 +00:00
|
|
|
#ifdef NFS_DEBUG
|
2010-09-17 14:54:37 +00:00
|
|
|
/*
|
|
|
|
* When the "nfsrootdebug" kernel command line option is specified,
|
|
|
|
* enable debugging messages for NFSROOT.
|
|
|
|
*/
|
|
|
|
static int __init nfs_root_debug(char *__unused)
|
|
|
|
{
|
|
|
|
nfs_debug |= NFSDBG_ROOT | NFSDBG_MOUNT;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("nfsrootdebug", nfs_root_debug);
|
2010-10-26 17:47:04 +00:00
|
|
|
#endif
|
2010-09-17 14:54:37 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Parse NFS server and directory information passed on the kernel
|
|
|
|
* command line.
|
2010-09-17 14:54:37 +00:00
|
|
|
*
|
|
|
|
* nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
|
|
|
|
*
|
|
|
|
* If there is a "%s" token in the <root-dir> string, it is replaced
|
|
|
|
* by the ASCII-representation of the client's IP address.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
static int __init nfs_root_setup(char *line)
|
|
|
|
{
|
|
|
|
ROOT_DEV = Root_NFS;
|
2010-09-17 14:54:37 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) {
|
2022-08-18 21:01:15 +00:00
|
|
|
strscpy(nfs_root_parms, line, sizeof(nfs_root_parms));
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2010-09-17 14:54:37 +00:00
|
|
|
size_t n = strlen(line) + sizeof(NFS_ROOT) - 1;
|
|
|
|
if (n >= sizeof(nfs_root_parms))
|
|
|
|
line[sizeof(nfs_root_parms) - sizeof(NFS_ROOT) - 2] = '\0';
|
|
|
|
sprintf(nfs_root_parms, NFS_ROOT, line);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2010-09-17 14:54:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Extract the IP address of the NFS server containing our
|
|
|
|
* root file system, if one was specified.
|
|
|
|
*
|
|
|
|
* Note: root_nfs_parse_addr() removes the server-ip from
|
|
|
|
* nfs_root_parms, if it exists.
|
|
|
|
*/
|
|
|
|
root_server_addr = root_nfs_parse_addr(nfs_root_parms);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("nfsroot=", nfs_root_setup);
|
|
|
|
|
2010-09-17 14:54:37 +00:00
|
|
|
static int __init root_nfs_copy(char *dest, const char *src,
|
|
|
|
const size_t destlen)
|
|
|
|
{
|
|
|
|
if (strlcpy(dest, src, destlen) > destlen)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init root_nfs_cat(char *dest, const char *src,
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
const size_t destlen)
|
2010-09-17 14:54:37 +00:00
|
|
|
{
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
size_t len = strlen(dest);
|
|
|
|
|
|
|
|
if (len && dest[len - 1] != ',')
|
|
|
|
if (strlcat(dest, ",", destlen) > destlen)
|
|
|
|
return -1;
|
|
|
|
|
2010-09-17 14:54:37 +00:00
|
|
|
if (strlcat(dest, src, destlen) > destlen)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse out root export path and mount options from
|
|
|
|
* passed-in string @incoming.
|
|
|
|
*
|
|
|
|
* Copy the export path into @exppath.
|
|
|
|
*/
|
|
|
|
static int __init root_nfs_parse_options(char *incoming, char *exppath,
|
|
|
|
const size_t exppathlen)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the NFS remote path
|
|
|
|
*/
|
|
|
|
p = strsep(&incoming, ",");
|
|
|
|
if (*p != '\0' && strcmp(p, "default") != 0)
|
|
|
|
if (root_nfs_copy(exppath, p, exppathlen))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @incoming now points to the rest of the string; if it
|
|
|
|
* contains something, append it to our root options buffer
|
|
|
|
*/
|
|
|
|
if (incoming != NULL && *incoming != '\0')
|
|
|
|
if (root_nfs_cat(nfs_root_options, incoming,
|
|
|
|
sizeof(nfs_root_options)))
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode the export directory path name and NFS options from
|
|
|
|
* the kernel command line. This has to be done late in order to
|
|
|
|
* use a dynamically acquired client IP address for the remote
|
|
|
|
* root directory path.
|
|
|
|
*
|
|
|
|
* Returns zero if successful; otherwise -1 is returned.
|
|
|
|
*/
|
|
|
|
static int __init root_nfs_data(char *cmdline)
|
|
|
|
{
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
char mand_options[sizeof("nolock,addr=") + INET_ADDRSTRLEN + 1];
|
2010-09-17 14:54:37 +00:00
|
|
|
int len, retval = -1;
|
|
|
|
char *tmp = NULL;
|
|
|
|
const size_t tmplen = sizeof(nfs_export_path);
|
|
|
|
|
|
|
|
tmp = kzalloc(tmplen, GFP_KERNEL);
|
|
|
|
if (tmp == NULL)
|
|
|
|
goto out_nomem;
|
|
|
|
strcpy(tmp, NFS_ROOT);
|
|
|
|
|
|
|
|
if (root_server_path[0] != '\0') {
|
|
|
|
dprintk("Root-NFS: DHCPv4 option 17: %s\n",
|
|
|
|
root_server_path);
|
|
|
|
if (root_nfs_parse_options(root_server_path, tmp, tmplen))
|
|
|
|
goto out_optionstoolong;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmdline[0] != '\0') {
|
|
|
|
dprintk("Root-NFS: nfsroot=%s\n", cmdline);
|
|
|
|
if (root_nfs_parse_options(cmdline, tmp, tmplen))
|
|
|
|
goto out_optionstoolong;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Append mandatory options for nfsroot so they override
|
|
|
|
* what has come before
|
|
|
|
*/
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
snprintf(mand_options, sizeof(mand_options), "nolock,addr=%pI4",
|
2010-09-17 14:54:37 +00:00
|
|
|
&servaddr);
|
NFS: NFSROOT should default to "proto=udp"
There have been a number of recent reports that NFSROOT is no longer
working with default mount options, but fails only with certain NICs.
Brian Downing <bdowning@lavos.net> bisected to commit 56463e50 "NFS:
Use super.c for NFSROOT mount option parsing". Among other things,
this commit changes the default mount options for NFSROOT to use TCP
instead of UDP as the underlying transport.
TCP seems less able to deal with NICs that are slow to initialize.
The system logs that have accompanied reports of problems all show
that NFSROOT attempts to establish a TCP connection before the NIC is
fully initialized, and thus the TCP connection attempt fails.
When a TCP connection attempt fails during a mount operation, the
NFS stack needs to fail the operation. Usually user space knows how
and when to retry it. The network layer does not report a distinct
error code for this particular failure mode. Thus, there isn't a
clean way for the RPC client to see that it needs to retry in this
case, but not in others.
Because NFSROOT is used in some environments where it is not possible
to update the kernel command line to specify "udp", the proper thing
to do is change NFSROOT to use UDP by default, as it did before commit
56463e50.
To make it easier to see how to change default mount options for
NFSROOT and to distinguish default settings from mandatory settings,
I've adjusted a couple of areas to document the specifics.
root_nfs_cat() is also modified to deal with commas properly when
concatenating strings containing mount option lists. This keeps
root_nfs_cat() call sites simpler, now that we may be concatenating
multiple mount option strings.
Tested-by: Brian Downing <bdowning@lavos.net>
Tested-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: <stable@kernel.org> # 2.6.37
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-11 20:31:06 +00:00
|
|
|
if (root_nfs_cat(nfs_root_options, mand_options,
|
2010-09-17 14:54:37 +00:00
|
|
|
sizeof(nfs_root_options)))
|
|
|
|
goto out_optionstoolong;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up nfs_root_device. For NFS mounts, this looks like
|
|
|
|
*
|
|
|
|
* server:/path
|
|
|
|
*
|
|
|
|
* At this point, utsname()->nodename contains our local
|
|
|
|
* IP address or hostname, set by ipconfig. If "%s" exists
|
|
|
|
* in tmp, substitute the nodename, then shovel the whole
|
|
|
|
* mess into nfs_root_device.
|
|
|
|
*/
|
|
|
|
len = snprintf(nfs_export_path, sizeof(nfs_export_path),
|
|
|
|
tmp, utsname()->nodename);
|
2014-12-16 23:52:26 +00:00
|
|
|
if (len >= (int)sizeof(nfs_export_path))
|
2010-09-17 14:54:37 +00:00
|
|
|
goto out_devnametoolong;
|
|
|
|
len = snprintf(nfs_root_device, sizeof(nfs_root_device),
|
|
|
|
"%pI4:%s", &servaddr, nfs_export_path);
|
2014-12-16 23:52:26 +00:00
|
|
|
if (len >= (int)sizeof(nfs_root_device))
|
2010-09-17 14:54:37 +00:00
|
|
|
goto out_devnametoolong;
|
|
|
|
|
|
|
|
retval = 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
kfree(tmp);
|
|
|
|
return retval;
|
|
|
|
out_nomem:
|
|
|
|
printk(KERN_ERR "Root-NFS: could not allocate memory\n");
|
|
|
|
goto out;
|
|
|
|
out_optionstoolong:
|
|
|
|
printk(KERN_ERR "Root-NFS: mount options string too long\n");
|
|
|
|
goto out;
|
|
|
|
out_devnametoolong:
|
|
|
|
printk(KERN_ERR "Root-NFS: root device name too long.\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nfs_root_data - Return prepared 'data' for NFSROOT mount
|
|
|
|
* @root_device: OUT: address of string containing NFSROOT device
|
|
|
|
* @root_data: OUT: address of string containing NFSROOT mount options
|
|
|
|
*
|
|
|
|
* Returns zero and sets @root_device and @root_data if successful,
|
|
|
|
* otherwise -1 is returned.
|
|
|
|
*/
|
|
|
|
int __init nfs_root_data(char **root_device, char **root_data)
|
|
|
|
{
|
|
|
|
servaddr = root_server_addr;
|
|
|
|
if (servaddr == htonl(INADDR_NONE)) {
|
|
|
|
printk(KERN_ERR "Root-NFS: no NFS server address\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (root_nfs_data(nfs_root_parms) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*root_device = nfs_root_device;
|
|
|
|
*root_data = nfs_root_options;
|
|
|
|
return 0;
|
|
|
|
}
|