libsnapshot: Move BLOCK_SZ to snapuserd.
Block sizes should not be hardcoded, since the value is set in the cow header. Move this to snapuserd to isolate use. Bug: 280529365 Test: builds Change-Id: I62aa8c7b795f9d258d4b6deb0779a536cba65d52
This commit is contained in:
parent
de20e57f08
commit
4485a6dfa4
4 changed files with 5 additions and 7 deletions
|
|
@ -28,9 +28,6 @@ static constexpr uint32_t kCowVersionMinor = 0;
|
|||
|
||||
static constexpr uint32_t kCowVersionManifest = 2;
|
||||
|
||||
static constexpr size_t BLOCK_SZ = 4096;
|
||||
static constexpr size_t BLOCK_SHIFT = (__builtin_ffs(BLOCK_SZ) - 1);
|
||||
|
||||
// This header appears as the first sequence of bytes in the COW. All fields
|
||||
// in the layout are little-endian encoded. The on-disk layout is:
|
||||
//
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ std::ostream& operator<<(std::ostream& os, CowOperation const& op) {
|
|||
os << "data_length:" << op.data_length << ",\t";
|
||||
os << "new_block:" << op.new_block << ",\t";
|
||||
os << "source:" << op.source;
|
||||
if (op.type == kCowXorOp)
|
||||
os << " (block:" << op.source / BLOCK_SZ << " offset:" << op.source % BLOCK_SZ << ")";
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -517,8 +517,8 @@ bool CowReader::VerifyMergeOps() {
|
|||
block = op.source;
|
||||
offset = false;
|
||||
} else if (op.type == kCowXorOp) {
|
||||
block = op.source / BLOCK_SZ;
|
||||
offset = (op.source % BLOCK_SZ) != 0;
|
||||
block = op.source / header_.block_size;
|
||||
offset = (op.source % header_.block_size) != 0;
|
||||
} else {
|
||||
itr->Next();
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ static constexpr uint32_t SNAPSHOT_VALID = 1;
|
|||
*/
|
||||
static constexpr uint32_t SECTOR_SHIFT = 9;
|
||||
|
||||
static constexpr size_t BLOCK_SZ = 4096;
|
||||
static constexpr size_t BLOCK_SHIFT = (__builtin_ffs(BLOCK_SZ) - 1);
|
||||
|
||||
typedef __u64 sector_t;
|
||||
typedef sector_t chunk_t;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue