🎓 BookMCQ
← Back to 10. Mass Storage Structure

📝 Stable Storage Implementation

Maintaining Reliable Data Through Redundant Storage

Stable storage is a storage-management abstraction designed to preserve information despite failures during write operations. Its central guarantee is that an interrupted write should leave either the previous valid data or the complete new data, rather than an inconsistent mixture of both. Because ordinary nonvolatile storage can still experience hardware errors, interrupted transfers, and power failures, stable storage is approximated by maintaining multiple physical copies of each logical data block on devices with independent failure modes. The copies must be updated in a controlled sequence so that a failure does not damage all available valid information. Error-detection mechanisms such as error-correcting codes (ECC) or checksums help identify corrupted copies, while recovery procedures restore consistency after a failure. Stable-storage principles are particularly important for reliable file-system metadata, database records, and write-ahead logs, where an incomplete update could leave persistent information inconsistent.

Stable Storage Implementation and Crash RecoveryA detailed illustration of stable storage showing two independent physical copies, sequential write operations, successful, partial and total write failures, recovery decisions and NVRAM caching.Stable Storage ImplementationRedundant physical copies, controlled writes and consistent recovery after failures1. Ordered Write ProtocolOne logical block is stored as two physical copies on independent storage devices.Logical BlockData BFIRST WRITEDisk 1: Copy AWrite and verifySECOND WRITEDisk 2: Copy BWrite after first succeedsWrite CompleteBoth copies successfulCompletion is acknowledged only after the required writes have succeeded.2. Three Possible Outcomes of a Disk WriteSuccessful CompletionAll intended data are written correctly.The physical block contains the new value.!Partial FailureTransfer stops before completion.Some sectors may be new; a block may be corrupted.Total FailureFailure occurs before the write starts.The previous data remain unchanged.3. Comparing Copies During RecoveryBoth Copies MatchBoth copies pass error checksand contain identical data.No repair requiredOne Copy Is DamagedECC or checksum detects an errorin one physical block.Restore it from the good copyBoth Copies Valid but DifferentUse the defined write-order and recoveryrule to choose a consistent version.Restore consistency according to protocolStable read: check the first copy; use the second when the first fails its integrity check.NVRAM can act as a nonvolatile write cache to reduce the delay of synchronous disk operations.Operating Systems • Mass Storage • Stable-Storage Implementation
Stable-storage write sequence, three possible write outcomes and the recovery decisions used to restore consistent physical copies. The layout changes to a vertical format on mobile screens.

Why Ordinary Disk Writes Cannot Guarantee Permanent Consistency

Ordinary disk writes cannot always guarantee a consistent result because a hardware or power failure may interrupt data transfer. A disk write can have three outcomes: successful completion, partial failure, or total failure. During successful completion, the intended data are written correctly. During partial failure, some sectors may contain the new information while the sector being written at the time of interruption may become corrupted. During total failure, the operation never begins, leaving the previous data unchanged. The most difficult situation is a partial failure because the affected physical block may contain neither a reliably complete old value nor a complete new value. Maintaining two physical copies for each logical block helps preserve an unaffected version while the system recovers. However, redundancy alone is insufficient; the order in which copies are updated must also be controlled.

Redundant Copies, Verification and Recovery Protocols

A classical stable-storage implementation maintains two physical blocks for each logical block, preferably on storage devices with independent failure modes. To update a logical block, the operating system first writes the new information to the first physical block. Only after that write completes successfully does it write the same information to the second physical block. The logical operation is declared complete only after the second write succeeds. Error-detection mechanisms, such as ECC or checksums, help identify a physical block that has been corrupted during transfer. Recovery examines each pair of copies and determines whether they contain identical valid information, whether one contains a detectable error, or whether both are valid but different. If both copies match and pass verification, no repair is necessary. If one copy is damaged and the other remains valid, the damaged copy is replaced using the valid one. If both copies are error-free but different, the system follows its defined write-order and recovery rule to select a consistent version. This controlled procedure is designed to leave a complete valid value rather than an uncertain mixture of old and new information.

Recovering a Block After an Interrupted Write

Suppose a storage system maintains two physical copies of an important metadata block on separate disks. The operating system first writes the updated block to Disk 1 and waits for successful completion before starting the write to Disk 2. If power fails while Disk 1 is being updated, its error-detection information can reveal the damaged block, allowing the intact copy on Disk 2 to restore the previous valid data. If Disk 1 completes successfully but the second write is interrupted, recovery examines both copies and applies the protocol's ordering rule to restore a consistent state. In one traditional textbook recovery procedure, when both blocks pass error checks but contain different values, the second physical block is copied to the first. If the second disk's write itself was partially completed and produces an error, the valid first copy can instead restore the damaged second copy. The essential requirement is that the recovery method knows which states are possible under the chosen write sequence and can restore a complete valid value. Recovery must also be designed to continue safely when another failure interrupts the repair process, subject to the assumption that at least one valid copy survives.

Reliability, Recovery Overhead and Physical Independence

Stable storage improves resilience against interrupted writes and certain storage failures, but its implementation introduces additional storage requirements, verification operations, and write latency. Two physical writes are needed for each completed logical update, and synchronous execution must wait for the required writes to finish. Nonvolatile RAM (NVRAM), including battery-backed or power-protected cache memory, can reduce this delay by retaining pending information without losing it during an ordinary power interruption. A stable read can examine one physical copy and use the other when an integrity check identifies an error. Physical independence is important because two copies exposed to the same hardware fault, controller failure, or power event may be damaged together. Ordinary RAID 1 mirroring alone does not guarantee stable-storage behaviour: simultaneous mirrored writes can leave both copies partially updated after a crash because mirroring by itself does not necessarily provide the required sequential write and recovery rules. Stable storage also supports write-ahead logging, in which log records must become durable before the corresponding data changes are applied. Modern storage systems use mechanisms such as write barriers, Force Unit Access (FUA), and power-loss protection to help preserve write ordering and durability. Nevertheless, stable storage is a fault-tolerant abstraction rather than a literal guarantee against every possible failure. Independent off-site backups are still necessary for broader protection against disasters, accidental deletion, and failures affecting all local replicas.

Clarifying Stable Storage and Redundancy

'Stable storage means a disk never experiences hardware failure' is incorrect because its purpose is to preserve a consistent logical value despite certain physical failures. 'Two copies automatically guarantee the latest valid version' is incorrect because controlled write ordering, error detection, and recovery rules are needed to decide which information is valid. 'A write is complete immediately after the first physical copy succeeds' is incorrect in the classical two-copy protocol because completion is acknowledged only after the second physical write succeeds. 'RAID 1 automatically provides the same guarantee as stable storage' is incorrect because ordinary mirroring does not necessarily control the order of physical writes or provide the same recovery procedure. 'Stable storage eliminates the need for backups' is incorrect because replicated devices can still be affected by common hardware failures, accidental deletion, malicious modification, and disasters. Similarly, a checksum can detect certain forms of corruption, but it does not independently restore missing data; recovery requires another valid copy or another reliable source.

Exam Focus: Replica Verification and Crash Recovery

Be prepared to define stable storage and explain why multiple physical copies must have independent failure modes. Identify the three possible outcomes of a disk write: successful completion, partial failure, and total failure. Trace the ordered output procedure in which the first physical block is written before the second and the logical operation is completed only after both writes succeed. Explain how ECC or checksums help detect damaged copies, how a stable read can use an alternate valid copy, and how recovery responds when two copies match, one is corrupted, or both are valid but different. Understand the purpose of NVRAM caching and why ordinary RAID 1 mirroring alone does not guarantee stable-write consistency. Compare stable storage with backups, journaling, and write-ahead logging, paying particular attention to data integrity, write ordering, and recovery after interrupted operations.

Key Terms of Stable Storage

  • Stable storage - A storage abstraction that preserves a consistent logical value despite specified failures.
  • Replication - Maintaining multiple physical copies of the same information.
  • Independent failure modes - Storage arrangements in which one device failure is unlikely to cause another copy to fail simultaneously.
  • Logical block - A block of data presented as one logical storage unit.
  • Physical block - An actual storage location containing a copy of a logical block.
  • Partial failure - An interrupted write that may leave some sectors updated and the affected block corrupted.
  • Total failure - A write failure occurring before the operation begins, leaving the old data unchanged.
  • ECC - Error-correcting code used to detect and, within its limits, correct data errors.
  • Checksum - A calculated value used to detect changes or corruption in stored data.
  • Recovery - The procedure used to restore consistent physical copies after a failure.
  • Write ordering - The controlled sequence in which physical copies are updated.
  • Stable read - A read operation that uses another valid physical copy when the selected copy fails verification.
  • NVRAM - Nonvolatile memory that retains information without ordinary continuous power and can be used as a write cache.
  • Write-ahead logging - A recovery technique that makes log records durable before applying corresponding data updates.
  • Write barrier - A mechanism that enforces ordering constraints between storage writes.
  • FUA - Force Unit Access, a command feature used to request that data reach nonvolatile storage rather than remain only in a volatile cache.
