src/storage/blobfs/common.cc
// Number of blocks reserved for the Merkle Tree
// TODO(fxbug.dev/45457): Refactor this method to not require heap allocations.
Number of blocks reserved for the Merkle Tree
TODO(fxbug.dev/45457): Refactor this method to not require heap allocations.
Number of blocks reserved for the Merkle Tree TODO ( fxbug . dev / 45457 ) : Refactor this method to not require heap allocations .
uint32_t ComputeNumMerkleTreeBlocks(const Inode& blobNode) {
  MerkleTreeCreator mtc;
  zx_status_t status = mtc.SetDataLength(blobNode.blob_size);
  if (status != ZX_OK) {
    FS_TRACE_ERROR("blobfs: Merkle tree blocks (%s) Failure: %d\n",
                   Digest(blobNode.merkle_root_hash).ToString().c_str(), status);
    return 0;
  }
  size_t merkle_size = mtc.GetTreeLength();
  if (merkle_size > std::numeric_limits<uint32_t>::max()) {
    FS_TRACE_ERROR("blobfs: Merkle tree blocks (%s) max exceeded: %zu\n",
                   Digest(blobNode.merkle_root_hash).ToString().c_str(), merkle_size);
    return 0;
  }
  return fbl::round_up(static_cast<uint32_t>(merkle_size), kBlobfsBlockSize) / kBlobfsBlockSize;
}
uint32_t ComputeNumMerkleTreeBlocks ( const Inode & blobNode ) { MerkleTreeCreator mtc ; zx_status_t status = mtc . SetDataLength ( blobNode . blob_size ) ; if ( status != ZX_OK ) { FS_TRACE_ERROR ( " \n " , Digest ( blobNode . merkle_root_hash ) . ToString ( ) . c_str ( ) , status ) ; return 0 ; } size_t merkle_size = mtc . GetTreeLength ( ) ; if ( merkle_size > std :: numeric_limits < uint32_t > :: max ( ) ) { FS_TRACE_ERROR ( " \n " , Digest ( blobNode . merkle_root_hash ) . ToString ( ) . c_str ( ) , merkle_size ) ; return 0 ; } return fbl :: round_up ( static_cast < uint32_t > ( merkle_size ) , kBlobfsBlockSize ) / kBlobfsBlockSize ; }
Number of blocks reserved for the Merkle Tree
TODO(fxbug.dev/45457): Refactor this method to not require heap allocations.
Number of blocks reserved for the Merkle Tree TODO ( fxbug . dev / 45457 ) : Refactor this method to not require heap allocations .
// If this fails, omit the Merkle tree. This will cause subsequent Merkle tree creation and/or // verification to fail.