Commit Graph

1829 Commits

Author SHA1 Message Date
Zach Brown
463f5e5a07 Correctly store last random word
pseudo_random_bytes() was accidentally copying the last partial long to
the beggining of the buffer instead of the end.  The final partial long
bytes weren't being filled.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-23 15:16:58 -07:00
Zach Brown
d0429e1c88 Add minimal bloom filter helpers
mkfs just needs to initialize bloom filter blocks with the bits for the
single root inode key.  We can get away with these skeletal functions
for now.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-23 14:01:16 -07:00
Zach Brown
8471134328 Add trivial set_bit_le in bitops.h
We're going to need to start setting bloom filters bits in mkfs so we'll
add this trivial inline.  It might grow later.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-23 14:00:07 -07:00
Zach Brown
f3de3b1817 Add DIV_ROUND_UP() to util.h
We're going to need this in some upcoming format.h changes.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-23 13:58:59 -07:00
Zach Brown
12d5d3d216 scoutfs: add next item reading
Add code to walk all the block segments that intersect a key range to
find the next item after that key value.

It is easier to just return failure from the next item reader and have
the caller retry the searches so we change the specific item reading
path to use the same convention to keep the caller consistent.

This still warns as it falls off the last block but that's fine for now.
We're going to be changing all this in the next few commits.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-18 17:30:39 -07:00
Zach Brown
af492a9f27 scoutfs: add scoutfs_inc_key()
Add a quick inline function for incrementing a key value across the
inode>type>offset sorted key space.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-18 17:24:12 -07:00
Zach Brown
96b8a6da46 scoutfs: update created inode times in mknod
In mknod the newly created inode's times are set down in the new inode
creation path instead of up in the mknod path to match the parent dir's
ctime and mtime.

This is strictly legal but it's easier to test that all the times have
been set in the mknod by having them equal.  This stops mkdir-interface
test failures when enough time passes between inode creation and parent
dir timestamp updates to have them differ.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-18 17:21:12 -07:00
Zach Brown
0c0f2b19d5 scoutfs: update dirty inode items
Wire up the code to update dirty inode items as inodes are modified in
memory.  We had a bit of the code but it wasn't being called.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-17 19:12:49 -07:00
Zach Brown
edf3c8a5d4 scoutfs: add initial item block writing
Add a sync_fs method that writes dirty items into level 0 item blocks.

Add chunk allocator code to allocate new item blocks in free chunks.  As
the allocator bitmap is modified it adds bitmap entries to the ring.

As new item blocks are allocated we create manifest entries that
describe their block location and keys.  The entry is added to the
in-memory manifest and to entries in the ring.

This isn't complete and there's still bugs but this is enough to start
building on.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-17 17:47:32 -07:00
Zach Brown
a0a3ef9675 Mark all mkfs chunks allocated in bitmap
The initial bitmap entry written in the ring by mkfs was off by one.
Three chunks were written but the 0th chunk is also free for the supers.
It has to mark the first four chunks as allocated.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-17 17:05:24 -07:00
Zach Brown
e59d0af199 Print full map and ring blocks
In the first pass we'd only printed the first map and ring blocks.

This reads the number of used map blocks into an allocation large enough
for the maximum number of map blocks.

Then we use the block numbers from the map blocks to print the active
ring blocks which are described by the super.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-17 17:05:19 -07:00
Zach Brown
d2ead58ce4 scoutfs: translate d_type in readdir
I had forgotten to translate from the scoutfs types in items to the vfs
types for filldir() so userspace was seeing garbage d_type values.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-16 14:04:20 -07:00
Zach Brown
c46fb0be78 scoutfs: fix sense of filldir return in readdir
The migration from the new iterator interface in upstream to the old
readdir interface in rhel7 got the sense of the filldir return code
wrong.  Any readdir would deadlock livelock as the dot entry was
returned at offset 0 without advancing f_pos.

Signed-off-by: Zach Brown <zab@versity.com>
2016-03-14 19:26:47 -07:00
Zach Brown
4b182c7759 scoutfs: insert manifest nodes into blkno radix
We had forgotten to actually insert manifest nodes in to the blkno
radix.  This hasn't mattered yet because there's only been one manifest
in the level 0 list.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-29 18:21:54 -08:00
Zach Brown
16abddb46a scoutfs: add basic segment reading
Add the most basic ability to read items from log segment blocks.  If
an item isn't in the cache then we walk segments in the manifest and
check for the item in each one.