4
Easy
6
Medium
4
Hard

📝 All Stable Storage Implementation MCQs

Q1. A disk scheduler receives the request queue {98, 183, 37, 122, 14, 124, 65, 67} and the head is currently at cylinder 5353. Using the C‑LOOK algorithm, which cylinder will be serviced next?

A.65 ✅
B.67
C.14
D.98
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The C‑LOOK algorithm services requests in increasing cylinder order starting from the current head position, then jumps directly to the lowest pending request. Since the head is at 5353, the next higher request in the queue is 6565. Therefore option A is correct. Options B, C, and D refer to later or lower cylinders that are not the immediate next target.

Q2. A server experiences a high volume of random disk requests, causing frequent head starvation with SSTF. Which scheduling algorithm is most likely to prevent starvation while maintaining good throughput?

A.FCFS
B.SSTF
C.SCAN ✅
D.LOOK
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: SCAN moves the disk arm in one direction servicing all pending requests before reversing, which prevents any request from being ignored indefinitely, unlike SSTF that may keep serving nearby requests. SCAN therefore reduces starvation risk while still providing reasonable throughput. FCFS processes in arrival order without optimizing movement, SSTF can cause starvation, and LOOK is similar to SCAN but stops at the last request, making SCAN the better answer for the described condition.

Q3. If a program reads a file stored contiguously from cylinder 2020 to 3030, while another program reads an indexed file with blocks at cylinders 55, 4545, 8080, and 120120, which program will cause more total head movement on average?

A.The program reading the contiguous file
B.The program reading the indexed file ✅
C.Both will cause equal movement
D.It depends on the initial head position
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The indexed file accesses blocks that are widely scattered, forcing the head to travel large distances between each block, whereas the contiguous file keeps the head within a small range of cylinders. Hence the indexed file program generates more head movement on average. The initial head position could affect the first seek but does not change the overall larger distance traveled for the indexed file, making option B correct.

Q4. Given the request queue {98, 183, 37, 122, 14, 124, 65, 67} and a head starting at cylinder 5353, what is the total number of cylinders the head moves under C‑LOOK (excluding the wrap‑around jump)?

A.145
B.150
C.158
D.153 ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: C‑LOOK services requests in increasing order from the current head position: 6565 → 6767 → 9898 → 122122 → 124124 → 183183; then it jumps to the lowest request 1414 and continues to 3737. The distances are 12+2+31+24+2+59+23=15312+2+31+24+2+59+23 = 153 cylinders. Option D matches this sum. The other options are close but do not reflect the correct cumulative distance, so D is the right answer.

Q5. In a file system where directory entries reside on cylinder 00 and file data begins on the last cylinder 199199, what is the minimum head movement required to open a file and read its first block?

A.199 cylinders ✅
B.100 cylinders
C.0 cylinders
D.199 minus current head position
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: To open a file, the head must first read the directory at cylinder 00 and then move to the file’s data at cylinder 199199. This requires traveling the full span of the disk, which is 199199 cylinders. Option A states this exact distance. Option D depends on an unspecified current head position, while options B and C underestimate the required movement, making A the correct choice.

Q6. A disk receives 80% sequential requests (near each other) and 20% random requests scattered across the disk. Which algorithm best balances response time for random requests while exploiting sequential locality?

A.FCFS
B.SSTF
C.C‑SCAN
D.LOOK ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: LOOK behaves like SCAN but stops at the last request in each direction, reducing unnecessary travel. This property lets it quickly serve sequential clusters while still moving in one direction, which improves response for scattered random requests compared to pure SSTF. FCFS does not optimize movement, SSTF can cause starvation, and C‑SCAN always returns to the start, adding extra travel. Therefore LOOK is the most balanced choice.

Q7. When the request queue contains only a single pending request, how do all disk‑scheduling algorithms behave relative to each other?

