Build a Reference-Counted Deduplicating Block Store

Last updated: November 29, 2026

Quick Overview

Implement a block store that maps (volume, LBA) to physical blocks, stores identical block contents only once, and frees a physical block when its last reference is overwritten or deleted. Support write, read, delete and a stats call returning logical and physical block counts.

Netapp
Coding & Algorithms
Software Engineer
Netapp
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Implement a block store that maps (volume, LBA) to physical blocks, stores identical block contents only once, and frees a physical block when its last reference is overwritten or deleted. Support write, read, delete and a stats call returning logical and physical block counts.

Inline deduplication is a core ONTAP storage-efficiency feature on AFF systems, so engineers on the efficiency and WAFL teams reason about fingerprints and shared block references daily. The interviewer looks for correct reference counting under overwrites, protection against fingerprint collisions, and awareness of the ordering bug when a block is overwritten with its own contents.

What the Interviewer Expects
  • Uses a fingerprint index to find candidate duplicates and verifies bytes before sharing
  • Keeps a refcount per physical block and frees it at zero, removing it from the index
  • Increments the new reference before releasing the old one so same-data overwrites are safe
  • Keeps write and delete O(1) expected apart from hashing
  • Discusses where the fingerprint index lives and what happens when it does not fit in memory
Key Topics to Cover
Deduplication
Content fingerprinting
Reference counting
Hash collisions
Storage efficiency
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Your fingerprint table no longer fits in RAM. What do you do, and what dedup ratio do you give up?
  • How do snapshots interact with refcounts here, and why might a real system avoid per-block refcounts entirely?
  • How would you make the store crash consistent if the process can die between updating the map and the refcount?
  • When would you choose post-process deduplication over inline?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Operations: write(vol, lba, data), read(vol, lba), delete(vol, lba), stats(). Identical contents across any volume share one physical block. A physical block is reclaimed exactly when nothing ...

High-Level Design

Three maps: lba_map from (vol, lba) to physical id; blocks from physical id to [data, refcount, fingerprint]; by_fp from fingerprint to a small list of physical ids (a collision chain). On write...


Submit Your Answer
Markdown supported

Related Questions