This is just the core fundamental code.  There's still a lot to do:
basic corruption validation, multi-block segments, bloom filters and
arrays to optimize segment misses, and some day the ability to read file
data items directly into page cache pages.  The manifest locking is also
super broken.

But this is enough to let us mount and stat the root inode!

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-28 17:45:44 -08:00
Zach Brown
8604c85486 scoutfs: add basic reing replay on mount
Read the ring described by the super block and replay its entries to
rebuild the in-memory state of the chunk allocator and log segment
manifest.

We add just enough of the chunk allocator to set the free bits to the
contents of the ring bitmap entries.

We start to build out the basic manifest data structure.  It'll
certainly evolve when we later add code to actually query it.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-26 17:00:19 -08:00
Zach Brown
d8f76cb893 Minor ring manifest format updates
Update to the format changes that were made while implementing ring
replay in the kernel.
2016-02-25 22:45:06 -08:00
Zach Brown
906c0186bc Get path size with stat or ioctl
If we're making a file system in a real device then we need to get
the device size with an ioctl.
2016-02-25 22:40:48 -08:00
Zach Brown
28521e8c45 scoutfs: add block read helper
Add a trivial helper function which verifies the block header in
metadata blocks.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-23 21:13:56 -08:00
Zach Brown
71df879f07 scoutfs: update format.h to remove bricks
Update to the format.h from the recent -utils changes that moved from
the clumsy 'brick' terminology to the more reasonable
'block/chunk/segment' terminology.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-23 19:39:02 -08:00
Zach Brown
6686ca191a scoutfs: remove the prototype log writing
The sync implementation was a quick demonstration of packing items in to
large log blocks.  We'll be doing things very differently in the actual
system.  So tear this code out so we can build up more functional
structures.  It'll still be in revision control so we'll be able
to reuse the parts that make sense in the new code.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-23 19:33:56 -08:00
Zach Brown
e9baa4559b Introduce chunk and segment terminology
The use of 'log' for all the large sizes was pretty confusing.  Let's
use 'chunk' to describe the large alloc size.  Other things live in them
as well as logs.  Then use 'log segment' to describe the larger log
structure stored in a chunk that's made up of all the little blocks.
2016-02-23 17:04:28 -08:00
Zach Brown
de1bf39614 Get rid of bricks
Get rid of the explicit distinction between brick and block numbers.
The format is now defined it terms of fixed 4k blocks.  Logs become a
logical structure that's made up of a fixed number of blocks.  The
allocator still manages large log sized regions.
2016-02-19 15:40:04 -08:00
Zach Brown
a7b8f955fe write ring brick as brick in mkfs
The only ring brick was being written as a full block which made its
brick checksum cover the entire block instead of just the brick.
2016-02-19 08:53:14 -08:00
Zach Brown
3483133cdf Read super brick instead of mkfs
Now that we have a working userspace mkfs we can read the supers on
mount instead of always initializing a new file system.  We still don't
know how to read items from blocks so mount fails when it can't find the
root dir inode.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-12 19:37:48 -08:00
Zach Brown
82ec91d1e0 Update format to recent utils changes
The format was updated while implementing mkfs and print in
scoutfs-utils.  Bring the kernel code up to speed.

For some reason I changed the name of the item length in the item header
struct.  Who knows.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-12 19:32:53 -08:00
Zach Brown
eb4694e401 Add simple message printing
Add a message printing function whose output includes the device and
major:minor and which handles the kernel level string prefix.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-12 19:28:03 -08:00
Zach Brown
2c2f090168 Initial commit
This initial commit has enough to make a new file system and print out
it's structures.

Signed-off-by: Zach Brown <zab@versity.com>
2016-02-12 15:58:41 -08:00
Zach Brown
25a1e8d1b7 Initial commit
This is the initial commit of the repo that will track development
against distro kernels.

This is an import of a prototype branch in the upstream kernel that only
had a few initial commits.  It needed to move to the old readdir
interface and use find_or_create_page() instead of pagecache_get_page()
to build in older distro kernels.
2016-02-05 14:12:14 -08:00