class Journal
Defined at line 56 of file ../../src/storage/lib/vfs/cpp/journal/journal.h
This class implements an interface for filesystems to write back data to the underlying
device. It provides methods for the following functionality:
- Writing data to the underlying device
- Writing metadata to the underlying device (journaled or unjournaled)
- Revoking metadata from the journal
The journal operates on asynchronous objects: it returns promises corresponding to each
operation, which may be chained together by the caller, and which may be completed by scheduling
these promises on the journal's executor via |journal.schedule_task|.
EXAMPLE USAGE
Journal journal(...);
auto data_promise = journal.WriteData(vnode_data);
journal.CommitTransaction({
.metadata_operations = ...
});
// A few moments later...
journal.schedule_task(Sync().and_then([]() {
printf("Operation completed successfully!");
}));
This class is thread-safe.
Public Methods
void Journal (fs::TransactionHandler * transaction_handler, JournalSuperblock journal_superblock, std::unique_ptr<storage::BlockingRingBuffer> journal_buffer, std::unique_ptr<storage::BlockingRingBuffer> writeback_buffer, uint64_t journal_start_block)
Constructs a Journal with journaling enabled. This is the traditional constructor of Journals,
where data and metadata are treated separately.
|journal_superblock| represents the journal info block.
|journal_buffer| must be the size of the entries (not including the info block).
|journal_start_block| must point to the start of the journal info block.
Defined at line 76 of file ../../src/storage/lib/vfs/cpp/journal/journal.cc
void ~Journal ()
Synchronizes with the background thread to ensure all enqueued work is complete before
returning.
Defined at line 91 of file ../../src/storage/lib/vfs/cpp/journal/journal.cc
void schedule_task (fpromise::pending_task task)
Schedules a promise to the journals background thread executor.
Defined at line 115 of file ../../src/storage/lib/vfs/cpp/journal/journal.h
void set_write_metadata_callback (fit::function<void ()> callback)
See comment below for write_metadata_callback_ for how this might be used.
Defined at line 120 of file ../../src/storage/lib/vfs/cpp/journal/journal.h
Promise WriteData (std::vector<storage::UnbufferedOperation> operations)
Transmits operations containing pure data, which may be subject to different atomicity
guarantees than metadata updates.
Multiple requests to WriteData are not ordered. If ordering is desired, it should be added
using a |fpromise::sequencer| object, or by chaining the data writeback promise along an object
which is ordered.
Defined at line 124 of file ../../src/storage/lib/vfs/cpp/journal/journal.cc
bool IsWritebackEnabled ()
Returns true if all writeback is "off", and no further data will be written to the
device.
Defined at line 126 of file ../../src/storage/lib/vfs/cpp/journal/journal.h
zx_status_t CommitTransaction (Transaction transaction)
Commits a transaction.
Defined at line 157 of file ../../src/storage/lib/vfs/cpp/journal/journal.cc
Promise Sync ()
Returns a promise which identifies that all previous committed transactions have completed
(regardless of success). Additionally, prompt the internal journal writer to update the info
block, if it isn't already up-to-date.
Defined at line 264 of file ../../src/storage/lib/vfs/cpp/journal/journal.cc