Commit Graph
1784 Commits
Author SHA1 Message Date
Benjamin LaHaiseandZach Brown 492afae552 scoutfs: add data_wait_err for reporting errors
Add support for reporting errors to data waiters via a new
SCOUTFS_IOC_DATA_WAIT_ERR ioctl.  This allows waiters to return an error
to readers when staging fails.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
[zab: renamed to data_wait_err, took ino arg]
Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:35 -07:00
Zach BrownandZach Brown 8cf6f73744 scoutfs-tests: filter another ext4 kernel message
Add another expected warning from ext4 during xfstests that should not
cause failure.

Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:35 -07:00
Benjamin LaHaiseandZach Brown 74f85ff93d scoutfs: add data_wait_err for reporting errors
Add support for reporting errors to data waiters via a new
SCOUTFS_IOC_DATA_WAIT_ERR ioctl.  This allows waiters to return an error
to readers when staging fails.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
[zab: renamed to data_wait_err, took ino arg]
Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:25 -07:00
Zach BrownandZach Brown 79e235af6e scoutfs-utils: fix argv typo in error message
The data_waiting ioctl used the wrong argv index when printing the path
arg string that it failed to open.

Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:25 -07:00
Zach BrownandZach Brown 0a8faf3e94 scoutfs-utils: add parse_s64()
Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:25 -07:00
Benjamin LaHaiseandZach Brown f5863142be scoutfs: add data_wait_err for reporting errors
Add support for reporting errors to data waiters via a new
SCOUTFS_IOC_DATA_WAIT_ERR ioctl.  This allows waiters to return an error
to readers when staging fails.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
[zab: renamed to data_wait_err, took ino arg]
Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:13 -07:00
Zach BrownandZach Brown d16b18562d scoutfs: make sure forest sees dirty log tree
Item writes are first stored in dirty blocks in the private version of
the mount's log tree.  Local readers need to be sure to check the dirty
version of the mount's log tree to make sure that they see the result of
writes.  Usually trees are found by walking the log tree items stored in
another btree in the super.  The private dirty version of a mount's log
tree hasn't been committed yet and isn't visible in these items.

The forest uses its lock private data to track which lock has seen items
written and so should always check the local dirty log tree when
reading.  The intent was to use the per-lock static forest_root for the
log tree to record that it had been marked by a write and was then
always used for reads.

We used storing the forest info's rid and testing for a non-zero
forest_root rid as the mechanism for always testing the dirty log root
during read.  But we weren't setting the forest info rid as each
transaction opened.  It was always 0 so readers never added the dirty
log tree for reading.

The fix is to use the more reliable indication that the log root has
items for us by testing the flag that all the bits have been set.  Then
we're also sure to always set the rid/nr of the forest_info record of
our log tree, and the per-lock forest_root copy of it whenever we use
it.

This fixed spurious errors we were seeing as creates tried to read
the item they just wrote as memory reclaim freed locks.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-29 12:02:47 -07:00
Zach BrownandZach Brown e3b1f2e2b0 scoutfs: add counters for radix enospc
Add counters for the various sources of ENOSPC from the radix block
allocator.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-22 16:08:03 -07:00
Zach BrownandZach Brown 9ad86d4d29 scoutfs: commit trans before premature enospc
File data allocations come from radix allocators which are populated by
the server before each client transation.  It's possible to fully
consume the data allocator within one transaction if the number of dirty
metadata blocks is kept low.  This could result in premature ENOSPC.

This was happening to the archive-light-cycle test.  If the transactions
performed by previous tests lined up just right then the creation of the
initial test files could see ENOSPC and cause all sorts of nonsense in
the rest of the test, culminating in cmp commands stuck in offline
waits.

This introduces high and low data allocator water marks for
transactions.  The server tries to fill data allocators for each
transaction to the high water mark and the client forces the commit of a
transaction if its data allocator falls below the low water mark.

The archive-light-cycle test now passes easily and we see the
trans_commit_data_alloc_low counter increasing during the test.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-22 16:08:03 -07:00
Zach BrownandZach Brown 7da8ddb8a1 scoutfs: fix data.h include guard
The identifier for data.h's include guard was brought over from an old
file and still had the old name.  Update it to reflect it's use in data,
not filerw.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-22 16:08:03 -07:00
Zach BrownandZach Brown 495358996c scoutfs: fix older kc readdir emit
When we added the kernelcompat layer around the old and new readdir
interfaces there was some confusion in the old readdir interface filldir
arguments.  We were passing in our scoutfs dent item struct pointer
instead of the filldir callback buf pointer.  This prevented readdir
from working in older kernels because filldir would immediately see a
corrupt buf and return an error.

