Loading fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_kernel.h +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ static constexpr uint32_t SNAPSHOT_VALID = 1; * multiple of 512 bytes. Hence these two constants. */ static constexpr uint32_t SECTOR_SHIFT = 9; static constexpr uint64_t SECTOR_SIZE = (1ULL << SECTOR_SHIFT); static constexpr size_t BLOCK_SZ = 4096; static constexpr size_t BLOCK_SHIFT = (__builtin_ffs(BLOCK_SZ) - 1); Loading fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.cpp +16 −14 Original line number Diff line number Diff line Loading @@ -280,20 +280,6 @@ bool SnapshotHandler::InitCowDevice() { return false; } unique_fd fd(TEMP_FAILURE_RETRY(open(base_path_merge_.c_str(), O_RDONLY | O_CLOEXEC))); if (fd < 0) { SNAP_LOG(ERROR) << "Cannot open block device"; return false; } uint64_t dev_sz = get_block_device_size(fd.get()); if (!dev_sz) { SNAP_LOG(ERROR) << "Failed to find block device size: " << base_path_merge_; return false; } num_sectors_ = dev_sz >> SECTOR_SHIFT; return ReadMetadata(); } Loading Loading @@ -460,5 +446,21 @@ void SnapshotHandler::FreeResources() { merge_thread_ = nullptr; } uint64_t SnapshotHandler::GetNumSectors() const { unique_fd fd(TEMP_FAILURE_RETRY(open(base_path_merge_.c_str(), O_RDONLY | O_CLOEXEC))); if (fd < 0) { SNAP_LOG(ERROR) << "Cannot open base path: " << base_path_merge_; return false; } uint64_t dev_sz = get_block_device_size(fd.get()); if (!dev_sz) { SNAP_LOG(ERROR) << "Failed to find block device size: " << base_path_merge_; return false; } return dev_sz / SECTOR_SIZE; } } // namespace snapshot } // namespace android fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h +1 −3 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> { const std::string& GetControlDevicePath() { return control_device_; } const std::string& GetMiscName() { return misc_name_; } const uint64_t& GetNumSectors() { return num_sectors_; } uint64_t GetNumSectors() const; const bool& IsAttached() const { return attached_; } void AttachControlDevice() { attached_ = true; } Loading Loading @@ -202,8 +202,6 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> { unique_fd cow_fd_; uint64_t num_sectors_; std::unique_ptr<CowReader> reader_; // chunk_vec stores the pseudo mapping of sector Loading fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,12 @@ bool UserSnapshotServer::Receivemsg(android::base::borrowed_fd fd, const std::st return Sendmsg(fd, "fail"); } auto retval = "success," + std::to_string(handler->snapuserd()->GetNumSectors()); auto num_sectors = handler->snapuserd()->GetNumSectors(); if (!num_sectors) { return Sendmsg(fd, "fail"); } auto retval = "success," + std::to_string(num_sectors); return Sendmsg(fd, retval); } else if (cmd == "start") { // Message format: Loading fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -540,7 +540,9 @@ void SnapuserdTest::InitCowDevice() { base_loop_->device(), 1, use_iouring, false); ASSERT_NE(handler, nullptr); ASSERT_NE(handler->snapuserd(), nullptr); #ifdef __ANDROID__ ASSERT_NE(handler->snapuserd()->GetNumSectors(), 0); #endif } void SnapuserdTest::SetDeviceControlName() { Loading Loading
fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_kernel.h +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ static constexpr uint32_t SNAPSHOT_VALID = 1; * multiple of 512 bytes. Hence these two constants. */ static constexpr uint32_t SECTOR_SHIFT = 9; static constexpr uint64_t SECTOR_SIZE = (1ULL << SECTOR_SHIFT); static constexpr size_t BLOCK_SZ = 4096; static constexpr size_t BLOCK_SHIFT = (__builtin_ffs(BLOCK_SZ) - 1); Loading
fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.cpp +16 −14 Original line number Diff line number Diff line Loading @@ -280,20 +280,6 @@ bool SnapshotHandler::InitCowDevice() { return false; } unique_fd fd(TEMP_FAILURE_RETRY(open(base_path_merge_.c_str(), O_RDONLY | O_CLOEXEC))); if (fd < 0) { SNAP_LOG(ERROR) << "Cannot open block device"; return false; } uint64_t dev_sz = get_block_device_size(fd.get()); if (!dev_sz) { SNAP_LOG(ERROR) << "Failed to find block device size: " << base_path_merge_; return false; } num_sectors_ = dev_sz >> SECTOR_SHIFT; return ReadMetadata(); } Loading Loading @@ -460,5 +446,21 @@ void SnapshotHandler::FreeResources() { merge_thread_ = nullptr; } uint64_t SnapshotHandler::GetNumSectors() const { unique_fd fd(TEMP_FAILURE_RETRY(open(base_path_merge_.c_str(), O_RDONLY | O_CLOEXEC))); if (fd < 0) { SNAP_LOG(ERROR) << "Cannot open base path: " << base_path_merge_; return false; } uint64_t dev_sz = get_block_device_size(fd.get()); if (!dev_sz) { SNAP_LOG(ERROR) << "Failed to find block device size: " << base_path_merge_; return false; } return dev_sz / SECTOR_SIZE; } } // namespace snapshot } // namespace android
fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h +1 −3 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> { const std::string& GetControlDevicePath() { return control_device_; } const std::string& GetMiscName() { return misc_name_; } const uint64_t& GetNumSectors() { return num_sectors_; } uint64_t GetNumSectors() const; const bool& IsAttached() const { return attached_; } void AttachControlDevice() { attached_ = true; } Loading Loading @@ -202,8 +202,6 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> { unique_fd cow_fd_; uint64_t num_sectors_; std::unique_ptr<CowReader> reader_; // chunk_vec stores the pseudo mapping of sector Loading
fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,12 @@ bool UserSnapshotServer::Receivemsg(android::base::borrowed_fd fd, const std::st return Sendmsg(fd, "fail"); } auto retval = "success," + std::to_string(handler->snapuserd()->GetNumSectors()); auto num_sectors = handler->snapuserd()->GetNumSectors(); if (!num_sectors) { return Sendmsg(fd, "fail"); } auto retval = "success," + std::to_string(num_sectors); return Sendmsg(fd, retval); } else if (cmd == "start") { // Message format: Loading
fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -540,7 +540,9 @@ void SnapuserdTest::InitCowDevice() { base_loop_->device(), 1, use_iouring, false); ASSERT_NE(handler, nullptr); ASSERT_NE(handler->snapuserd(), nullptr); #ifdef __ANDROID__ ASSERT_NE(handler->snapuserd()->GetNumSectors(), 0); #endif } void SnapuserdTest::SetDeviceControlName() { Loading