A.FCFS is fastest
B.All behave identically ✅
C.SSTF outperforms others
D.SCAN moves head back and forth
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: With only one request, every algorithm has no choice but to move the head directly to that cylinder, making their behavior identical to FCFS. There is no opportunity for optimization or direction changes, so the correct answer is that all algorithms behave the same. Options A, C, and D describe behaviors that require multiple pending requests, which are not applicable here.

Q8. Why does the SCAN algorithm reduce the likelihood of starvation compared to SSTF?

A.It services requests in a fixed direction ✅
B.It always chooses the closest request
C.It randomly selects a request
D.It ignores request order
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: SCAN moves the head monotonically in one direction, servicing every request encountered before reversing. This guarantees that any request will eventually be reached, preventing indefinite postponement. SSTF, by always picking the nearest request, can repeatedly skip far‑away requests, leading to starvation. Hence option A correctly explains the reduction in starvation risk.

Q9. How does the file allocation method influence disk head movement patterns?

A.Contiguous allocation clusters blocks, reducing movement ✅
B.Indexed allocation always places blocks together
C.Linked allocation eliminates movement
D.Allocation method has no effect
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When a file is stored contiguously, its blocks occupy consecutive cylinders, so the head moves only a short distance while reading the file. In contrast, indexed or linked allocations may locate blocks far apart, causing larger seeks. Therefore the allocation method directly impacts head movement, making option A the accurate statement. The other options misrepresent how indexed and linked allocations work.

Q10. Explain why C‑LOOK can achieve lower average seek time than SCAN in a system where requests are clustered near the outer cylinders.

A.C‑LOOK eliminates unnecessary travel to the innermost cylinder ✅
B.C‑LOOK always services the farthest request first
C.SCAN skips outer cylinders
D.Both have identical travel
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: C‑LOOK only moves as far as the highest pending request before jumping back to the lowest, avoiding the extra sweep to the extreme inner cylinder that SCAN performs regardless of request distribution. When most requests lie near the outer edge, this saved travel reduces the average seek time. Options B, C, and D describe behaviors that are not true for C‑LOOK, so A is correct.

Q11. What is the primary reason that heavy disk load can cause starvation in SSTF?

A.SSTF always selects the nearest request, causing far requests to wait ✅
B.SSTF skips requests randomly
C.SSTF moves head only outward
D.SSTF has fixed service order
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Under heavy load, many requests are constantly arriving near the current head position. SSTF's rule of picking the closest request means those nearby requests keep getting serviced, while those farther away may never become the nearest, leading to starvation. The other options describe mechanisms not used by SSTF, so option A correctly identifies the cause.

Q12. In a stable‑storage implementation, why must write‑ahead logging be coordinated with disk‑scheduling algorithms?

A.To ensure that log records are written before the corresponding data blocks, preserving consistency even if the head moves ✅
B.To allow logs to be written after data
C.Because scheduling algorithms ignore logs
D.Logs are unrelated to storage stability
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Write‑ahead logging requires that the log entry reach stable storage before the actual data modification is flushed. Disk‑scheduling decisions affect the order and timing of these writes; if a data block were written before its log, a crash could leave the system inconsistent. Coordinating the scheduler ensures logs are prioritized appropriately. The other statements either reverse the correct order or claim no relationship, which is inaccurate.

Q13. What does the acronym SSTF stand for in disk scheduling?

A.Shortest Seek Time First ✅
B.Sequential Scan Transfer Function
C.Simple Seek Transfer Format
D.Systematic Service Timing Factor
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: SSTF is commonly defined as Shortest Seek Time First, describing the algorithm that selects the pending request requiring the smallest head movement. The other options are fabricated expansions that do not match the accepted meaning, making option A the correct definition.

Q14. Which disk‑scheduling algorithm moves the head only in one direction and then jumps back to the beginning without servicing requests on the return?

A.SCAN
B.C‑LOOK ✅
C.FCFS
D.SSTF
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: C‑LOOK operates by moving the head in a single direction, servicing all pending requests, and then quickly returning to the lowest pending request without servicing any cylinders on the return trip. This behavior matches the description. SCAN also moves in one direction but services requests on the way back, while FCFS and SSTF do not perform a jump‑back operation. Hence option B is correct.

🔗 Related Topics (MCQs)