Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 1.29 KB

File metadata and controls

24 lines (20 loc) · 1.29 KB

DiskVirtualization

Considered 2 arrays A and B as 2 disks of size 200 and 300 blocks each. But the user gets a view of single disk of size 500 blocks.

Designed the followind APIs:

  1. CreateDisk(Id, num_blocks)

to create a smaller disk of size num_blocks with a unique Id within a larger available disk of 500 blocks.

  1. DeleteDisk(Id)

to delete a disk of given id. This would create a hole in larger disk, leading to fragmentation. Fragmentation has been handled using merging and splitting of blocks.

  1. readFromDisk(Id, block_no)

read from a disk Id and its block block_no.

  1. writeToDisk(Id, block_no, block_info)

write to disk Id on block block_no and content is block_info.

  1. createCheckpoint(Id)

to save the current state of disk Id and return a state number. This disk can be later rolled back to the current state using the returned state number.

  1. RollBack(Id, state)

to roll back Id to state.

Added replication feature to provide reliability. New APIs introduced:

  1. write_with_replicate(Id, block_no, block_info)

to write on the disk Id and also create a copy in the backup disk.

  1. read_with_replicate(Id, block_no)

to read from main disk but if block is corrupted, read from backup and create one more copy in backup