33.1. Choosing a Shared Storage Architecture

The first decision is not which package to install. It is what the application needs from the data: a raw block device, a POSIX filesystem, a shared directory, or an object API. That answer decides whether the second host may mount the storage directly, whether a lock manager is required, and what a failover is allowed to interrupt.

33.1.1. Shared Block Devices, Network Filesystems, and Distributed Storage

A shared block device is the least abstract option. The storage server exports a LUN; the client's kernel sees a SCSI disk and can put any filesystem, volume manager, or database on it. The storage server does not understand the filesystem and cannot arbitrate between clients. If two hosts mount the same ext4 filesystem, each kernel caches metadata and inodes independently and neither knows the other exists. The result is corruption, not concurrency.

A network filesystem moves the arbitration to a server. The client sends file operations over NFS or SMB; the server serializes access and owns the disk. This is the normal choice for shared home directories and file shares, and it scales to many clients because the server, not every client, manages the metadata. The cost is that the server is a failure domain unless it is made highly available, which is the subject of Chapter 32.

A cluster filesystem keeps the block-device model but adds a distributed lock manager and a shared journal. Every node mounts the same filesystem; locks are granted and revoked over the cluster network, and a node that dies must be prevented from writing before another node recovers its locks. GFS2 and OCFS2 are the two cluster filesystems packaged for Debian. They are the right tool when applications need direct POSIX access from several nodes and cannot be fronted by a single NFS or SMB server.

Distributed storage removes the single data server altogether. Ceph spreads objects across many OSDs, uses CRUSH to decide placement, and exposes the resulting pool as a block device (RBD), a POSIX filesystem (CephFS), or an object service (RADOS Gateway). Clients consult monitors for maps and then talk to OSDs directly. There is no node whose loss stops the namespace, as long as enough replicas remain and the monitors retain quorum.

Model Unit the client uses Who arbitrates concurrent access Debian packages Typical fit
Local disk block device the one host e2fsprogs, xfsprogs a single server
Shared block, ordinary filesystem block device nobody; one host at a time open-iscsi, multipath-tools a database or filesystem that has its own fencing or is active-passive
Shared block, cluster filesystem block device with cluster locks DLM plus the cluster stack gfs2-utils, dlm-controld, ocfs2-tools several nodes needing direct POSIX access
Network filesystem files and directories the NFS or SMB server nfs-kernel-server, samba shared directories for many clients
Distributed block/file/object block device, filesystem, or S3 API CRUSH placement and per-object locks; monitors for maps ceph-mon, ceph-osd, ceph-mds, radosgw a storage cluster that must survive node loss without a single data server

The comparison is not a ranking. A single NFS server with a good backup is simpler and faster to operate than a three-node Ceph cluster, and a two-node DRBD pair is often the correct answer for a small active-passive service. The rest of this chapter uses each model where it fits and points out the point at which the simpler model stops being safe.

33.1.2. Single-Writer Ownership Versus Concurrent Multi-Host Access

An ordinary filesystem is built on the assumption that one kernel owns the superblock. Its journal, inode cache, directory cache, and block allocator are not designed to hear from a peer. Exporting that filesystem's block device to a second host does not change the assumption; it only hides the second writer from the first.

There are two safe ways to use a shared LUN with an ordinary filesystem. The first is single-writer ownership: exactly one host mounts the filesystem at a time, and ownership moves only after the old owner has flushed and unmounted. Pacemaker can enforce that order with a Filesystem resource and a virtual address; Chapter 32 builds such a group. The second is to keep the filesystem mounted on one host and export it over NFS or SMB, so the other hosts never touch the blocks. Both approaches put a single authority between the shared device and its users.

Concurrent multi-host access needs a filesystem that was designed for it. GFS2 places a lock manager (DLM) between the filesystem and the block device. A node that wants to modify an inode asks DLM for the appropriate lock; DLM grants it only when no conflicting holder exists, and revokes locks when a node joins or leaves. The block device is still shared, but the filesystem no longer assumes that its own cache is the only cache.

33.1.3. Locking, Leases, Quorum, and Fencing

A distributed lock is a promise with a timeout. DLM grants a lock to a node and expects the node to release it or to be declared dead. If the node is merely slow, the lock manager cannot distinguish "slow" from "dead" without a failure detector. Quorum is the membership decision: a majority of the cluster's voting members must agree who is allowed to act. Fencing is the enforcement: before a failed node's locks are recovered, the cluster must make it impossible for that node to write. A power controller, a storage array's LUN masking, or a hypervisor reset can provide that guarantee. A network partition alone does not.

The rule is simple and unforgiving: if you cannot fence a node, you cannot safely give its storage to another node. Running GFS2 or a Pacemaker Filesystem resource with fencing disabled is a laboratory simplification, not a production configuration. The lab in this chapter disables fencing because the guests have no out-of-band power control; the text marks where a real deployment must supply it.

A lease is a time-bounded grant that a client must renew. NFSv4 leases, Ceph monitor sessions, and DRBD's peer states all use timeouts to decide when a peer is gone. Timeouts trade recovery speed against false failure: too short and a busy node loses its locks; too long and clients wait for a dead node. The correct values depend on the network's worst-case delay, not on the average.

33.1.4. Latency, Network Capacity, and Independent Failure Domains

Sharing storage puts a network in the I/O path. A local SSD may answer a 4 KiB read in tens of microseconds; an iSCSI LUN adds the target's queueing, the network round trip, and the target disk. Replication adds another network hop and another disk. The application's tolerance for that latency, not a generic benchmark, decides whether shared storage is appropriate.

Capacity planning must count every copy. Three-way replication stores three copies of every object, so 6 GiB of raw OSD capacity does not provide 6 GiB of usable pool capacity. Recovery traffic competes with client traffic, and a rebuild after a node loss can saturate a link that was sized only for normal writes. Section 33.6.2 works through the arithmetic and the backfill behaviour.

Finally, a failure domain is any component whose failure takes out a set of data at once. A host, a disk shelf, a power feed, a switch, or a rack can be a failure domain. Ceph's CRUSH rule in this chapter places replicas on different hosts, which protects against one host loss but not against a rack or site loss. A two-node DRBD pair has no independent failure domain for quorum unless a witness is added. The topology in Figure 33.1 separates the data network from the cluster network, but all five guests still share one hypervisor; a production design must place the copies in domains that fail independently.

Storage models

Figure 33.2. The model determines where consistency is enforced. Moving from local disk to distributed storage moves the boundary from the kernel's page cache to a cluster protocol.