Implementing SMB2 in Samba. Opening Windows to a Wider. Jeremy Allison Samba Team/Google Open Source Programs Office

Similar documents
The State of Samba (June 2011) Jeremy Allison Samba Team/Google Open Source Programs Office

Samba. OpenLDAP Developer s Day. Volker Lendecke, Günther Deschner Samba Team

SNIA SDC 2018 Santa Clara

SerNet. Async Programming in Samba. Linuxkongress Oktober Volker Lendecke SerNet Samba Team. Network Service in a Service Network

Clustered Samba Challenges and Directions. SDC 2016 Santa Clara

SMB2 and SMB3 in Samba: Durable File Handles and Beyond. sambaxp 2012

SerNet. Samba Status Update. SNIA SDC 2011 Santa Clara, CA. Volker Lendecke SerNet Samba Team

SMB3 and Linux Seamless POSIX file serving. Jeremy Allison Samba Team.

Emulating Windows file serving on POSIX. Jeremy Allison Samba Team

Jeremy Allison Samba Team

SDC 2015 Santa Clara

The CephFS Gateways Samba and NFS-Ganesha. David Disseldorp Supriti Singh

SMB 2.1 & SMB 3 Protocol features, Status, Architecture, Implementation. Gordon Ross Nexenta Systems, Inc.

Samba4 Status - April Andrew Tridgell Samba Team

CTDB + Samba: Scalable Network Storage For The Cloud. Storage Networking World Europe 2011

Clustered NAS For Everyone Clustering Samba With CTDB A Tutorial At sambaxp 2009

COMMON INTERNET FILE SYSTEM PROXY

Distributed Systems. Hajussüsteemid MTAT Distributed File Systems. (slides: adopted from Meelis Roos DS12 course) 1/25

Samba4 Progress - March Andrew Tridgell Samba Team

Gerald Carter Samba Team/HP

Samba in a cross protocol environment

Clustered NAS For Everyone Clustering Samba With CTDB. NLUUG Spring Conference 2009 File Systems and Storage

A new DCERPC infrastructure for Samba

A new DCERPC infrastructure for Samba

The Death of File Sharing Protocols. Jeremy Allison Samba Team/Google Open Source Programs Office

Clustering Samba With CTDB A Tutorial At sambaxp 2010

Clustering Samba With CTDB A Tutorial At sambaxp 2010

SMB3 Multi-Channel in Samba

SDC EMEA 2019 Tel Aviv

HANDLING PERSISTENT PROBLEMS: PERSISTENT HANDLES IN SAMBA. Ira Cooper Tech Lead / Red Hat Storage SMB Team May 20, 2015 SambaXP

Simo Sorce Samba Team.

SMB 2.0 Next Generation CIFS protocol in Data ONTAP

Flash: an efficient and portable web server

System that permanently stores data Usually layered on top of a lower-level physical storage medium Divided into logical units called files

PLAYING NICE WITH OTHERS: Samba HA with Pacemaker

SA30228 / CVE

Background: I/O Concurrency

Towards full NTFS semantics in Samba. Andrew Tridgell

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Samba and Ceph. Release the Kraken! David Disseldorp

Using samba base libraries SSSD as an example application

Outline. Threads. Single and Multithreaded Processes. Benefits of Threads. Eike Ritter 1. Modified: October 16, 2012

Lessons learned implementing a multithreaded SMB2 server in OneFS

Implementing the Witness protocol in Samba

SMB3: Bringing High Performance File Access to Linux: A Status Update. How do you use it? What works? What is coming soon?

Exception-Less System Calls for Event-Driven Servers

Distributed file systems

CTDB Remix - Dreaming the Fantasy

Azure File Service: Expectations vs. Reality on the Public Cloud David Goebel Microsoft

Samba 4 Status Report

LAS16-TR06 Remoteproc & rpmsg development. Bjorn Andersson

CS Lab 1: httpd

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

The Google File System

Memory Management Strategies for Data Serving with RDMA

Chapter 4: Multithreaded Programming. Operating System Concepts 8 th Edition,

Notes. CS 537 Lecture 5 Threads and Cooperation. Questions answered in this lecture: What s in a process?

WINS Replication. Stefan Metzmacher SerNet Service Network GmbH Samba Team

CHAPTER 3 - PROCESS CONCEPT

Feeling odd Using new OS and CPU features to speed up large file copying. Sebastian Krahmer stealth [at] openwall net.

[MS-SMB2]: Server Message Block (SMB) Protocol Versions 2 and 3

CSE 544: Principles of Database Systems

Implementing Persistent Handles in Samba. Ralph Böhme, Samba Team, SerNet

