Skip to content

Commit d8848ee

Browse files
committed
Merge tag '5.2-rc-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Minor cleanup and fixes, one for stable, four rdma (smbdirect) related. Also adds SEEK_HOLE support" * tag '5.2-rc-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: add support for SEEK_DATA and SEEK_HOLE Fixed https://bugzilla.kernel.org/show_bug.cgi?id=202935 allow write on the same file cifs: Allocate memory for all iovs in smb2_ioctl cifs: Don't match port on SMBDirect transport cifs:smbd Use the correct DMA direction when sending data cifs:smbd When reconnecting to server, call smbd_destroy() after all MIDs have been called cifs: use the right include for signal_pending() smb3: trivial cleanup to smb2ops.c cifs: cleanup smb2ops.c and normalize strings smb3: display session id in debug data
2 parents 1ba3b5d + dece44e commit d8848ee

File tree

8 files changed

+173
-51
lines changed

8 files changed

+173
-51
lines changed

fs/cifs/cifs_debug.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
380380
atomic_read(&server->in_send),
381381
atomic_read(&server->num_waiters));
382382
#endif
383+
/* dump session id helpful for use with network trace */
384+
seq_printf(m, " SessionId: 0x%llx", ses->Suid);
383385
if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA)
384386
seq_puts(m, " encrypted");
385387
if (ses->sign)

fs/cifs/cifsfs.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,9 @@ static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
878878

879879
static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
880880
{
881+
struct cifsFileInfo *cfile = file->private_data;
882+
struct cifs_tcon *tcon;
883+
881884
/*
882885
* whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
883886
* the cached file length
@@ -909,6 +912,12 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
909912
if (rc < 0)
910913
return (loff_t)rc;
911914
}
915+
if (cfile && cfile->tlink) {
916+
tcon = tlink_tcon(cfile->tlink);
917+
if (tcon->ses->server->ops->llseek)
918+
return tcon->ses->server->ops->llseek(file, tcon,
919+
offset, whence);
920+
}
912921
return generic_file_llseek(file, offset, whence);
913922
}
914923

@@ -1070,11 +1079,6 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
10701079

10711080
cifs_dbg(FYI, "copychunk range\n");
10721081

1073-
if (src_inode == target_inode) {
1074-
rc = -EINVAL;
1075-
goto out;
1076-
}
1077-
10781082
if (!src_file->private_data || !dst_file->private_data) {
10791083
rc = -EBADF;
10801084
cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");

fs/cifs/cifsglob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ struct smb_version_operations {
497497
/* version specific fiemap implementation */
498498
int (*fiemap)(struct cifs_tcon *tcon, struct cifsFileInfo *,
499499
struct fiemap_extent_info *, u64, u64);
500+
/* version specific llseek implementation */
501+
loff_t (*llseek)(struct file *, struct cifs_tcon *, loff_t, int);
500502
};
501503

502504
struct smb_version_values {

fs/cifs/connect.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,21 @@ cifs_reconnect(struct TCP_Server_Info *server)
528528
/* do not want to be sending data on a socket we are freeing */
529529
cifs_dbg(FYI, "%s: tearing down socket\n", __func__);
530530
mutex_lock(&server->srv_mutex);
531+
if (server->ssocket) {
532+
cifs_dbg(FYI, "State: 0x%x Flags: 0x%lx\n",
533+
server->ssocket->state, server->ssocket->flags);
534+
kernel_sock_shutdown(server->ssocket, SHUT_WR);
535+
cifs_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n",
536+
server->ssocket->state, server->ssocket->flags);
537+
sock_release(server->ssocket);
538+
server->ssocket = NULL;
539+
}
540+
server->sequence_number = 0;
541+
server->session_estab = false;
542+
kfree(server->session_key.response);
543+
server->session_key.response = NULL;
544+
server->session_key.len = 0;
545+
server->lstrp = jiffies;
531546

532547
/* mark submitted MIDs for retry and issue callback */
533548
INIT_LIST_HEAD(&retry_list);
@@ -540,6 +555,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
540555
list_move(&mid_entry->qhead, &retry_list);
541556
}
542557
spin_unlock(&GlobalMid_Lock);
558+
mutex_unlock(&server->srv_mutex);
543559

544560
cifs_dbg(FYI, "%s: issuing mid callbacks\n", __func__);
545561
list_for_each_safe(tmp, tmp2, &retry_list) {
@@ -548,24 +564,11 @@ cifs_reconnect(struct TCP_Server_Info *server)
548564
mid_entry->callback(mid_entry);
549565
}
550566

551-
if (server->ssocket) {
552-
cifs_dbg(FYI, "State: 0x%x Flags: 0x%lx\n",
553-
server->ssocket->state, server->ssocket->flags);
554-
kernel_sock_shutdown(server->ssocket, SHUT_WR);
555-
cifs_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n",
556-
server->ssocket->state, server->ssocket->flags);
557-
sock_release(server->ssocket);
558-
server->ssocket = NULL;
559-
} else if (cifs_rdma_enabled(server))
567+
if (cifs_rdma_enabled(server)) {
568+
mutex_lock(&server->srv_mutex);
560569
smbd_destroy(server);
561-
server->sequence_number = 0;
562-
server->session_estab = false;
563-
kfree(server->session_key.response);
564-
server->session_key.response = NULL;
565-
server->session_key.len = 0;
566-
server->lstrp = jiffies;
567-
568-
mutex_unlock(&server->srv_mutex);
570+
mutex_unlock(&server->srv_mutex);
571+
}
569572

570573
do {
571574
try_to_freeze();
@@ -2443,6 +2446,10 @@ match_port(struct TCP_Server_Info *server, struct sockaddr *addr)
24432446
{
24442447
__be16 port, *sport;
24452448

2449+
/* SMBDirect manages its own ports, don't match it here */
2450+
if (server->rdma)
2451+
return true;
2452+
24462453
switch (addr->sa_family) {
24472454
case AF_INET:
24482455
sport = &((struct sockaddr_in *) &server->dstaddr)->sin_port;

0 commit comments

Comments
 (0)