30bcb6947b
I intended to also add a test for cycles in the btree that backs the mtree (and eventually other btrees), but something really curious happened. It turns out it's actually really hard to create a btree cycle, even intentionally. This is because each CoW btree pointer includes the expected CRC of the branch's rbyd. To succesfully create a cycle that isn't trivially detected in a validating mtree traversal, you would somehow need to solve for a cyclic set of dependent CRCs that are still valid. I suspect this is slightly easier than a hash-based construction, due to the linear nature of CRCs, but still I think it's unreasonable to expect these sort of cycles to occur in the wild. Even with filesystem bugs. --- Note this isn't true for the mdirs, which are mutable so storing a checksum in the pointer isn't possible. For this reason, cycle detection is kept for mdirs during mtree traversal. This may not be strictly necessary for the mtree, but it needed for the mroot chain. Nonetheless, this does simplify things. Specifically it reduces the cycle detection's tortoise state to only mdir pairs.