This renames the emit compat macro arguments to make them consistent
with the other calls and readdir now provides the correct pointer to the
emit wrapper.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-21 16:28:06 -07:00
Zach BrownandZach Brown d2a15ea506 scoutfs: fix depth-first radix next bit search
The radix block next bit search could return a spurious -ENOENT if it
ran out of references in a parent block further down the tree.  It needs
to bubble up to try the next ref in its parent so that it keeps
performing a depth-first search of the entire tree.

This lead to an assertion being tripped in _radix_merge.  Getting an
early -ENOENT caused it to start searching from 0 again.  When it's
iterating over a read-only input it could find the same leaf and try to
clear source bits that were already cleared.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-16 10:33:28 -07:00
Zach BrownandZach Brown 2c5e3aa551 scoutfs: trace radix merge input root and leaf bit
Add a bit more detail to the radix merge trace.  It was missing the
input block and leaf bit.  Also use abbreviations of the fields in the
trace output so that it's slightly less enormous.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-16 10:33:28 -07:00
Zach BrownandZach Brown 2478d124dd scoutfs: use random radix block ref seqs
The seq portion of radix block references is intended to differentiate
versions of a given block location over time.  The current method of
incrementing the existing value as the block is dirtied is risky.  It
means that every lineage of a block has the same sequence number
progression.  Different trees referencing the same block over time could
get confused.  It's more robust to have large random numbers.  The
collision window is then evenly distributed over the 64bit space rather
than being bunched up all in in the initial seq values.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-16 10:33:28 -07:00
Zach BrownandZach Brown 968e719a9a scoutfs: check for bad radix merge count
When we're merging bits that are set in a read-only input tree then we
can't try to merge more bits than exist in the input tree.  That'll
cause us to loop around and double-free bits.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-16 10:33:28 -07:00
Zach BrownandZach Brown 4c1f78afd4 scoutfs: use our own _le bitmap xor helper
We were using bitmap_xor() to set and clear blocks of allocator bits at
a time.  bitmap_xor() is a ternary function with two const input
pointers and we were providing the changing destination as a const input
pointer.  That doesn't seem wise.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-16 10:33:28 -07:00
Zach BrownandZach Brown 66f8b3814c scoutfs: remove warning on reading while staging
An incorrect warning condition was added as fallocate was implemented.
It tried to warn against trying to read from the staging ioctl.  But the
staging boolean is set on the inode when the staging ioctl has the inode
mutex.  It protects against writes, but page reading doesn't use the
mutex.  It's perfectly acceptable for reads to be attempted while the
staging ioctl is busy.  We rely on it for a large read to consume
staging being written.

The warning caused reads to fail while the stager ioctl was working.
Typically this would hit read-ahead and just force sync reads.  But it
could hit sync reads and cause EIO.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-10 12:02:18 -07:00
Zach BrownandZach Brown 192453e717 scoutfs: add server error messages
Add specific error messages for failures that can happen as the server
commits log trees from the client.  These are severe enough that we'd
like to know about them.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-10 12:02:18 -07:00
Zach BrownandZach Brown ae9e060fbf scoutfs: read and write supers as sm blocks
Back in ancient LSM times these functions to read and write the super
block reused the bio functions that LSM segment IO used.  Each IO would
be performed with privately allocated pages and bios.

When we got rid of the LSM code we got rid of the bio functions.  It was
quick and easy to transition super read/write to use buffer_heads.  This
introduced sharing of the super's buffer_head between readers and
writers.  First we saw concurrent readers being confused by the uptodate
bit and added a bunch of complexity to coordinate use of the uptodate
bit.

Now we're seeing the writer copy its super for writing into the buffer
that readers are using, causing crc failures on read.  Let's not use
buffer_heads anymore (always good advice).

We added quick block functions to read and write small blocks with
private pages and bios.  Use those here to read and write the super so
that readers and writers operate on their own buffers again.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-07 14:06:00 -07:00
Zach BrownandZach Brown 44ac668afa scoutfs: add small private block io read and write
Add two quick functions which perform IO on small fixed size 4K blocks
to or from the caller's buffer with privately allocated pages and bios.
Callers have no interaction with each other.  This matches the behaviour
expected by callers of scoutfs_read_super and _write_super.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-07 14:06:00 -07:00
Zach BrownandZach Brown 63cccfa582 scoutfs-tests: check setattr_more offline extent
We had a bug where we were creating extent lengths that were rounded up
to the size of the packed extent items instead of being limited by
i_size.  As it happens the last setattr_more test would have found it if
I'd actually done the math to check that the extent length was correct.
We add an explicit offline blocks count test because that's what lead us
to notice that the offline extent length was wrong.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-03 14:47:04 -07:00
Zach BrownandZach Brown 6ae0ac936c scoutfs: fix setattr offline extent length
We miscalculated the length of extents to create when initializing
offline extents for setattr_more.  We were clamping the extent length in
each packed extent item by the full size of the offline extent, ignoring
the iblock position that we were starting from.

