SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long...

42
SMB3 in Samba Multi-Channel and Beyond Michael Adam Red Hat / samba.org 2016-09-20

Transcript of SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long...

Page 1: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

SMB3 in Samba

Multi-Channel and Beyond

Michael Adam

Red Hat / samba.org

2016-09-20

Page 2: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

agenda

I SMB 2+ ∈ Samba

I SMB3 Multi-Channel

I Outlook: SMB3 over RDMA

I Outlook: SMB3 Persistent Handles

I Outlook: SMB3 Clustering/Witness

Michael Adam SMB3 in Samba (2/33)

Page 3: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

SMB2+ Features ∈ SambaI SMB 2.0:

I durable file handles [4.0]I SMB 2.1:

I multi-credit / large mtu [4.0]I dynamic reauthentication [4.0]I leasing [4.2, default in 4.5]I resilient file handles [PoC]

I SMB 3.0:I new crypto (sign/encrypt) [4.0]I secure negotiation [4.0]I durable file handles v2 [4.0]I multi-channel [4.4 (experimental)]I SMB direct [design/PoC]I persistent file handles / CA [WIP/PoC]I witness [WIP+]

I SMB 3.0.2: [4.3]I SMB 3.1.1:

I negotiate contexts, preauth: [4.3]

Michael Adam SMB3 in Samba (3/33)

Page 4: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel

Page 5: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel - General

multiple transport connections in one SMB(3) session

I channel: transport connection bound to a session

I client decides which connections to bind and to use

I session is valid as long as at least one channel is intact

two purposes

1. increase throughput:I use multiple connections of same type

2. improve fault tolerance:I channel failure: replay/retry detection

Michael Adam SMB3 in Samba (5/33)

Page 6: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel - Windows/Protocol

1. establish initial session on TCP connection

2. find interfaces with interface discovery:FSCTL QUERY NETWORK INTERFACE INFO

3. bind additional TCP (or later RDMA) connection (channel) toestablished SMB3 session (session bind)

4. Windows: uses connections of same (and best) quality

5. Windows: binds only to a single node

6. replay / retry mechanisms, epoch numbers

Michael Adam SMB3 in Samba (6/33)

Page 7: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

samba/smbd: multi-process

I Originally: process ⇔ TCP connection

I Want to avoid synchronization between smbds for disk access.

I Idea: transfer new TCP connection to existing smbd

I How? ⇒ use fd-passing (sendmsg/recvmsg)I When?

I Natural choice: at SessionSetup (Bind)I Samba’s choice: at Negotiate, based on ClientGUID

Michael Adam SMB3 in Samba (7/33)

Page 8: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

Michael Adam SMB3 in Samba (8/33)

Page 9: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

samba/smbd: multi-process

I Originally: process ⇔ TCP connection

I Want to avoid synchronization between smbds for disk access.

I Idea: transfer new TCP connection to existing smbd

I How? ⇒ use fd-passing (sendmsg/recvmsg)I When?

I Natural choice: at SessionSetup (Bind)I Samba’s choice: at Negotiate, based on ClientGUID

Michael Adam SMB3 in Samba (9/33)

Page 10: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

samba/smbd: multi-process

I Originally: process ⇔ TCP connection

I Want to avoid synchronization between smbds for disk access.

I Idea: transfer new TCP connection to existing smbd

I How? ⇒ use fd-passing (sendmsg/recvmsg)I When?

I Natural choice: at SessionSetup (Bind)I Samba’s choice: at Negotiate, based on ClientGUID

Michael Adam SMB3 in Samba (9/33)

Page 11: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

Michael Adam SMB3 in Samba (10/33)

Page 12: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

Michael Adam SMB3 in Samba (10/33)

Page 13: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

Michael Adam SMB3 in Samba (10/33)

Page 14: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

samba/smbd: multi-process

I Originally: process ⇔ TCP connection

I Want to avoid synchronization between smbds for disk access.

