Architecture and Design of the Linux Storage Stack

Book description

Master the design and structure of Linux storage stack and explore its sophisticated architecture Purchase of the print or Kindle book includes a free PDF eBook

Key Features

  • Explore the virtual file system (VFS) and how it serves as an abstraction layer for the actual file system
  • Understand how the block layer acts as an intermediary between file systems and physical storage
  • Discover the physical layout and protocols linked with storage media

Book Description

The Linux storage stack serves as a prime example of meticulously coordinated layers. Embark on a journey through the kernel code with Architecture and Design of the Linux Storage Stack, crafted for anyone seeking in-depth knowledge about the layered design of Linux storage and its landscape.

You’ll explore the Linux storage stack and its various concepts. You’ll unlock the secrets of the virtual filesystem and the actual filesystem and the differences in their implementation, the role of the block layer, the Multi-Queue and Device Mapper frameworks, I/O schedulers, physical storage layout, and how to analyze all the layers in the storage stack.

By the end of this book, you’ll be acquainted with how a simple I/O request from a process travels down through all the layers and ends up in physical storage.

What you will learn

  • Understand the role of the virtual filesystem
  • Explore the different flavors of Linux filesystems and their key concepts
  • Manage I/O operations to and from block devices using the block layer
  • Deep dive into the Small Computer System Interface (SCSI) subsystem and the layout of physical devices
  • Gauge I/O performance at each layer of the storage stack
  • Discover the best storage practices

Who this book is for

This book is for system and storage administrators, engineers, linux professionals, linux community in general, and anyone looking to expand their understanding of Linux and its storage landscape. Prior knowledge of Linux operating system is a must.

