Skip to content

Commit 9c7dc82

Browse files
committed
Merge tag '5.1-rc-smb3' of git://git.samba.org/sfrench/cifs-2.6
Pull more smb3 updates from Steve French: "Various tracing and debugging improvements, crediting fixes, some cleanup, and important fallocate fix (fixes three xfstests) and lock fix. Summary: - Various additional dynamic tracing tracepoints - Debugging improvements (including ability to query the server via SMB3 fsctl from userspace tools which can help with stats and debugging) - One minor performance improvement (root directory inode caching) - Crediting (SMB3 flow control) fixes - Some cleanup (docs and to mknod) - Important fixes: one to smb3 implementation of fallocate zero range (which fixes three xfstests) and a POSIX lock fix" * tag '5.1-rc-smb3' of git://git.samba.org/sfrench/cifs-2.6: (22 commits) CIFS: fix POSIX lock leak and invalid ptr deref SMB3: Allow SMB3 FSCTL queries to be sent to server from tools cifs: fix incorrect handling of smb2_set_sparse() return in smb3_simple_falloc smb2: fix typo in definition of a few error flags CIFS: make mknod() an smb_version_op cifs: minor documentation updates cifs: remove unused value pointed out by Coverity SMB3: passthru query info doesn't check for SMB3 FSCTL passthru smb3: add dynamic tracepoints for simple fallocate and zero range cifs: fix smb3_zero_range so it can expand the file-size when required cifs: add SMB2_ioctl_init/free helpers to be used with compounding smb3: Add dynamic trace points for various compounded smb3 ops cifs: cache FILE_ALL_INFO for the shared root handle smb3: display volume serial number for shares in /proc/fs/cifs/DebugData cifs: simplify how we handle credits in compound_send_recv() smb3: add dynamic tracepoint for timeout waiting for credits smb3: display security information in /proc/fs/cifs/DebugData more accurately cifs: add a timeout argument to wait_for_free_credits cifs: prevent starvation in wait_for_free_credits for multi-credit requests cifs: wait_for_free_credits() make it possible to wait for >=1 credits ...
2 parents 6c83d0d + bc31d0c commit 9c7dc82

File tree

17 files changed

+981
-362
lines changed

17 files changed

+981
-362
lines changed

Documentation/filesystems/cifs/TODO

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ negotiated size) and send larger write sizes to modern servers.
111111

112112
5) Continue to extend the smb3 "buildbot" which does automated xfstesting
113113
against Windows, Samba and Azure currently - to add additional tests and
114-
to allow the buildbot to execute the tests faster.
114+
to allow the buildbot to execute the tests faster. The URL for the
115+
buildbot is: http://smb3-test-rhel-75.southcentralus.cloudapp.azure.com
115116

116117
6) Address various coverity warnings (most are not bugs per-se, but
117118
the more warnings are addressed, the easier it is to spot real
Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
This is the client VFS module for the SMB3 NAS protocol as well
2-
older dialects such as the Common Internet File System (CIFS)
2+
as for older dialects such as the Common Internet File System (CIFS)
33
protocol which was the successor to the Server Message Block
44
(SMB) protocol, the native file sharing mechanism for most early
55
PC operating systems. New and improved versions of CIFS are now
6-
called SMB2 and SMB3. These dialects are also supported by the
7-
CIFS VFS module. CIFS is fully supported by network
8-
file servers such as Windows 2000, 2003, 2008, 2012 and 2016
9-
as well by Samba (which provides excellent CIFS
10-
server support for Linux and many other operating systems), Apple
11-
systems, as well as most Network Attached Storage vendors, so
12-
this network filesystem client can mount to a wide variety of
13-
servers.
6+
called SMB2 and SMB3. Use of SMB3 (and later, including SMB3.1.1)
7+
is strongly preferred over using older dialects like CIFS due to
8+
security reaasons. All modern dialects, including the most recent,
9+
SMB3.1.1 are supported by the CIFS VFS module. The SMB3 protocol
10+
is implemented and supported by all major file servers
11+
such as all modern versions of Windows (including Windows 2016
12+
Server), as well as by Samba (which provides excellent
13+
CIFS/SMB2/SMB3 server support and tools for Linux and many other
14+
operating systems). Apple systems also support SMB3 well, as
15+
do most Network Attached Storage vendors, so this network
16+
filesystem client can mount to a wide variety of systems.
17+
It also supports mounting to the cloud (for example
18+
Microsoft Azure), including the necessary security features.
1419

1520
The intent of this module is to provide the most advanced network
1621
file system function for SMB3 compliant servers, including advanced
@@ -24,12 +29,17 @@
2429
cluster file systems for fileserving in some Linux to Linux environments,
2530
not just in Linux to Windows (or Linux to Mac) environments.
2631

27-
This filesystem has an mount utility (mount.cifs) that can be obtained from
32+
This filesystem has a mount utility (mount.cifs) and various user space
33+
tools (including smbinfo and setcifsacl) that can be obtained from
2834

29-
https://ftp.samba.org/pub/linux-cifs/cifs-utils/
35+
https://git.samba.org/?p=cifs-utils.git
36+
or
37+
git://git.samba.org/cifs-utils.git
3038

31-
It must be installed in the directory with the other mount helpers.
39+
mount.cifs should be installed in the directory with the other mount helpers.
3240

3341
For more information on the module see the project wiki page at
3442

43+
https://wiki.samba.org/index.php/LinuxCIFS
44+
and
3545
https://wiki.samba.org/index.php/LinuxCIFS_utils

fs/cifs/cifs_debug.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
115115
seq_puts(m, " type: CDROM ");
116116
else
117117
seq_printf(m, " type: %d ", dev_type);
118-
if (tcon->seal)
118+
119+
seq_printf(m, "Serial Number: 0x%x", tcon->vol_serial_number);
120+
121+
if ((tcon->seal) ||
122+
(tcon->ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) ||
123+
(tcon->share_flags & SHI1005_FLAGS_ENCRYPT_DATA))
119124
seq_printf(m, " Encrypted");
120125
if (tcon->nocase)
121126
seq_printf(m, " nocase");
@@ -371,6 +376,10 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
371376
atomic_read(&server->in_send),
372377
atomic_read(&server->num_waiters));
373378
#endif
379+
if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA)
380+
seq_puts(m, " encrypted");
381+
if (ses->sign)
382+
seq_puts(m, " signed");
374383

