Commit Graph
1784 Commits
Author SHA1 Message Date
Zach Brown 54d286d91c scoutfs: format strings for all key types
Add all the missing key types to scoutfs_key_str() so that we can get
traces and printks of all key types.

Signed-off-by: Zach Brown <zab@versity.com>
2017-06-06 15:01:37 -07:00
Zach Brown 1485b02554 scoutfs: add SK_ helpers for printing keys
Add some percpu string buffers so that we can pass formatted strings as
arguments when printing keys.  The percpu struct uses a different buffer
for each argument.  We wrap the whole print call in a wrapper that
disables and enables preemption.

Signed-off-by: Zach Brown <zab@versity.com>
2017-06-06 14:48:09 -07:00
Zach Brown a050152254 scoutfs: fix ring next/prev walk comparison test
The scoutfs_ring_next() and _prev() functions had a really dumb bug
where they check the sign of comparisons by comparing with 1.  For
example, next would miss that the walk traversed a lesser item
and wouldn't return the next item.

This was causing compaction to miss underlying segments, creating
segments in levels that had overlapping keys, which then totally
confused reading and kept it from finding the items it was looking for.

Signed-off-by: Zach Brown <zab@versity.com>
2017-06-06 14:32:29 -07:00
Zach Brown 79de18443b scoutfs: don't extend key in dec_cur_len
A copy and paste bug had us extending the length of keys that were
decremented at their previous length.  The whole point of the _cur_len
functions is that they don't have to extend the key buf out to full
precision.

Signed-off-by: Zach Brown <zab@versity.com>
2017-06-06 14:30:43 -07:00
Zach Brown 2bd698b604 scoutfs: set NODELAY and REUSEADDR on net sockets
Add a helper that creates a socket and sets nodelay for all sockets and
set reuseaddr in listening sockets.

Signed-off-by: Zach Brown <zab@versity.com>
2017-06-06 14:29:05 -07:00
Zach Brown c84250b8c6 scoutfs: add item_set_batch trace point
Restore the item_set_batch trace point by changing the current
insert_batch tracepoint to a class and defining insert and set as class
trace points.

Signed-off-by: Zach Brown <zab@versity.com>
2017-06-02 09:20:02 -07:00
Zach Brown a2ef5ecb33 scoutfs: remove item_forget
It's pretty dangerous to forcefully remove items without writing
deletion items to lsm segments.  This was only used for magical
ephemeral items when we were having them store file data.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-23 12:59:24 -07:00
Zach Brown 1f933016f0 scoutfs: remove ephemeral items
Ephemeral items were only used by the page cache which tracked page
contents in items whose values pointed to the pages.  Remove their
special case.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-23 12:58:09 -07:00
Zach Brown 228c5d8b4b scoutfs-utils: support meta and data seqs
Signed-off-by: Zach Brown <zab@versity.com>
2017-05-23 12:17:52 -07:00
Zach Brown 08aaa5b430 scoutfs-utils: add stat command
The scoutfs stat command is modeled after stat(1) and uses the STAT_MORE
ioctl.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-23 12:17:50 -07:00
Zach Brown b7bbad1fba scoutfs: add precise transation item reservations
We had a simple mechanism for ensuring that transaction didn't create
more items than would fit in a single written segment.  We calculated
the most dirty items that a holder could generate and assumed that all
holders dirtied that much.

This had two big problems.

The first was that it wasn't accounting for nested holds.
write_begin/end calls the generic inode dirtying path whild holding a
transaction.  This ended up deadlocking as the dirty inode waited to be
able to write while its trans held back in write_begin prevented
writeout.

The second was that the worst case (full size xattr) item dirtying is
enormous and meaningfully restricts concurrent transaction holders.
With no currently dirty items you can have less than 16 full size xattr
writes.  This concurrency limit only gets worse as the transaction fills
up with dirty items.

This fixes those problems.  It adds precise accounting of the dirty
items that can be created while a transaction is held.  These
reservations are tracked in journal_info so that they can be used by
nested holds.  The precision allows much greater concurrency as
something like a create will try to reserve a few hundreds bytes instead
of 64k.  Normal sized xattr operations won't try to reserve the largest
possible space.

We add some feedback from the item cache to the transaction to issue
warnings if a holder dirties more items than it reserved.

Now that we have precise item/key/value counts (segment space
consumption is a function of all three :/) we can't have a single atomic
track transaction holders.  We add a long-overdue trans_info and put a
proper lock and fields there and much more clearly track transaction
serialization amongst the holders and writer.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-23 12:15:13 -07:00
Zach Brown 297b859577 scoutfs: deletion items maintain counts
When we turned existing items into deletion items we'd remove their
values.  But we didn't update the count of dirty values to reflect that
removal so the dirty value count would slowly grow without bound.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-23 12:12:30 -07:00
Zach Brown 5f11cdbfe5 scoutfs: add and index inode meta and data seqs
For each transaction we send a message to to the server asking for a
unique sequence number to associate with the transaction.  When we
change metadata or data of an inode we store the current transaction seq
in the inode and we index it with index items like the other inode
fields.

The server remembers the sequences it gives out.  When we go to walk the
inode sequence indexes we ask the server for the largest stable seq and
limit results to that seq.  This ensures that we never return seqs that
are past dirty items so never have inodes and seqs appear in the past.

Nodes use the sync timer to regularly cycle through seqs and ensure that
inode seq index walks don't get stuck on their otherwise idle seq.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-23 12:12:24 -07:00
Zach Brown b291818448 scoutfs: add sync deadline timer
Make sure that data is regularly synced.  We switch to a delayed work
struct that is always queued with the sync deadline.  If we need an
immediate sync we mod it to now.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-19 11:19:56 -07:00
Zach Brown 373def02f0 scoutfs: remove trade_time message
This was mostly just a demonstration for how to add messages.  We're
about to add a message that we always send on mount so this becomes
completely redundant.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-18 10:52:04 -07:00
Zach Brown 8ea414ac68 scoutfs: clear seg rb node after replacing
When inserting a newly allocated segment we might find an existing
cached stale segment.  We replace it in the cache so that its user can
keep using its stale contents while we work on the new segment.

Replacing doesn't clear the rb_node, though, so we trip over a warning
when we finally free the segment and it looks like it's still present in
the rb tree.

Clear the node after we replace it so that freeing sees a clear node and
doesn't issue a warning.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 14:51:36 -07:00
Zach Brown 5307c56954 scoutfs: add a stat_more ioctl
We have inode fields that we want to return to userspace with very low
overhead.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 14:28:10 -07:00
Zach Brown 9fc99a8c31 scoutfs-utils: add support for inode index items
Add support for the inode index items which are replacing the seq walks
from the old btree structures.  We create the index items for the root
inode, can print out the items, and add a commmand to walk the indices.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 11:14:10 -07:00
Zach Brown 9c00602051 scoutfs-utils: print extent flags
Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 11:14:10 -07:00
Zach Brown a9cb464d49 scoutfs-utils: rename __bitwise
Recent kernel headers have leaked __bitwise into userspace.  Rename our
use of __bitwise in userspace sparse builds to avoid the collision.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 11:14:10 -07:00
Zach Brown 4585d57153 scoutfs-utils: only print recent super
It's a bit confusing to always see both the old and current super block.
Let's only print the first one.  We could add an argument to print all
of them.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 11:13:59 -07:00
Zach Brown 1c9a407059 scoutfs-utils: print extent items
Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 11:13:47 -07:00
Zach Brown b97587b8fa scoutfs: add indexing of inodes by fields
Add items for indexing inodes by their fields.  When we update the inode
item we also delete the old index items and create the new items.  We
rename and refactor the old inode since ioctl to now walk the inode
index items.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:12 -07:00
Zach Brown 4084d3d9dc scoutfs: add offline flag, releasing, and fiemap
Now that we have basic file extents we can add a flag to extents to
track offline extents.  We have to initialize and test the flags as we
work with extents.  Truncation can be told to leave removed extents
around with no block mapping and the offline bit set.  Only staging with
the correct data version can write to the offline regions.  Demand
staging isn't implemented yet.  Reads from offline extents are treated
like sparse regions.

Truncation is a straight forward iteration over the portions of existing
extents which overlap with the truncated blocks.

Writing to offline extents has to first remove the existing offline
extent before then adding the new allocated extents.  The 'changes'
mechanism relied on being able to search the current items to find the
changes that should be made before making any changes.  This doesn't
work for finding merge candidates for the new allocated insertion
because the old offline extent change won't have been applied yet.  We
replace the change mechanism with straight forward item modification and
unwinding.

The generic block fiemap can't communicate offline extents and iterates
over blocks instead of extents.  We add our fiemap that iterates
over extents and sets the 'UNKNOWN' flag on offline extents.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:12 -07:00
Zach Brown e34f8db4a9 scoutfs: add release argument and result tracing
Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:12 -07:00
Zach Brown a262a158ce scoutfs: fix single block release
The offset comparison in release that was meant to catch wrapping was
inverted and accidentally prevented releasing a single block.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:12 -07:00
Zach Brown 81866620a9 scoutfs: allow xattrs with 0 length values
xattrs can have 0 lenth values so fix the item iterator to emit a single
item in the case where the size is 0.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:12 -07:00
Zach Brown c678923401 scoutfs: don't try to sync on mount errors
kill_sb tries to sync before calling kill_block_super.   It shouldn't do
this on mount errors that wouldn't have initialized the higher level
systems needed for syncing.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:12 -07:00
Zach Brown 66dd35b9a5 scoutfs: fix ring next/prev
The ring node rb walker was returning an exact match for the search key
instead of the last node that was traversed.  This stopped callers from
then iterating from the traversed node to find the next or previous
node.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:11 -07:00
Zach Brown 723e0368f8 scoutfs: add a trace point for item insertion
Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:11 -07:00
Zach Brown 6afeb97802 scoutfs: reference file data with extent items
Our first attempt at storing file data put them in items.  This was easy
to implement but won't be acceptable in the long term.  The cost of the
power of LSM indexing is compaction overhead.  That's acceptable for
fine grained metadata but is totally unacceptable for bulk file data.

This switches to storing file data in seperate block allocations which
are referenced by extent items.

The bulk of the change is the mechanics of working with extents.  We
have high level callers which add or remove logical extents and then
underlying mechanisms that insert, merge, or split the items that
the extents are stored in.

We have three types of extent items.  The primary type maps logical file
regions to physical block extents.  The next two store free extents
per-node so that clients don't create lock and LSM contention as they
try and allocate extents.

To fill those per-node free extents we add messages that communcate free
extents in the form of lists of segment allocations from the server.

We don't do any fancy multi-block allocation yet.  We only allocate
blocks in get_blocks as writes find unmapped blocks.  We do use some
per-task cursors to cache block allocation positions so that these
single block allocations are very likely to merge into larger extents as
tasks stream wites.

This is just the first chunk of the extent work that's coming.  A later
patch adds offline flags and fixes up the change nonsense that seemed
like a good idea here.

The final moving part is that we initiate writeback on all newly
allocated extents before we commit the metadata that references the new
blocks.  We do this with our own dirty inode tracking because the high
level vfs methods are unusably slow in some upstream kernels (they walk
all inodes, not just dirty inodes.)

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:48:11 -07:00
Zach Brown 6719733ddc scoutfs: output full dirent name when tracing
The dirent name formatting code accidentally copied the calculation for
the length of the name from the xattrs, which are null terminated.  The
durents are not, their length is just the value length minus the dirent
header.

Signed-off-by: Zach Brown <zab@versity.com>
2017-05-16 10:29:59 -07:00
Zach Brown d5a2b0a6db Move towards compaction messages
The compaction code is still directly referencing the super block
and calling sync methods as though it was still standalone.  This is
mostly OK because only the server runs it.  But it isn't quite right
because the sync methods no longer make the rings persistent as they
write the item transaction.  The server is in control of that now.

Eventually we'll have compaction messages being sent between the mount
clients and the server.  Let's take a step in that direction by having
the compaction work call net methods to get its compaction parameters
and finish the compaction.  Eventually these would be marshalled through
request/process/reply code.

But in this first step we know that the compaction code is running on
the server so we can forgo all the messaging and just call in to and out
of compaction.  The net calls just holds the ring consistency locks in
the server and call into the manifest to do the work, commiting the
changes when its done.

This is more careful about segno alloction and freeing.  Compaction
doesn't call the allocator directly.  It gets allocaitons from the
messages and returns them if it doesn't use them.  We actually now
free segnos as they're removed from the manifest.

With the server controlling compaction and can tear all the fiddly level
count watching code out of the manifest.  Item transactions can't care
about the level counts and the server always tries compaction after the
manifest is updated intead of having the manifest watch the level counts
and call compaction.

Now that the server owns the rings they should not be torn down as the
super is torn down, net does that now.  And we need to be more careful
to be sure that writes from dirtying and compaction are stable before
killing the super.

With all this in place moving to shared compaction involves adding the
messages and negotiating concurrent compactions in the manifest.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-24 14:02:18 -07:00
Zach Brown e09a216762 Support simpler ring entries
Add mkfs and print support for the simpler rings that the segment bitmap
allocator and manifest are now using.  Some other recent format header
updates come along for the ride.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown bd54995599 Add a simple native bitmap
Nothing fancy at all.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown f86ce74ffd Add BITS_PER_LONG define
Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown a147239022 Remove dead block, btree, and buddy code
Remove the last bits of the dead code from the old btree design.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 2e2ee3b2f1 Print symlink items
Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 77d0268cb2 Add printing xattrs
For now we only print the xattr names, not the values.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 13b2d9bb88 Remove find_xattr commands
We're no longer maintaining xattr backrefs.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 02993a2dd7 Update ino_path for the large cursor
Previously we could iterate over backref items with a small u64.  Now we
need a larger opaque buffer.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 16da3c182a Add printing link backref items
Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown acda5a3bf1 Add support for free_segs in super
The allocator records the total number of free segments in the super
block.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 44f8551fb6 Print data items
Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 52291b2c75 Update format for readdir_pos
We now track each parent dir's next readdir pos and the readdir pos of
each dirent.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 38c8a4901f Print orphan items
Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown c4f2563cc1 Update tools to new segment item layout
The segment item struct used to have fiddly packed offsets and lengths.
Now it's just normal fields so we can work with them directly and get
rid of the native item indirection.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown e81c256a22 Remove the bitops helpers
We don't have any use for the bitops today, we'll resurrect this in
simpler form if it's needed again.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 34c62824e5 Use a treap walker to print segments
We were using a bitmap to record segments during manifest printing and
then walking that bitmap to print segments.  It's a little silly to have
a second data structure record the referenced segments when we could
just walk the manifest again to print the segments.

So refactor node printing into a treap walker that calls a function for
each node.  Then we can have functions that print the node data
structurs for each treap and then one that prints the segments that are
referenced by manifest nodes.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00
Zach Brown 26a4266964 Set manifest keys to precise segment keys
We had changed the manifest keys to fully cover the space around the
segments in the hopes that it'd let item reading easily find negative
cached regions around items.

But that makes compaction think that segments intersect with items when
they really don't.  We'd much rather avoid unnecessary compaction by
having the manifest entries precisely reflect the keys in the segment.

Item reading can do more work at run time to find the bounds of the key
space that are around the edges of the segments it works with.

Signed-off-by: Zach Brown <zab@versity.com>
2017-04-18 14:20:43 -07:00