class StreamSizeManager
Defined at line 44 of file ../../zircon/kernel/vm/include/vm/stream_size_manager.h
`StreamSizeManager` is a class that helps coordinate multiple, potentially concurrent changes
to a VMO's stream size without needing to serialize the I/O of those operations. This is done by
maintaining queues of outstanding operations, allowing concurrent execution of the operations,
and then committing the stream size effects of those operations in a particular order. This idea
is similar to the re-order buffer in Tomasulo's algorithm.
There are 2 ordering queues: the read queue and the write queue. Both queues hold their
respective namesake operations as well as shrink operations.
Read operations are permitted to read up to the smallest outstanding stream size, which can be
found as the minimum of the current stream size and all shrink operations. Upon completion,
reads will always commit without blocking behind other operations.
Write operations may extend stream size. Upon completion, a write will block until it is the
head of the write queue if the smallest outstanding stream size is less than its target size.
Set size operations are treated differently, depending on whether the operation will expand or
shrink the stream size. When expanding, set size ops are treated as write operations of the same
target size (see above). When shrinking, set size ops are treated as shrink operations and will
block until it is the head if any read or write operations that operate beyond the target size
are queued in front of the set size.
Public Methods
zx::result<fbl::RefPtr<StreamSizeManager>> Create (uint64_t stream_size)
Create a StreamSizeManager with its initial stream size set to |stream_size|. Returns a
RefPtr to the newly created StreamSizeManager in |stream_size_manager| on success.
Defined at line 13 of file ../../zircon/kernel/vm/stream_size_manager.cc
zx_status_t BeginAppendLocked (uint64_t append_size, Guard<Mutex> * lock_guard, Operation * out_op)
Marks and registers the beginning of an append operation.
Notes:
* This function may block until other conflicting operations complete.
* This function may drop and reacquire the lock guarded by `lock_guard`.
* `append_size` must be greater than 0.
Defined at line 81 of file ../../zircon/kernel/vm/stream_size_manager.cc
void BeginWriteLocked (uint64_t target_size, Guard<Mutex> * lock_guard, ktl::optional<uint64_t> * out_prev_stream_size, Operation * out_op)
Marks and registers the beginning of a write operation.
If the write is results in an expansion of the stream size, returns the previous stream size
from which the write expands in `out_prev_stream_size`. The gap from the previous stream size
to where the write begins likely needs to be zeroed out.
Notes:
* This function may block until other conflicting operations complete.
* This function may drop and reacquire the lock guarted by `lock_guard`.
Defined at line 138 of file ../../zircon/kernel/vm/stream_size_manager.cc
void BeginReadLocked (uint64_t target_size, uint64_t * out_stream_size_limit, Operation * out_op)
Marks and registers the beginning of a read operation.
Returns the maximum size of the stream that should be read in `out_stream_size_limit`.
Defined at line 176 of file ../../zircon/kernel/vm/stream_size_manager.cc
Lock<Mutex> * lock ()
Defined at line 178 of file ../../zircon/kernel/vm/include/vm/stream_size_manager.h
uint64_t GetStreamSize ()
Returns the current stream size.
Defined at line 181 of file ../../zircon/kernel/vm/include/vm/stream_size_manager.h
void BeginSetStreamSizeLocked (uint64_t target_size, Operation * out_op, Guard<Mutex> * lock_guard)
Marks and registers the beginning of an operation to set the stream size to a target size.
Note that this function may drop and reacquire the lock guarded by `lock_guard`.
Defined at line 199 of file ../../zircon/kernel/vm/stream_size_manager.cc
Enumerations
enum OperationType
| Name | Value |
|---|---|
| Write | 0 |
| Read | 1 |
| SetSize | 2 |
| Append | 3 |
Defined at line 51 of file ../../zircon/kernel/vm/include/vm/stream_size_manager.h