375384
seq_puts(m, "\n\tShares:");
376385
j = 0;

fs/cifs/cifs_ioctl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ struct smb_snapshot_array {
4343
/* snapshots[]; */
4444
} __packed;
4545

46+
/* query_info flags */
47+
#define PASSTHRU_QUERY_INFO 0x00000000
48+
#define PASSTHRU_FSCTL 0x00000001
4649
struct smb_query_info {
4750
__u32 info_type;
4851
__u32 file_info_class;

fs/cifs/cifsglob.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,14 @@ struct smb_version_operations {
479479
struct cifs_tcon *tcon,
480480
__le16 *path, int is_dir,
481481
unsigned long p);
482+
/* make unix special files (block, char, fifo, socket) */
483+
int (*make_node)(unsigned int xid,
484+
struct inode *inode,
485+
struct dentry *dentry,
486+
struct cifs_tcon *tcon,
487+
char *full_path,
488+
umode_t mode,
489+
dev_t device_number);
482490
};
483491

484492
struct smb_version_values {
@@ -735,13 +743,13 @@ in_flight(struct TCP_Server_Info *server)
735743
}
736744

737745
static inline bool
738-
has_credits(struct TCP_Server_Info *server, int *credits)
746+
has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
739747
{
740748
int num;
741749
spin_lock(&server->req_lock);
742750
num = *credits;
743751
spin_unlock(&server->req_lock);
744-
return num > 0;
752+
return num >= num_credits;
745753
}
746754

747755
static inline void
@@ -962,11 +970,14 @@ cap_unix(struct cifs_ses *ses)
962970

963971
struct cached_fid {
964972
bool is_valid:1; /* Do we have a useable root fid */
973+
bool file_all_info_is_valid:1;
974+
965975
struct kref refcount;
966976
struct cifs_fid *fid;
967977
struct mutex fid_mutex;
968978
struct cifs_tcon *tcon;
969979
struct work_struct lease_break;
980+
struct smb2_file_all_info file_all_info;
970981
};
971982

972983
/*
@@ -1735,6 +1746,7 @@ require use of the stronger protocol */
17351746
* GlobalMid_Lock protects:
17361747
* list operations on pending_mid_q and oplockQ
17371748
* updates to XID counters, multiplex id and SMB sequence numbers
1749+
* list operations on global DnotifyReqList
17381750
* tcp_ses_lock protects:
17391751
* list operations on tcp and SMB session lists
17401752
* tcon->open_file_lock protects the list of open files hanging off the tcon

fs/cifs/connect.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,10 +1191,6 @@ cifs_demultiplex_thread(void *p)
11911191
continue;
11921192
}
11931193

1194-
if (server->large_buf)
1195-
buf = server->bigbuf;
1196-
1197-
11981194
server->lstrp = jiffies;
11991195