I Idea: transfer new TCP connection to existing smbd

I How? ⇒ use fd-passing (sendmsg/recvmsg)I When?

I Protocol choice: at SessionSetup (Bind)I Samba’s choice: at Negotiate, based on ClientGUID

Michael Adam SMB3 in Samba (11/33)

Page 15: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba

samba/smbd: multi-process

I Originally: process ⇔ TCP connection

I Want to avoid synchronization between smbds for disk access.

I Idea: transfer new TCP connection to existing smbd

I How? ⇒ use fd-passing (sendmsg/recvmsg)I When?

I Protocol choice: at SessionSetup (Bind)I Samba’s choice: at Negotiate, based on ClientGUID

Michael Adam SMB3 in Samba (11/33)

Page 16: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : pass by ClientGUID

Michael Adam SMB3 in Samba (12/33)

Page 17: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : pass by ClientGUID

Wait a minute - what about performance?

I Single process...

I But we use short-lived worker-pthreads for I/O ops!

I Extensive benchmarks and tunings still to be done.

I First benchmarks show ≥ 50% increase going from 1 channel to 2

Michael Adam SMB3 in Samba (13/33)

Page 18: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : Status

1. messaging rewrite using unix dgm sockets with sendmsg [DONE,4.2]

2. add fd-passing to messaging [DONE,4.2]

3. preparations in internal structures [DONE,4.4]

4. prepare code to cope with multiple channels [DONE,4.4]

5. implement smbd message to pass a tcp socket [DONE,4.4]

6. transfer connection in Negotiate (by ClientGUID) [DONE,4.4]

7. implement session bind [DONE,4.4]

8. implement channel epoch numbers [DONE,4.4]

9. implement interface discovery [DONE(linux/conf),4.4]

10. implement test cases [WIP(isn’t it always?... ,)]

11. implement fd-passing in socket-wrapper [WIP (Anoop CS, obnox)]

12. implement lease break replay [WIP (obnox, Gunther, metze)]

13. integrate Multi-Channel with clustering (CTDB) [WIP]

Michael Adam SMB3 in Samba (14/33)

Page 19: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : Status

1. messaging rewrite using unix dgm sockets with sendmsg [DONE,4.2]

2. add fd-passing to messaging [DONE,4.2]

3. preparations in internal structures [DONE,4.4]

4. prepare code to cope with multiple channels [DONE,4.4]

5. implement smbd message to pass a tcp socket [DONE,4.4]

6. transfer connection in Negotiate (by ClientGUID) [DONE,4.4]

7. implement session bind [DONE,4.4]

8. implement channel epoch numbers [DONE,4.4]

9. implement interface discovery [DONE(linux/conf),4.4]

10. implement test cases [WIP(isn’t it always?... ,)]

11. implement fd-passing in socket-wrapper [WIP (Anoop CS, obnox)]

12. implement lease break replay [WIP (obnox, Gunther, metze)]

13. integrate Multi-Channel with clustering (CTDB) [WIP]

Michael Adam SMB3 in Samba (14/33)

Page 20: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : Status

1. messaging rewrite using unix dgm sockets with sendmsg [DONE,4.2]

2. add fd-passing to messaging [DONE,4.2]

3. preparations in internal structures [DONE,4.4]

4. prepare code to cope with multiple channels [DONE,4.4]

5. implement smbd message to pass a tcp socket [DONE,4.4]

6. transfer connection in Negotiate (by ClientGUID) [DONE,4.4]

7. implement session bind [DONE,4.4]

8. implement channel epoch numbers [DONE,4.4]

9. implement interface discovery [DONE(linux/conf),4.4]

10. implement test cases [WIP(isn’t it always?... ,)]

11. implement fd-passing in socket-wrapper [WIP (Anoop CS, obnox)]

12. implement lease break replay [WIP (obnox, Gunther, metze)]

13. integrate Multi-Channel with clustering (CTDB) [WIP]