Signed-off-by: Zach Brown <zab@versity.com>
2020-04-03 14:46:48 -07:00
Zach BrownandZach Brown 6228f7cde7 scoutfs: create offline extents after arg checks
With the introduction of packed extent items the setattr_more ioctl had
to be careful not to try and dirty all the extent items in one
transaction.  But it pulled the extent creation call up to high and was
doing it before some argument checks that were done after the inode was
refreshed by acquiring its lock.  This moves the extent creation to be
done after the args are verified for the inode.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-16 15:48:19 -07:00
Zach BrownandZach Brown 88422c6405 scoutfs: fiemap with no extents returns 0
Don't return -ENOENT from fiemap on a file with no extents.  The
operation is supposed to succeed with no extents.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-16 15:48:19 -07:00
Zach BrownandZach Brown ef1dc677d0 scoutfs: store initialied offline unpacked extents
The setattr_more ioctl has its own helper for creating uninitialized
extents when we know that there can't be any other existing extents.  We
don't have to worry about freeing blocks they might have referenced.
This helper forgot to actually store the modified extents back into
packed extent items after setting extents offline.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-16 15:48:19 -07:00
Zach BrownandZach Brown e44fb23064 scoutfs-tests: add setattr_more tests
We had a bug where offline extent creation during setattr_more just
wasn't making it all the way to persistent items.  This adds basic
sanity tests of the setattr_more interface.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-16 15:48:09 -07:00
Zach BrownandZach Brown 462749cb87 scoutfs: add stage and release tracing
Add a bit more tracing to stage, release, and unwritten extent
conversion so we can get a bit more visibility into the threads staging
and releasing.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:02:06 -08:00
Zach BrownandZach Brown ac3466921a scoutfs: invalidate stale bloom blocks
We need to invalidate old stale blocks we encounter when reading old
bloom block references written by other nodes.  This is the same
consistency mechanism used by btree blocks.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:02:06 -08:00
Zach BrownandZach Brown 65724c6724 scoutfs: forest comment update
A quick update of the comment describing the forest's use of the bloom
filter block.  It used to be a tree of bloom filter items.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:02:06 -08:00
Zach BrownandZach Brown e8b0bbc619 scoutfs: remove unused counters
Remove a bunch of unused counters which have accumulated over time as
we've worked on the code and forgotten to remove counters.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:02:06 -08:00
Zach BrownandZach Brown debac8ab06 scoutfs: free all forest iter pos
Forest item iteration allocates iterator positions for each tree root
it reads from.  The postorder destruction of the iterator nodes wasn't
quite right because we were balancing the nodes as they were freed.
That can change parent/child relationships and cause postorder iteration
to skip some nodes, leaking memory.  It would have worked if we just
freed the nodes without using rb_erase to balance.

The fix is to actually iterate over the rbnodes while using the destroy
helper which rebalances as it frees.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:02:06 -08:00
Zach BrownandZach Brown e9e515524b scoutfs: remove unused corruption sources
Remove a bunch of constants for sources of corruption that are no longer
used in the code.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:02:06 -08:00
Zach BrownandZach Brown 247e22f56f scoutfs-utils: remove unused corruption sources
Remove the definitions and descriptions of sources of corruption that
are no longer identified by the kernel module.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:01:54 -08:00
Zach BrownandZach Brown 3c7d1f3935 scoutfs-utils: quick forest bloom comment update
Signed-off-by: Zach Brown <zab@versity.com>
2020-03-05 09:01:54 -08:00
Zach BrownandZach Brown 91c64dfa2d scoutfs-utils: print packed extents
Add support for printing the invidual extents stored in packed extent
items.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-02 12:11:39 -08:00
Zach BrownandZach Brown 53f29d3f2a scoutfs-utils: add ilog2() helper
It's handy to use ilog2 in the format header for defining shifts based
on values.  Add a userspace helper that uses glibc's log2 functions.

Signed-off-by: Zach Brown <zab@versity.com>
2020-03-02 12:11:39 -08:00
Zach BrownandZach Brown 7cf8d01c1b scoutfs: fix super read error race
The conversion to reading the super with buffer_head IO caused racing
readers to risk spurious errors.  Clearing uptodate to force device
access could race with a current waking reader.  They could wake and
find uptodate cleared and think that an IO error had occurred.

