Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

storage/block_device: initial implementation#359

Closed
cgonyeo wants to merge 1 commit intocoreos:masterfrom
cgonyeo:master
Closed

storage/block_device: initial implementation#359
cgonyeo wants to merge 1 commit intocoreos:masterfrom
cgonyeo:master

Conversation

@cgonyeo
Copy link

@cgonyeo cgonyeo commented Oct 20, 2016

This commit adds support for using a block device as the backing storage for
torusd.

Two utilities have been added, mkfs.torus and fsck.torus, to format a block
device for use by torus, and for checking the consistency of a formatted block
device, respectively.

There is a metadata section of size 512 bytes written to the beginning of the
disk, and the rest of the disk is used to store data.

Each location on the disk in which data can be stored has two things: block
headers of size 512 bytes, and the actual data, whose size is determined by the
torus cluster's block size.

When given a block ref, the location of the data is determined by feeding 24
bits comprised of the block ref's volume, inode, and index through sha256,
converting the last 8 bytes into a uint64.

The block headers are simply a series of 32 bit chunks, containing the three
fields from a block ref and a location field. The location field will either be
0, signifying the data for this block ref is at this location, or a non-zero
integer, which is the location of a different set of block headers to go to.

When writing a block, if the default location is used for a preexisting block
(so, a hash collision), linear probing is then used to find the next free
location to use.

Fixes #171.

@cgonyeo cgonyeo force-pushed the master branch 4 times, most recently from 45ef9f7 to dba52a8 Compare October 25, 2016 14:22
@cgonyeo
Copy link
Author

cgonyeo commented Oct 25, 2016

This is no longer a WIP, I'm happy with the current state of the tests and they all pass. Unfortunately it looks like travis ci doesn't support loopback devices, so my tests don't succeed when run there. Anyone have any ideas on that one? Maybe just disable my tests in CI for now?

@cgonyeo cgonyeo force-pushed the master branch 2 times, most recently from 9a0f1f6 to c58a4d0 Compare October 31, 2016 20:48
@cgonyeo
Copy link
Author

cgonyeo commented Oct 31, 2016

I've updated my added tests to require the integration build tag to run, to prevent them from failing in travis ci.

@cgonyeo
Copy link
Author

cgonyeo commented Dec 5, 2016

Review bump

@lpabon
Copy link

lpabon commented Dec 9, 2016

@dgonyeo I'll review, plus... THANKS FOR THE UNIT TESTS!! Finally!

@lpabon
Copy link

lpabon commented Dec 9, 2016

@dgonyeo Quick question before I start the review. It says on your comment:

There is a metadata section of size 512 bytes written to the beginning of the
disk, and the rest of the disk is used to store data.

This would create a very unaligned disk chunk because everything would be off by 512 bytes. You want to store metadata on the first chunk, not LBA. For example, a 4k write to LBA 0 from the caller, would not be aligned to the chunk if the is 4k in size. If the chunk is 512k in size and the caller write the last 4k in that chunk, 4k-512 bytes would go into this chunk, and 512 bytes would go into the next.

@cgonyeo
Copy link
Author

cgonyeo commented Dec 10, 2016

Seems to me like the easiest fix would be to make that starting section 4k then, right? I'll tweak this PR to do that.

This commit adds support for using a block device as the backing storage for
torusd.

Two utilities have been added, mkfs.torus and fsck.torus, to format a block
device for use by torus, and for checking the consistency of a formatted block
device, respectively.

There is a metadata section of size 4k bytes written to the beginning of the
disk, and the rest of the disk is used to store data.

Each location on the disk in which data can be stored has two things: block
headers of size 4k bytes, and the actual data, whose size is determined by the
torus cluster's block size.

When given a block ref, the location of the data is determined by feeding 24
bits comprised of the block ref's volume, inode, and index through sha256,
converting the last 8 bytes into a uint64, and modding that by the number of
slots available to store data in. By going to this location and reading the
block headers, one can then determine if the data does live at this location on
disk or get the real location of the data.

The block headers are simply a series of 32 bit chunks, containing the three
fields from a block ref and a location field. The location field will either be
0, signifying the data for this block ref is at this location, or a non-zero
integer, which is the location of a different set of block headers to go to.

When writing a block, if the default location is used for a preexisting block
(so, a hash collision), linear probing is then used to find the next free
location to use.
@cgonyeo
Copy link
Author

cgonyeo commented Jun 11, 2018

Cleaning up my old PRs

@cgonyeo cgonyeo closed this Jun 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants