[blobfs] Change container size and reorder member fields
Saves 8 bytes per blobfs::Blob instance
Before:
[zxdb] p sizeof(blobfs::Blob)
344
After:
[zxdb] p sizeof(blobfs::Blob)
336
TEST: Built
Change-Id: I3bbbcfce66441aa6fbaa84a1738975c1a442b21f
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/392353
Reviewed-by: Brett Wilson <brettw@google.com>
Testability-Review: Brett Wilson <brettw@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
diff --git a/zircon/system/ulib/blobfs/blob.cc b/zircon/system/ulib/blobfs/blob.cc
index bdd7410..bc64988 100644
--- a/zircon/system/ulib/blobfs/blob.cc
+++ b/zircon/system/ulib/blobfs/blob.cc
@@ -111,8 +111,8 @@
blobfs_(bs),
flags_(kBlobStateReadable),
syncing_state_(SyncingState::kDone),
- clone_watcher_(this),
map_index_(node_index),
+ clone_watcher_(this),
inode_(inode) {}
zx_status_t Blob::SpaceAllocate(uint64_t size_data) {
diff --git a/zircon/system/ulib/blobfs/blob.h b/zircon/system/ulib/blobfs/blob.h
index 2730fa2..722c95c 100644
--- a/zircon/system/ulib/blobfs/blob.h
+++ b/zircon/system/ulib/blobfs/blob.h
@@ -50,7 +50,7 @@
using digest::Digest;
using digest::MerkleTreeVerifier;
-typedef uint32_t BlobFlags;
+typedef uint16_t BlobFlags;
// clang-format off
@@ -252,11 +252,9 @@
Blobfs* const blobfs_;
BlobFlags flags_ = {};
- // This object is not generally threadsafe but a few small things are done on the journal thread.
- // This mutex protects such data.
- std::mutex mutex_;
+ bool tearing_down_ = false;
- enum class SyncingState {
+ enum class SyncingState : char {
// The Blob is being streamed and it is not possible to generate the merkle root and metadata at
// this point.
kDataIncomplete,
@@ -272,6 +270,12 @@
// is protected by the mutex.
SyncingState syncing_state_ __TA_GUARDED(mutex_) = SyncingState::kDataIncomplete;
+ uint32_t map_index_ = 0;
+
+ // This object is not generally threadsafe but a few small things are done on the journal thread.
+ // This mutex protects such data.
+ std::mutex mutex_;
+
// VMO mappings for the blob's merkle tree and data.
// Data is stored in a separate VMO from the merkle tree for several reasons:
// - While data may be paged, the merkle tree (i.e. verification metadata) should always be
@@ -296,8 +300,6 @@
zx::event readable_event_ = {};
uint32_t fd_count_ = 0;
- uint32_t map_index_ = 0;
- bool tearing_down_ = false;
// TODO(smklein): We are only using a few of these fields, such as:
// - blob_size