12001196
for (i = 0; i < num_mids; i++) {

fs/cifs/dir.c

Lines changed: 3 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -621,20 +621,10 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
621621
{
622622
int rc = -EPERM;
623623
unsigned int xid;
624-
int create_options = CREATE_NOT_DIR | CREATE_OPTION_SPECIAL;
625624
struct cifs_sb_info *cifs_sb;
626625
struct tcon_link *tlink;
627626
struct cifs_tcon *tcon;
628-
struct cifs_io_parms io_parms;
629627
char *full_path = NULL;
630-
struct inode *newinode = NULL;
631-
__u32 oplock = 0;
632-
struct cifs_fid fid;
633-
struct cifs_open_parms oparms;
634-
FILE_ALL_INFO *buf = NULL;
635-
unsigned int bytes_written;
636-
struct win_dev *pdev;
637-
struct kvec iov[2];
638628

639629
if (!old_valid_dev(device_number))
640630
return -EINVAL;
@@ -654,103 +644,12 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
654644
goto mknod_out;
655645
}
656646

657-
if (tcon->unix_ext) {
658-
struct cifs_unix_set_info_args args = {
659-
.mode = mode & ~current_umask(),
660-
.ctime = NO_CHANGE_64,
661-
.atime = NO_CHANGE_64,
662-
.mtime = NO_CHANGE_64,
663-
.device = device_number,
664-
};
665-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
666-
args.uid = current_fsuid();
667-
args.gid = current_fsgid();
668-
} else {
669-
args.uid = INVALID_UID; /* no change */
670-
args.gid = INVALID_GID; /* no change */
671-
}
672-
rc = CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
673-
cifs_sb->local_nls,
674-
cifs_remap(cifs_sb));
675-
if (rc)
676-
goto mknod_out;
677-
678-
rc = cifs_get_inode_info_unix(&newinode, full_path,
679-
inode->i_sb, xid);
680-
681-
if (rc == 0)
682-
d_instantiate(direntry, newinode);
683-
goto mknod_out;
684-
}
685-
686-
if (!S_ISCHR(mode) && !S_ISBLK(mode))
687-
goto mknod_out;
688-
689-
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
690-
goto mknod_out;
691-
692-
693-
cifs_dbg(FYI, "sfu compat create special file\n");
694-
695-
buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
696-
if (buf == NULL) {
697-
rc = -ENOMEM;
698-
goto mknod_out;
699-
}
700-
701-
if (backup_cred(cifs_sb))
702-
create_options |= CREATE_OPEN_BACKUP_INTENT;
703-
704-
oparms.tcon = tcon;
705-
oparms.cifs_sb = cifs_sb;
706-
oparms.desired_access = GENERIC_WRITE;
707-
oparms.create_options = create_options;
708-
oparms.disposition = FILE_CREATE;
709-
oparms.path = full_path;
710-
oparms.fid = &fid;
711-
oparms.reconnect = false;
712-
713-
if (tcon->ses->server->oplocks)
714-
oplock = REQ_OPLOCK;
715-
else
716-
oplock = 0;
717-
rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, buf);
718-
if (rc)
719-
goto mknod_out;
720-
721-
/*
722-
* BB Do not bother to decode buf since no local inode yet to put
723-
* timestamps in, but we can reuse it safely.
724-
*/
725-
726-
pdev = (struct win_dev *)buf;
727-
io_parms.pid = current->tgid;
728-
io_parms.tcon = tcon;
729-
io_parms.offset = 0;
730-
io_parms.length = sizeof(struct win_dev);
731-
iov[1].iov_base = buf;
732-
iov[1].iov_len = sizeof(struct win_dev);
733-
if (S_ISCHR(mode)) {
734-
memcpy(pdev->type, "IntxCHR", 8);
735-
pdev->major = cpu_to_le64(MAJOR(device_number));
736-
pdev->minor = cpu_to_le64(MINOR(device_number));
737-
rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
738-
&bytes_written, iov, 1);
739-
} else if (S_ISBLK(mode)) {
740-
memcpy(pdev->type, "IntxBLK", 8);
741-
pdev->major = cpu_to_le64(MAJOR(device_number));
742-
pdev->minor = cpu_to_le64(MINOR(device_number));
743-
rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
744-
&bytes_written, iov, 1);
745-
}
746-
tcon->ses->server->ops->close(xid, tcon, &fid);
747-
d_drop(direntry);
748-
749-
/* FIXME: add code here to set EAs */
647+
rc = tcon->ses->server->ops->make_node(xid, inode, direntry, tcon,
648+
full_path, mode,
649+
device_number);
750650

751651
mknod_out:
752652
kfree(full_path);
753-
kfree(buf);
754653
free_xid(xid);
755654
cifs_put_tlink(tlink);
756655
return rc;

fs/cifs/file.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,20 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
16451645
rc = server->ops->mand_unlock_range(cfile, flock, xid);
16461646

16471647
out:
1648-
if (flock->fl_flags & FL_POSIX && !rc)
1648+
if (flock->fl_flags & FL_POSIX) {
1649+
/*
1650+
* If this is a request to remove all locks because we
1651+
* are closing the file, it doesn't matter if the
1652+
* unlocking failed as both cifs.ko and the SMB server
1653+
* remove the lock on file close
1654+
*/
1655+
if (rc) {
1656+
cifs_dbg(VFS, "%s failed rc=%d\n", __func__, rc);
1657+
if (!(flock->fl_flags & FL_CLOSE))
1658+
return rc;
1659+
}
16491660
rc = locks_lock_file_wait(file, flock);
1661+
}
16501662
return rc;
16511663
}
16521664

0 commit comments

Comments
 (0)