diff options
author | David Anderson <dvander@google.com> | 2022-07-19 13:56:17 -0700 |
---|---|---|
committer | Arvind Kumar <quic_c_karvin@quicinc.com> | 2023-01-16 07:00:19 +0000 |
commit | cd1ae69fcfb100d7d4b83d02ba95d0821ea9b838 (patch) | |
tree | 794be81aa0839b8c8891e2e69e595d6a402ff418 | |
parent | 5582eaf14ab7b6d63670c5fac672030d4bf129fb (diff) |
remount: Ensure that scratch images are block-size aligned.
Bug: 218976943
Test: adb remount
CRs-Fixed: 3380890
Change-Id: I46a4592c4ba504865a633437d734ce26e5fba6a5
(cherry picked from commit 2d8bc218237bd2759f88840e16ad2f87ed393146)
-rw-r--r-- | fs_mgr/fs_mgr_overlayfs.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp index 82b5275a3..6942d0ccd 100644 --- a/fs_mgr/fs_mgr_overlayfs.cpp +++ b/fs_mgr/fs_mgr_overlayfs.cpp @@ -1140,7 +1140,13 @@ static inline uint64_t GetIdealDataScratchSize() { return 0; } - return std::min(super_info.size, (uint64_t(s.f_frsize) * s.f_bfree) / 2); + auto ideal_size = std::min(super_info.size, (uint64_t(s.f_frsize) * s.f_bfree) / 2); + + // Align up to the filesystem block size. + if (auto remainder = ideal_size % s.f_bsize; remainder > 0) { + ideal_size += s.f_bsize - remainder; + } + return ideal_size; } static bool CreateScratchOnData(std::string* scratch_device, bool* partition_exists, bool* change) { |