Commit 7e3d2c82 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag '5.4-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs updates from Steve French:
 "Various cifs/smb3 fixes (including for share deleted cases) and
  features including improved encrypted read performance, and various
  debugging improvements.

  Note that since I am at a test event this week with the Samba team,
  and at the annual Storage Developer Conference/SMB3 Plugfest test
  event next week a higher than usual number of fixes is expected later
  next week as other features in progress get additional testing and
  review during these two events"

* tag '5.4-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: (38 commits)
  cifs: update internal module version number
  cifs: modefromsid: write mode ACE first
  cifs: cifsroot: add more err checking
  smb3: add missing worker function for SMB3 change notify
  cifs: Add support for root file systems
  cifs: modefromsid: make room for 4 ACE
  smb3: fix potential null dereference in decrypt offload
  smb3: fix unmount hang in open_shroot
  smb3: allow disabling requesting leases
  smb3: improve handling of share deleted (and share recreated)
  smb3: display max smb3 requests in flight at any one time
  smb3: only offload decryption of read responses if multiple requests
  cifs: add a helper to find an existing readable handle to a file
  smb3: enable offload of decryption of large reads via mount option
  smb3: allow parallelizing decryption of reads
  cifs: add a debug macro that prints \\server\share for errors
  smb3: fix signing verification of large reads
  smb3: allow skipping signature verification for perf sensitive configurations
  smb3: add dynamic tracepoints for flush and close
  smb3: log warning if CSC policy conflicts with cache mount option
  ...
parents 7a0d7961 4d6bcba7
Loading
Loading
Loading
Loading
+97 −0
Original line number Diff line number Diff line
Mounting root file system via SMB (cifs.ko)
===========================================

Written 2019 by Paulo Alcantara <palcantara@suse.de>
Written 2019 by Aurelien Aptel <aaptel@suse.com>

The CONFIG_CIFS_ROOT option enables experimental root file system
support over the SMB protocol via cifs.ko.

It introduces a new kernel command-line option called 'cifsroot='
which will tell the kernel to mount the root file system over the
network by utilizing SMB or CIFS protocol.

In order to mount, the network stack will also need to be set up by
using 'ip=' config option. For more details, see
Documentation/filesystems/nfs/nfsroot.txt.

A CIFS root mount currently requires the use of SMB1+UNIX Extensions
which is only supported by the Samba server. SMB1 is the older
deprecated version of the protocol but it has been extended to support
POSIX features (See [1]). The equivalent extensions for the newer
recommended version of the protocol (SMB3) have not been fully
implemented yet which means SMB3 doesn't support some required POSIX
file system objects (e.g. block devices, pipes, sockets).

As a result, a CIFS root will default to SMB1 for now but the version
to use can nonetheless be changed via the 'vers=' mount option.  This
default will change once the SMB3 POSIX extensions are fully
implemented.

Server configuration
====================

To enable SMB1+UNIX extensions you will need to set these global
settings in Samba smb.conf:

    [global]
    server min protocol = NT1
    unix extension = yes        # default

Kernel command line
===================

root=/dev/cifs

This is just a virtual device that basically tells the kernel to mount
the root file system via SMB protocol.

cifsroot=//<server-ip>/<share>[,options]

Enables the kernel to mount the root file system via SMB that are
located in the <server-ip> and <share> specified in this option.

The default mount options are set in fs/cifs/cifsroot.c.

server-ip
	IPv4 address of the server.

share
	Path to SMB share (rootfs).

options
	Optional mount options. For more information, see mount.cifs(8).

Examples
========

Export root file system as a Samba share in smb.conf file.

...
[linux]
	path = /path/to/rootfs
	read only = no
	guest ok = yes
	force user = root
	force group = root
	browseable = yes
	writeable = yes
	admin users = root
	public = yes
	create mask = 0777
	directory mask = 0777
...

Restart smb service.

# systemctl restart smb

Test it under QEMU on a kernel built with CONFIG_CIFS_ROOT and
CONFIG_IP_PNP options enabled.

# qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
  -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
  -append "root=/dev/cifs rw ip=dhcp cifsroot=//10.0.2.2/linux,username=foo,password=bar console=ttyS0 3"


1: https://wiki.samba.org/index.php/UNIX_Extensions
+8 −0
Original line number Diff line number Diff line
@@ -211,3 +211,11 @@ config CIFS_FSCACHE
	  Makes CIFS FS-Cache capable. Say Y here if you want your CIFS data
	  to be cached locally on disk through the general filesystem cache
	  manager. If unsure, say N.

