Merge "16K: Part V Configure ext4 and f2fs block size based on TARGET_PAGE_SIZE" into main-16k-with-phones
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index ede3afd..a2d996c 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -613,7 +613,7 @@
// Read the primary superblock from an f2fs filesystem. On failure return
// false. If it's not an f2fs filesystem, also set FS_STAT_INVALID_MAGIC.
-#define F2FS_BLKSIZE 16384
+#define F2FS_BLKSIZE TARGET_PAGE_SIZE
#define F2FS_SUPER_OFFSET 1024
static bool read_f2fs_superblock(const std::string& blk_device, int* fs_stat) {
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(blk_device.c_str(), O_RDONLY | O_CLOEXEC)));
diff --git a/fs_mgr/fs_mgr_format.cpp b/fs_mgr/fs_mgr_format.cpp
index 6e9079f..bfa511b 100644
--- a/fs_mgr/fs_mgr_format.cpp
+++ b/fs_mgr/fs_mgr_format.cpp
@@ -56,6 +56,9 @@
return 0;
}
+#define __STRINGIFY(PRE) #PRE
+#define STRINGIFY(PRE) __STRINGIFY(PRE)
+
static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_point,
bool needs_projid, bool needs_metadata_csum) {
uint64_t dev_sz;
@@ -68,9 +71,10 @@
/* Format the partition using the calculated length */
- std::string size_str = std::to_string(dev_sz / 16384);
+ std::string size_str = std::to_string(dev_sz / TARGET_PAGE_SIZE);
- std::vector<const char*> mke2fs_args = {"/system/bin/mke2fs", "-t", "ext4", "-b", "16384"};
+ std::vector<const char*> mke2fs_args = {"/system/bin/mke2fs", "-t", "ext4", "-b",
+ STRINGIFY(TARGET_PAGE_SIZE)};
// Project ID's require wider inodes. The Quotas themselves are enabled by tune2fs during boot.
if (needs_projid) {
@@ -127,7 +131,7 @@
/* Format the partition using the calculated length */
- std::string size_str = std::to_string(dev_sz / 16384);
+ std::string size_str = std::to_string(dev_sz / TARGET_PAGE_SIZE);
std::vector<const char*> args = {"/system/bin/make_f2fs", "-g", "android"};
if (needs_projid) {
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp
index 3bdefb4..408ea60 100644
--- a/fs_mgr/fs_mgr_overlayfs.cpp
+++ b/fs_mgr/fs_mgr_overlayfs.cpp
@@ -932,6 +932,9 @@
return "";
}
+#define __STRINGIFY(PRE) #PRE
+#define STRINGIFY(PRE) __STRINGIFY(PRE)
+
bool MakeScratchFilesystem(const std::string& scratch_device) {
// Force mkfs by design for overlay support of adb remount, simplify and
// thus do not rely on fsck to correct problems that could creep in.
@@ -939,10 +942,13 @@
auto command = ""s;
if (!access(kMkF2fs.c_str(), X_OK) && fs_mgr_filesystem_available("f2fs")) {
fs_type = "f2fs";
- command = kMkF2fs + " -w 16384 -f -d1 -l" + android::base::Basename(kScratchMountPoint);
+ command = kMkF2fs + " -w " STRINGIFY(TARGET_PAGE_SIZE) " -f -d1 -l" +
+ android::base::Basename(kScratchMountPoint);
} else if (!access(kMkExt4.c_str(), X_OK) && fs_mgr_filesystem_available("ext4")) {
fs_type = "ext4";
- command = kMkExt4 + " -F -b 16384 -t ext4 -m 0 -O has_journal -M " + kScratchMountPoint;
+ command = kMkExt4 +
+ " -F -b " STRINGIFY(TARGET_PAGE_SIZE) " -t ext4 -m 0 -O has_journal -M " +
+ kScratchMountPoint;
} else {
LERROR << "No supported mkfs command or filesystem driver available, supported filesystems "
"are: f2fs, ext4";