The buffer_head functions generally require higher level serialization
of this kind of use of the uptodate bit.  We use bh_private as a counter
to ensure that we don't clear uptodate while there are active readers.
We then also use a private buffer_head bit to satisfy batches of waiting
readers with each IO.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-28 11:34:02 -08:00
Zach BrownandZach Brown d374a7c06f scoutfs: fix up radix block _first tracking
Updating the _first tracking in leaf bits was pretty confusing because
we tried to mashing all the tracking updates from all leaf modifications
into one shared code path.

It had a bug where merging would advance _first tracking by the number
of bits merged in the leaf rather than the number of contiguous set bits
after the new first.  This lead to allocation failures eventually as
_first was after actual set bits in the leaf.

This fixes that by moving _first tracking updates into the leaf callers
that modify bits and to the parent ref updating code.

In the process we also fix little bugs in the support code that were
found by the radix block consistency checking.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-28 11:34:02 -08:00
Zach BrownandZach Brown 6eac823bd3 scoutfs: add radix block metadata checker
Add a quick runtime check of the consistency of the radix block and
reference metadata fields.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-28 11:34:02 -08:00
Zach BrownandZach Brown c10c7d9748 scoutfs: clean up forest lock data
The client lock code forgot to call into the forest to clear its
per-lock tracking before freeing the lock.  This would result in a slow
memory leak over time as locks were reclaimed by memory pressure.  It
shouldn't have affected consistency.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-28 11:34:02 -08:00
Zach BrownandZach Brown 757ee85520 scoutfs: don't lose block wakeups
The block end_io path could lose wakeups.  Both the bio submission
task and a bio's end_io completion could see an io_count > 1 and neither
would set the block uptodate before dropping their io_count and waking.

It got into this mess because readers were waiting for io_count to drop
to 0.  We add a io_busy bit which indicates that io is still in flight
which waiters now wait for.  This gives the final io_count drop a chance
to do work before clearing io_busy and dropping their reference before
waking.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-28 11:34:02 -08:00
Zach BrownandZach Brown 3308bf8d8c scoutfs-tests: use fallocate to get large extent
The simple-release-extents test wanted to create a file with a single
large extent, but it did it with a streaming write.  While we'd like
our data allocator to create a large extent from initial writes, it
certainly doesn't guarantee it.  Fallocate is much more likely to
createa a large extent.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:04:44 -08:00
Zach BrownandZach Brown cce20dbeb6 scoutfs-tests: only check for new dmesg entries
The dmesg check was creating false positives when unexpected messages
from before the test run were forced out of the ring.  The evicted
messages were showing up as removals in the diff.

We only want to see new messages that were created during the test run.
So we format the diff to only output added lines.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:04:44 -08:00
Zach BrownandZach Brown 503011b777 scoutfs-tests: prepend our paths to PATH
We add directories of our built binaries for tests to find.  Let's
prepend them to PATH so that we find them before any installed
binaries in the system.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:04:44 -08:00
Zach BrownandZach Brown ec782fff8d scoutfs-utils: meta and data free blocks
The super block now tracks free metadata and data blocks in separate
counters.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:04:17 -08:00
Zach BrownandZach Brown 6b66e583f2 scoutfs-utils: fix printing block hdr fields
The block header printing helper had the identifiers for the blkno and
seq in the format string swapped.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:04:17 -08:00
Zach BrownandZach Brown ff436db49b scoutfs-utils: add support for radix alloc
Add support for initializing radix allocator blocks that describe free
space in mkfs and support for printing them out.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:04:17 -08:00
Zach BrownandZach Brown 34c3d903d9 scoutfs-utils: add round_down() and flsll()
Add quick helpers for these two kernel functions.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:04:17 -08:00
Zach BrownandZach Brown 44a7e2ab56 scoutfs: more carefully handle alloc cursors
The first pass at the radix allocator wasn't paying a lot of attention
to the allocation cursors.

This more carefully manages them.  They're only advanced after
allocating.  Previously the metadata alloc cursor was advanced as it
searched through leaves that it might allocate from.  We test for
wrapping past the specific final allocatable bit, rather than the limit
of what the radix height can store.  This required pushing knoweldge of
metadata or data allocs down through some of the code paths.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:03:46 -08:00
Zach BrownandZach Brown 76ed627548 scoutfs: reclaim freed metadata blocks in server
Reclaim freed metadata blocks in the server by merging the stable freed
tree into the allocator as a commit opens and we can trust that the
stable version of the freed allocator in the super is a strict subset of
the allocator's dirty freed tree.

Signed-off-by: Zach Brown <zab@versity.com>
2020-02-25 12:03:46 -08:00