Table of contents

  1. Architecture and Design of the Linux Storage Stack
  2. Contributors
  3. About the author
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
    9. Download a free PDF copy of this book
  6. Part 1: Diving into the Virtual Filesystem
  7. Chapter 1: Where It All Starts From – The Virtual Filesystem
    1. Technical requirements
    2. Understanding storage in a modern-day data center
      1. Interacting with storage in Linux
    3. Understanding system calls
    4. Explaining the need for a Virtual Filesystem
    5. Describing the VFS
      1. Implementing a common filesystem interface through the VFS
      2. Peeking at the source code
    6. Tracing VFS functions
    7. Explaining the Everything is a file philosophy
    8. Summary
  8. Chapter 2: Explaining the Data Structures in a VFS
    1. Technical requirements
    2. Data structures in VFS
    3. Inodes – indexing files and directories
      1. Defining an inode in the kernel
      2. Defining inode operations
      3. Tracking file data on disk through inodes
      4. Can a filesystem run out of inodes?
    4. Directory entries – mapping inodes to filenames
      1. Dentry cache
      2. Dentry states
      3. Dentry operations
    5. File objects – representing open files
      1. Defining file operations
      2. Can a process run out of file descriptors?
    6. Superblocks – describing filesystem metadata
      1. Superblock operations in the kernel
      2. Linking
      3. Summarizing the four structures
      4. Page cache
      5. Reading
    7. Summary
  9. Chapter 3: Exploring the Actual Filesystems Under the VFS
    1. Technical requirements
    2. The Linux filesystem gallery
    3. The diary of a filesystem – the concept of journaling
      1. The burning question – doesn’t journaling adversely affect performance?
    4. The curious case of CoW filesystems
    5. Extended filesystem
      1. Blocks – the lingua franca of filesystems
      2. Is there a more efficient approach to organizing data?
      3. The structural layout of an Ext4 filesystem
    6. Network filesystem
      1. NFS architecture
      2. Comparing NFS with regular block filesystems
    7. FUSE – a unique method for creating filesystems
    8. Summary
  10. Part 2: Navigating Through the Block Layer
  11. Chapter 4: Understanding the Block Layer, Block Devices, and Data Structures
    1. Technical requirements
    2. Explaining the role of the block layer
    3. Defining block devices
    4. The defining characteristics of a block device
    5. Looking at the representation of block devices
    6. Looking at data structures in the block layer
      1. The register_blkdev function (block device registration)
      2. The block_device structure (representing block devices)
      3. The gendisk structure (representing physical disks)
      4. The buffer_head structure (representing blocks in memory)
      5. The bio structure (representing active block I/Os)
      6. The bio_vec structure (representing vector I/O)
      7. Requests and request queues (representing pending I/O requests)
    7. The journey of an I/O request in the block layer
    8. Summary
  12. Chapter 5: Understanding the Block Layer, Multi-Queue, and Device Mapper
    1. Technical requirements
    2. Looking at problems with single-request queues
    3. Understanding the multi-queue block I/O framework
      1. Looking at data structures
      2. Looking at the device mapper framework
      3. Looking at multi-tier caching mechanisms in the block layer
    4. Summary
  13. Chapter 6: Understanding I/O Handling and Scheduling in the Block Layer
    1. Technical requirements
    2. Understanding the I/O handling techniques in block layer
      1. Sorting
      2. Merging
      3. Coalescing
      4. Plugging
    3. Explaining the Linux I/O schedulers
      1. The MQ-deadline scheduler – guaranteeing a start service time
      2. Budget fair queuing – providing proportional disk share
      3. Kyber – prioritizing throughput
      4. None – minimal scheduling overhead
    4. Discussing the scheduling conundrum
    5. Summary
  14. Part 3: Descending into the Physical Layer
  15. Chapter 7: The SCSI Subsystem
    1. Technical requirements
    2. The device driver model
    3. Explaining the SCSI subsystem
      1. SCSI architecture
      2. The client and server model
    4. Summary
  16. Chapter 8: Illustrating the Layout of Physical Media
    1. Technical requirements
    2. Understanding mechanical hard drives
      1. Looking at the physical layout and addressing
      2. Looking at bad sectors
      3. Looking at hard drive performance
      4. Understanding where mechanical drives lag
    3. Explaining the architecture of solid-state drives
      1. Looking at the physical layout and addressing
      2. Looking at reads and writes
      3. Erasing, garbage collection, and the illusion of available space
      4. Looking at wear leveling
      5. Looking at bad block management
      6. Looking at SSD performance
      7. Understanding where SSDs lag
    4. Understanding drive endurance
    5. Reinventing SSDs with NVMe
    6. Summary
  17. Part 4: Analyzing and Troubleshooting Storage Performance
  18. Chapter 9: Analyzing Physical Storage Performance
    1. Technical requirements
    2. How do we gauge performance?
    3. Understanding storage topology
    4. Analyzing physical storage
      1. Understanding disk service time
      2. Disk access patterns
      3. Determining reads/writes ratio and I/O size
      4. Disk cache
      5. IOPS and throughput
      6. Queue depth
      7. Determining disk busyness
      8. I/O wait
    5. Using disk I/O analysis tools
      1. Establish a baseline using top
      2. The iotop utility
      3. The iostat utility
      4. Performance Co-Pilot
      5. The vmstat command
      6. Pressure Stall Index
    6. Summary
  19. Chapter 10: Analyzing Filesystems and the Block Layer
    1. Technical requirements
    2. Investigating filesystems and the block layer
    3. The different types of filesystem I/O
    4. What causes filesystem latency?
    5. Identifying the target layers
    6. Finding the right tools
      1. Tracing application calls
      2. Tracing VFS calls
      3. Analyzing cache usage
      4. Analyzing filesystems
      5. Analyzing block I/O
      6. Summarizing the tools
    7. Summary
  20. Chapter 11: Tuning the I/O Stack
    1. Technical requirements
    2. How memory usage affects I/O
    3. Tuning the memory subsystem
      1. Using direct I/O
      2. Controlling the write-back frequency
    4. Tuning the filesystem
      1. Block size
      2. Filesystem I/O alignment
      3. LVM I/O alignment
      4. Journaling
      5. Barriers
      6. Timestamps
      7. Read-ahead
      8. Discarding unused blocks
    5. Choosing the right scheduler
    6. Summary
  21. Index
    1. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Architecture and Design of the Linux Storage Stack
  • Author(s): Muhammad Umer
  • Release date: July 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781837639960