config CIFS_ROOT
	bool "SMB root file system (Experimental)"
	depends on CIFS=y && IP_PNP
	help
	  Enables root file system support over SMB protocol.

	  Most people say N here.
+2 −0
Original line number Diff line number Diff line
@@ -21,3 +21,5 @@ cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o dfs_cache.o
cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o

cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o

cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
+2 −0
Original line number Diff line number Diff line
@@ -452,6 +452,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
		list_for_each(tmp1, &cifs_tcp_ses_list) {
			server = list_entry(tmp1, struct TCP_Server_Info,
					    tcp_ses_list);
			server->max_in_flight = 0;
#ifdef CONFIG_CIFS_STATS2
			for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
				atomic_set(&server->num_cmds[i], 0);
@@ -526,6 +527,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
	list_for_each(tmp1, &cifs_tcp_ses_list) {
		server = list_entry(tmp1, struct TCP_Server_Info,
				    tcp_ses_list);
		seq_printf(m, "\nMax requests in flight: %d", server->max_in_flight);
#ifdef CONFIG_CIFS_STATS2
		seq_puts(m, "\nTotal time spent processing by command. Time ");
		seq_printf(m, "units are jiffies (%d per second)\n", HZ);
+67 −0
Original line number Diff line number Diff line
@@ -80,6 +80,60 @@ do { \
			type, fmt, ##__VA_ARGS__);	\
} while (0)

#define cifs_server_dbg_func(ratefunc, type, fmt, ...)		\
do {								\
	const char *sn = "";					\
	if (server && server->hostname)				\
		sn = server->hostname;				\
	if ((type) & FYI && cifsFYI & CIFS_INFO) {		\
		pr_debug_ ## ratefunc("%s: \\\\%s "	fmt,	\
			__FILE__, sn, ##__VA_ARGS__);		\
	} else if ((type) & VFS) {				\
		pr_err_ ## ratefunc("CIFS VFS: \\\\%s " fmt,	\
			sn, ##__VA_ARGS__);			\
	} else if ((type) & NOISY && (NOISY != 0)) {		\
		pr_debug_ ## ratefunc("\\\\%s " fmt,		\
			sn, ##__VA_ARGS__);			\
	}							\
} while (0)

#define cifs_server_dbg(type, fmt, ...)			\
do {							\
	if ((type) & ONCE)				\
		cifs_server_dbg_func(once,		\
			type, fmt, ##__VA_ARGS__);	\
	else						\
		cifs_server_dbg_func(ratelimited,	\
			type, fmt, ##__VA_ARGS__);	\
} while (0)

#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...)		\
do {								\
	const char *tn = "";					\
	if (tcon && tcon->treeName)				\
		tn = tcon->treeName;				\
	if ((type) & FYI && cifsFYI & CIFS_INFO) {		\
		pr_debug_ ## ratefunc("%s: %s "	fmt,		\
			__FILE__, tn, ##__VA_ARGS__);		\
	} else if ((type) & VFS) {				\
		pr_err_ ## ratefunc("CIFS VFS: %s " fmt,	\
			tn, ##__VA_ARGS__);			\
	} else if ((type) & NOISY && (NOISY != 0)) {		\
		pr_debug_ ## ratefunc("%s " fmt,		\
			tn, ##__VA_ARGS__);			\
	}							\
} while (0)

#define cifs_tcon_dbg(type, fmt, ...)			\
do {							\
	if ((type) & ONCE)				\
		cifs_tcon_dbg_func(once,		\
			type, fmt, ##__VA_ARGS__);	\
	else						\
		cifs_tcon_dbg_func(ratelimited,	\
			type, fmt, ##__VA_ARGS__);	\
} while (0)

/*
 *	debug OFF
 *	---------
@@ -91,6 +145,19 @@ do { \
		pr_debug(fmt, ##__VA_ARGS__);				\
} while (0)

#define cifs_server_dbg(type, fmt, ...)					\
do {									\
	if (0)								\
		pr_debug("\\\\%s " fmt,					\
			 server->hostname, ##__VA_ARGS__);		\
} while (0)

#define cifs_tcon_dbg(type, fmt, ...)					\
do {									\
	if (0)								\
		pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__);	\
} while (0)

#define cifs_info(fmt, ...)						\
do {									\
	pr_info("CIFS: "fmt, ##__VA_ARGS__);				\
Loading