CS533 Concepts of Operating Systems. Jonathan Walpole

Chapter 4: Threads. Chapter 4: Threads

Networking and Internetworking 1

02 - Distributed Systems

02 - Distributed Systems

CSE 544 Principles of Database Management Systems

Big and Fast. Anti-Caching in OLTP Systems. Justin DeBrabant

Network Simulator Project Guidelines Introduction

Eduardo

OPERATING SYSTEM. Chapter 4: Threads

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

True/False: In Signal and Wait, the signaller finishes execution while the signalled process waits for its turn

An AIO Implementation and its Behaviour

Processes and Threads

Asynchronous Events on Linux

NETWORK SIMULATION USING NCTUns. Ankit Verma* Shashi Singh* Meenakshi Vyas*

Improving Azure File Service: Adding New Wings to a Plane in Mid-flight David Goebel Microsoft

Chapter 4: Multithreaded

Internal Server Architectures

Distributed Systems 16. Distributed File Systems II

CSE544 Database Architecture

CISC2200 Threads Spring 2015

6.9. Communicating to the Outside World: Cluster Networking

EMC VNX Series: Introduction to SMB 3.0 Support

Solving Linux File System Pain Points. Steve French Samba Team & Linux Kernel CIFS VFS maintainer Principal Software Engineer Azure Storage

Chapter 4: Multi-Threaded Programming

Linux multi-core scalability

Chapter 4: Threads. Chapter 4: Threads

TCP/misc works. Eric Google

! Design constraints. " Component failures are the norm. " Files are huge by traditional standards. ! POSIX-like

The Application Layer HTTP and FTP

CSE398: Network Systems Design

DCERPC and Endpoint Mapper

Building a Highly Scalable and Performant SMB Protocol Server

Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland

What s in a process?

Portland State University ECE 588/688. Directory-Based Cache Coherence Protocols

Transcription:

Implementing SMB2 in Samba Jeremy Allison Samba Team/Google Open Source Programs Office jra@samba.org jra@google.com

What is SMB2? Microsoft's replacement for SMB/CIFS. Ships in Vista, Windows7 and Windows 2008. Considerably simpler than SMB/CIFS. Only 19 requests vs. ~100 for CIFS. Much better support for asynchronous request/responses and multiple concurrent requests. Larger read/write sizes for more modern networks/machines.

What is Samba? Large, old codebase (started in 1991). Getting larger and older.. Only fully-featured implementation of SMB/CIFS outside of Microsoft. Implements AD domains, NT domains, printing, registry, performance counter and other things most other implementations don't care about :-). Open Source/Free Software under GPLv3 license.

How to move to SMB2? Samba works as a separate daemon process (smbd) per connected client. Options were to write all SMB2 code as a new server: Advantage is clean slate design. Disadvantage is re-implementation of lots of subtle working SMB1 code that still applies to SMB2 semantics. Separate server is still an option to explore, as changing to SMB2 is a gateway on initial client packet.

A Historical Precedent Samba has undergone a similar change in the past. DOS/Windows 3.1/Windows 95 use old SMB semantics on the wire (SMBopenX and friends). Windows NT uses NTCreateX with a different set of share parameters. Samba used to implement the DOS API, and map the Windows NT semantics onto it. Was changed to implement DOS semantics on top of Windows NT. Birth of the Samba VFS.

Refactoring in a nutshell..

Samba VFS Provides an internal API that represents the Windows file API. NTCreateFile() etc. Other associated API's make it easy to build Windows file sharing semantics underneath a packet parsing layer. Not useful as an external API as too much knowledge of Samba internals needed. But close to what we need to implement Windows semantics under an SMB2 parser.

The Four T 's Samba is built on top of four libraries: TALLOC (tridge): Hierarchical memory allocator. C++ style destructors. TDB (tridge, rusty): Fast, multi-reader/writer key/value pair database. TEVENT/TEVENT_REQ (tridge, Volker, Metze): Async event library. TSOCKET (Metze). Helper library for tevent_req.

talloc() Talloc header + memory Talloc header + memory Talloc header + memory Talloc header + memory talloc_free() this to remove the whole tree. Talloc header + memory Etc. A heirarchical tree of allocations, with associated destructors.

Trivial DataBase (tdb). Was so called because it once took less than 1000 lines of code. Once transactions were added this was no longer the case. mmap()'ed shared memory area arbitrated by fcntl() locks. Very scalable for multi-readers/writers. Dynamically expands as entries added (munmap(), ftruncate(), mmap()). Depends on coherent buffer cache between pread/pwrite/mmap.