Michael Adam SMB3 in Samba (14/33)

Page 21: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : Status

1. messaging rewrite using unix dgm sockets with sendmsg [DONE,4.2]

2. add fd-passing to messaging [DONE,4.2]

3. preparations in internal structures [DONE,4.4]

4. prepare code to cope with multiple channels [DONE,4.4]

5. implement smbd message to pass a tcp socket [DONE,4.4]

6. transfer connection in Negotiate (by ClientGUID) [DONE,4.4]

7. implement session bind [DONE,4.4]

8. implement channel epoch numbers [DONE,4.4]

9. implement interface discovery [DONE(linux/conf),4.4]

10. implement test cases [WIP(isn’t it always?... ,)]

11. implement fd-passing in socket-wrapper [WIP (Anoop CS, obnox)]

12. implement lease break replay [WIP (obnox, Gunther, metze)]

13. integrate Multi-Channel with clustering (CTDB) [WIP]

Michael Adam SMB3 in Samba (14/33)

Page 22: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

selftest ⇐ fd-passing ∈ socket-wrapper

1. untangle socket info fd from socket info

2. array (sockets) of socket infos instead of linked list

3. protect structures from concurrent access by ptread mutexesI sockets, sockets[i], socket fds, first freeI use process shared robust mutexes where indicated

4. put sockets list and first free index into a shared storageI use a file, mmap into each user of swrap (like tdb)I these are the parts to use robust mutexes for

5. implement fd-passing:I create a pipeI pass one end of pipe along with original fds arrayI sender writes array of indexes to sockets array into pipeI receiver reads indexes from pipe and creates new socket fd structures

using fds and indexes

Michael Adam SMB3 in Samba (15/33)

Page 23: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

selftest ⇐ fd-passing ∈ socket-wrapper

1. untangle socket info fd from socket info

2. array (sockets) of socket infos instead of linked list

3. protect structures from concurrent access by ptread mutexesI sockets, sockets[i], socket fds, first freeI use process shared robust mutexes where indicated

4. put sockets list and first free index into a shared storageI use a file, mmap into each user of swrap (like tdb)I these are the parts to use robust mutexes for

5. implement fd-passing:I create a pipeI pass one end of pipe along with original fds arrayI sender writes array of indexes to sockets array into pipeI receiver reads indexes from pipe and creates new socket fd structures

using fds and indexes

Michael Adam SMB3 in Samba (15/33)

Page 24: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba: Lease Break Replay

I oplock/lease break request: server → client

I protection with channel sequence numbers not available!

I need to track sent but not acked break requests

I declare channel dead if not acked for a while and resend (replay)them over other channels (if any)

I if we don’t do that ... multi-channel may eat your data /

Michael Adam SMB3 in Samba (16/33)

Page 25: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba: Lease Break Replay

I have send queue, add ack queue

I use SIOCOUTQ ioctl on the tcp socket:unsent data in the socket send queue

Michael Adam SMB3 in Samba (17/33)

Page 26: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba: Lease Break Replay

( l e f t t he h o s t )+−−−−−− a c k e d b y t e +−−−s e n t b y t e s| |v v

+++++++++++++++++++++++++++++++++++++++++| p1−−−−−|p2−−−−−−|p3−−−−−|p4−−−−−|p5−−−−|

ˆ ˆ| || +−−−−−p3 . ack . l a s t b y t e|

+−−− p1 . ack . l a s t b y t e

Michael Adam SMB3 in Samba (18/33)

Page 27: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba: Lease Break Replay

WIP code

I git://git.samba.org/obnox/samba/samba-obnox.gitI branch: master-multi-channel-obnox

I git://git.samba.org/gd/samba/.gitI branch master-multichannel

Michael Adam SMB3 in Samba (19/33)

Page 28: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : Clustering/CTDB

Special considerations

I channels of one session only to one node !

I do not bind connections to CTDB public IPs (can move)!

I ⇒ add static IPs on public interfacesuse these for interface discovery

Michael Adam SMB3 in Samba (20/33)

Page 29: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Multi-Channel ∈ Samba : Clustering/CTDB

Special considerations

I channels of one session only to one node !

I do not bind connections to CTDB public IPs (can move)!

I ⇒ add static IPs on public interfacesuse these for interface discovery

Michael Adam SMB3 in Samba (20/33)

Page 30: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Outlook: SMB Direct

Page 31: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

SMB Direct : SMB3 over RDMA

Windows/Protocol

I requires multi-channel

I start with TCP, bind an RDMA channel

I SMB Direct: small wrapper protocol to put SMB into RDMA

I reads and writes use RDMA write/read

I protocol/metadata via send/receive

Michael Adam SMB3 in Samba (22/33)

Page 32: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

SMB Direct ∈ Samba

I wireshark dissector: [DONE]

I Samba:I prereq: multi-channel [ess.DONE]I buffer / transport abstractions [WIP]

I problem with RDMA libraries:I not fork safeI no fd-passing

I ⇒ central RDMA proxy (”smbd-d”..)I PoC/dev: user space daemonI production: kernel moduleI see Ralph Bohme’s repo (started by Richard Sharpe):

https://github.com/slowfranklin/smbdirect-driver

Michael Adam SMB3 in Samba (23/33)

Page 33: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

SMB Direct ∈ Samba

Michael Adam SMB3 in Samba (24/33)

Page 34: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Outlook: persistent handles

Page 35: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Persistent File Handles

I available on ’Continuously Available’ SMB3 shares

I allows disconnected clients to reconnect

I like durable handles, but with strong guarantees!

Michael Adam SMB3 in Samba (26/33)

Page 36: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Persistent Handles : Challenges

I protocol is easyI wip patches for the protocol head exist since many yearsI extended patches for protocol head on ML from contributors

I persistence/guarantees are hardI strategies for guarantees:

I filesystem specificI generic, with tdb/ctdb extensions:

essentially per-record persistence

Michael Adam SMB3 in Samba (27/33)

Page 37: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Outlook: clustering / witness

Page 38: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Witness - General

I New DCE/RPC Service to “witness” availability of IPs, shares, ...

I ⇒ Faster fail-over of clients in the cluster

I Prompt, explicit, and controlled notifications about failures(CTDB tickle-ACKs are implicit)

I Available since SMB3 (Windows 8 / Windows Server 2012)

I basis for ”cluster” capability

Michael Adam SMB3 in Samba (29/33)

Page 39: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Witness - Samba

Currently under development in Samba

I PoC implementation available

I TODO(wip): new async DCE/RPC infrastructureI https://wiki.samba.org/index.php/Samba3/

SMB2#Witness Notification Protocol

I WIP branch:https://git.samba.org/?p=gd/samba/.git;a=shortlog;

h=refs/heads/master-witness

Samba Witness service will cause Windows clients to reconnect...

I when client admin tool is used

I when CTDB (or any other cluster resource control manager) movesresources or IP addresses

Michael Adam SMB3 in Samba (30/33)

Page 40: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Wrapping up...

Page 41: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

What’s next ?

I SMB3 Multi-Channel: finishing moves

I SMB3 Witness service: async RPC

I SMB3 Persistent Handles / CA

I SMB3 over RDMA (SMB direct)

I Multi-Protocol access (NFS, SMB...)

I SMB2+ Unix Extensions ⇒ Jeremy’s Talk!

Michael Adam SMB3 in Samba (32/33)

Page 42: SMB3 in Samba · I client decides which connections to bind and to use I session is valid as long as at least one channel is intact two purposes 1.increase throughput: I use multiple

Thanks for your attention!

Questions?

[email protected]

[email protected]

https://git.samba.org/?p=obnox/slides/2016-09-sdc.git

https://www.samba.org/~obnox/presentations/2016-09-sdc/smb3-in-samba.pr.pdf