Skip to content

arwin-swapna/raid-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

💾 RAID Sector Mapping Tool (C)

A high-performance command-line program that computes how logical sectors in a RAID array map to the physical disks and stripes that store them.

This project focuses on storage systems, RAID architectures, and efficient large-scale computation.


📌 Overview

RAID arrays distribute and replicate data across multiple disks to improve performance, fault tolerance, or both.

This tool takes a RAID configuration and answers millions of queries of the form:

“Where is logical sector X stored in the RAID array?”

For redundancy and parity-based RAID levels, the program also reports the mirror disk or parity disk affected.

The program reads from stdin and writes results to stdout, making it suitable for piping and batch processing.


🧠 Supported RAID Levels

RAID Level Description
RAID 0 Striping (performance)
RAID 1 Mirroring (redundancy)
RAID 01 Mirror of stripes
RAID 10 Stripe of mirrors
RAID 4 Block striping with dedicated parity
RAID 5 Block striping with distributed parity

⚙️ Input Format

The first line contains five values:

T N C S Q
Symbol Meaning
T RAID level (0, 1, 01, 10, 4, 5)
N Number of disks
C Chunk size (in sectors)
S Sectors per disk
Q Number of queries

The next Q lines contain sector numbers to query.

Example:

5 4 1 1000 3
12
25
90

📤 Output Format

For each queried sector, the program prints:

<disk> <stripe> [mirror/parity disk]

Meaning

  1. disk → disk storing the sector
  2. stripe → stripe index on that disk
  3. Additional value depending on RAID level:
RAID Third Value
RAID 1 / 01 / 10 Disk containing mirrored copy
RAID 4 / 5 Disk containing affected parity
RAID 0 Not printed

🧩 Constraints & Scale

The program is designed for very large inputs:

  • Disks: 2 → 16
  • Sectors per disk: billions
  • Queries: millions

Efficiency requirements:

  • O(1) computation per query
  • Minimal memory usage
  • Streaming I/O friendly

🏗️ Project Structure

.
├── makefile
├── raid.c
└── README.md

🔨 Build Instructions

Requirements

  • Linux environment
  • GCC

Compile

make

▶️ Run

make run

🧪 Example

Input:

0 3 2 10 2
5
12

Output:

1 2
0 4

📚 Concepts Demonstrated

  • RAID data layout algorithms
  • Large-scale numeric computation
  • Streaming input/output
  • Constant-time mapping logic
  • Storage system fundamentals

📝 License

This repository is for educational and learning purposes.

About

This project involves implementing a program that maps the location of sectors in a RAID device into the sectors of the hard disks that compose it. The program reads input from the standard input and prints the result to the standard output.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors