Everyone:

Next week, we will discuss how to enforce consistency in filesystems and how to maintain data integrity.

TL;DR

For this reading assignment, you are to read about maintaining consistency and integrity in filesystems, and submit your responses to the Reading 13 Quiz.

Reading

The readings for this week are:

  1. Operating Systems: Three Easy Pieces

Optional

These readings may be covered in class, but you will not be quizzed on the following:

  1. ZFS 101—Understanding ZFS storage and performance

  2. The Google File System

  3. MapReduce

Quiz

Once you have done the readings, answer the following Reading 13 Quiz questions:

Program

For this week, you are to write a program that analyzes a stream of bytes that uses an even parity bit scheme to check for consistency within each block of data:

# Check byte stream for consistency (no errors)
$ printf '12345670' | ./program ; echo $?
0

# Check byte stream for consistency (1 error)
$ printf '12345671' | ./program ; echo $?
1

The byte stream is encoded in the following format:

Each Block of bytes consists of seven bytes followed by a parity byte, which is computed by XORing all the bytes together.

Your task is to read in a stream of Blocks and verify that the parity byte of each Block is consistent with the provided data within the Block. At the end of your program, return the number of inconsistent blocks as the status code.

Hints

  1. You can use the Block structure defined above.

  2. You can use fread to read in one Block at a time.

  3. To compute XOR, you can use ^.

Submission

To submit you work, follow the same process outlined in Reading 01:

$ git checkout master                 # Make sure we are in master branch
$ git pull --rebase                   # Make sure we are up-to-date with GitLab

$ git checkout -b reading13           # Create reading13 branch and check it out

$ cd reading13                        # Go into reading13 folder
$ $EDITOR answers.json                # Edit your answers.json file

$ ../.scripts/check.py                # Check reading13 quiz
Checking reading13 quiz ...
     Q01 0.45
     Q02 0.40
     Q03 0.20
     Q04 0.70
     Q05 0.55
     Q06 0.40
     Q07 0.30
   Score 3.00 / 3.00
  Status Success

$ git add answers.json                # Add answers.json to staging area
$ git commit -m "Reading 13: Quiz"    # Commit work

$ $EDITOR program.c                   # Edit your program.c file

$ make test-program                   # Check reading13 program
Checking reading13 program...
 disk1                                                        ... Success
 disk1 (inconsistent byte)                                    ... Success
 disk1 (inconsistent parity)                                  ... Success
 disk1 (swapped bytes)                                        ... Success
 disk2                                                        ... Success
 disk2 (inconsistent byte)                                    ... Success
 disk2 (inconsistent parity)                                  ... Success
 disk2 (swapped bytes)                                        ... Success
 disk3                                                        ... Success
 disk3 (inconsistent byte)                                    ... Success
 disk3 (inconsistent parity)                                  ... Success
 disk3 (swapped bytes)                                        ... Success
 disk4                                                        ... Success
 disk4 (inconsistent byte)                                    ... Success
 disk4 (inconsistent parity)                                  ... Success
 disk4 (swapped bytes)                                        ... Success
   Score 3.00 / 3.00
  Status Success

$ git add Makefile                    # Add Makefile to staging area
$ git add program.c                   # Add program.c to staging area
$ git commit -m "Reading 13: Code"    # Commit work

$ git push -u origin reading13        # Push branch to GitHub

Pull Request

Once you have committed your work and pushed it to GitHub, remember to create a pull request and assign it to the appropriate teaching assistant from the Reading 13 TA List.