Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Checkpoint and Restore of file locks in userspace in Linux Pavel Begunkov, SPbAU RAS, CEE-SECR 2017

CEE-SECR
October 20, 2017

Checkpoint and Restore of file locks in userspace in Linux Pavel Begunkov, SPbAU RAS, CEE-SECR 2017

I will talk about checkpoint and restore(c/r) in Linux in userspace and give an overview of live-migration and c/r tools, and CRIU in particular. I will present a mechanism for c/r of two types of file locks and tell about work with Linux API, kernel code and concomitant problems.

The work will be of interest to administrators, specialists in this field and people keen on developing software at the edge of userspace and kernel.

CEE-SECR

October 20, 2017
Tweet

More Decks by CEE-SECR

Other Decks in Technology

Transcript

  1. Software Engineering Conference Russia October 2017, St. Petersburg CRIU: Checkpoint

    and Restore & file locks • Pavel Begunkov (Silence) SpbAU RAS 1
  2. 2 • Failure tolerance ◦ Network ◦ Hardware ◦ Programmer

    • Scalability • Flexibility • etc.
  3. Checkpoint & Restore image restore 3 Host 1 App 1

    App 2 App 3 Host 2 App 1 App 2 App 3 checkpoint
  4. What for? • Live-migration • Load-balancing • Failure tolerance &

    recovery • etc. criu.org/Usage_scenarios 4
  5. 5 Program state Hardware state (e.g. CPU registers) Memory Kernel

    (files, threads, etc)
  6. 6 • Code instrumentation • LD_PRELOAD • Kernel modification •

    Kernel module • Userspace solution • etc. How to do c/r?
  7. CRIU: Checkpoint and Restore In Userspace 7

  8. 8 - checkpoint/restart feature work. “A note on this: this

    is a project by various mad Russians to perform c/r mainly from userspace, with various oddball helper code added into the kernel where the need is demonstrated.” Torvalds committed on Jan 13, 2012 (commit 0994695)
  9. 9 • Procfs • System calls • Code injection Userspace

    c/r Hardware state (e.g. CPU registers) Memory Kernel (files, threads, etc)
  10. Types 1. BSD locks 2. POSIX locks 3. OFD locks

    4. File lease File locks 10 Key features 1. Read-Write synchronisation 2. Advisory & Mandatory*
  11. File locks 11 Checkpoint 1. Read locks from procfs 2.

    Match each lock with physical file* 3. Match each lock with open file description* 4. Fixup the data 5. Save to image Restore 1. Read image 2. Open file 3. Set lock (fcntl, flock, etc) 4. [break lease]
  12. Procfs & locks 12

  13. File locks 13 Checkpoint 1. Read locks from procfs 2.

    Match each lock with physical file* 3. Match each lock with open file description* 4. Fixup the data 5. Save to image Restore 1. Read image 2. Open file 3. Set lock (fcntl, flock, etc) 4. [break lease]
  14. 14 Breaking leases

  15. 15 Bugs

  16. Pavel Begunkov (Silence) • asml.silence [at] gmail.com • www.linkedin.com/in/isilence •

    www.github.com/isilence Contact information