tevent/tevent_req/tsocket Similar to libevent/libev In our defense, at the time tevent was created libevent did not handle POSIX realtime signals at all. tevent heavily uses talloc(), making it much easier to integrate into the Samba event loop. Set all sockets into asynchronous mode, then just get callbacks when data is ready to read/write.

tevent/tevent_req/tsocket (continued) tevent_req is a pattern around tevent, making handling of asynchronous requests completely boilerplate. Allows read and write requests to be asynchronously passed to named pipe services. Finally named pipe servers can be moved out of process reduce smbd bloat! Simo has a prototype of spoolssd out of process.

The central role of tevent SMB1/2 Client Request Reply 2 Packet parser 3a tevent/tevent_req/tsocket library 4a Smbd File System VFS 8b 3b External pipe process 4b 5b 6b 7b Pipe Parser = TCP socket

tevent timeout functions Signals and time-based events functions are handled as callbacks within tevent. Allows modular handling of all smbd housekeeping functions. Can cause interesting bugs :-) Thanks to Microsoft's Nick Meier for some iozone help with SMB2 in Samba.

Implementing the SMB2 parser (design by metze) Tevent/tevent_req used to construct an array of io_vec structs containing the parts of an SMB2 packet. iov[0] = NBT header for all requests. Iov[1] = SMB2 header (fixed) iov[2] = SMB2 header (variable) iov[3] = (variable length) rest of SMB2 packet. Chained SMB2 requests create a tuple of io_vec structs for each incoming SMB2 request inside the NBT packet.

Implementing the SMB2 parser (continued) Every incoming request is matched with an outgoing io_vec tuple. To deal with each packet in turn, simply increment the index into the io_vec array by 3. All incoming requests and outgoing replies are on a queue with attached state. Allows multiple requests/responses in flight inside the server code. Significant improvement on the SMB1 code design.

Asynchronous SMB2 requests Every SMB2 request has the ability to go asynchronous. Server can send an interim response to inform the client this may take some time. Internally this is handled by splitting out the delayed request into a separate entry on the request queue, and generating an interim response iovec tuple. Allows a later SMB2_CANCEL request to delete any unprocessed request.

SMB2 asynchronous IO Windows client redirector (finally) will do multiple outstanding reads/writes to reduce the effects of latency. Samba SMB2 implementation uses POSIX aio to allow this (or Volker's fork VFS module). On Linux, current glibc design has problems with this. Patch available from speaker :-). sendfile()/recvfile() (zero copy) not yet implemented in current SMB2 code planned for final 3.6.0.

Interfacing to the internal API The SMB1 API needed some updates to cope with SMB2. The SMB1 : MID (multiplex ID) field is only 16 bits was expanded to 64 bits for SMB2. Unfortunately means share mode database format changes. Many of the internal functions take a struct smb_request, which is SMB1 only. Each SMB2 request fakes up a struct smb_request for the API. Eventually this will get reversed.

Interfacing to the internal API (continued) Remarkably few other changes were needed to make the SMB1 oplock, locking, change notify and deferred open (share mode) code work with SMB2. Only 23 instances of : if (using_smb2) needed in the entire codebase. Full support for all named pipes (print spooler, LSA, SAMR, registry etc.) available

What is left to do? Support for the Windows tools to get and set user quotas is the only missing SMB2.002x feature in the server code. Credit algorithm may need work. Post 3.6.x we need to add SMB2.1 dialect features to the underlying file sharing engine. Lease level on File oplocks. Durable file open handles. Some of the SMB2.1 features may need extra kernel support.

SMB2.x features Adding durable file handles will mean additional state added into a persistent tdb kept updated on every handle change. Making this work across clustered Samba will be interesting. SMB2.1 leases Allow handle caching across multiple opens by the same client. Easier than fixing Microsoft Office code :-). Implementation will start with smbtorture tests

What is left to do (continued)? Modify libsmbclient to allow SMB2 connections. Allow Linux GNOME/KDE desktops to easily integrate with SMB2 servers. Use smbclient as a test bed to get the right internal API's. smbtorture4 already does some SMB2 tests written by Tim Prouty (tprouty). Samba 3.6.0 will ship with production-ready SMB2 support, but not on by default. The next release (4.0) should have this on by default.

An anecdote Early OEMs running v3-6-test code in advance of release have reported 2x the performance of the same applications running over SMB1. This is before SENDFILE() fix added to the server. Almost certainly due to improvements in Windows client redirector with SMB2.

Praise and thanks The ease of production-ready SMB2 support in the 3.6.0 server is a testament to the hard work done in design and coding by: Andrew Tridgell (tridge) Stefan Metzmacher (metze) Volker Lendecke (vl) Simo Source (idra) Guenther Deschner (gd)

Questions and Comments? Email: jra@samba.org jra@google.com