Find a zoned partition automatically
Since we cannot create a gpt table on zoned LU, we cannot make a generic symlink
from it. Instead, let's make it by uevent, "/dev/block/by-name/zoned_device".
Note that, we support only one zoned device in the system.
Bug: 265180564
Change-Id: Ie62b0fd68b77e3e43cf0f5c5cad9503150174271
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 36bd75d..598a3d2 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -304,19 +304,16 @@
if (!ParseByteCount(arg, &entry->zram_backingdev_size)) {
LWARNING << "Warning: zram_backingdev_size= flag malformed: " << arg;
}
- } else if (StartsWith(flag, "zoned_device=")) {
- std::string zoned;
- if (ReadFileToString("/sys/class/block/" + arg + "/queue/zoned", &zoned) &&
- android::base::StartsWith(zoned, "host-managed")) {
- entry->zoned_device = "/dev/block/" + arg;
+ } else if (flag == "zoned_device") {
+ if (access("/dev/block/by-name/zoned_device", F_OK) == 0) {
+ entry->zoned_device = "/dev/block/by-name/zoned_device";
// atgc in f2fs does not support a zoned device
auto options = Split(entry->fs_options, ",");
options.erase(std::remove(options.begin(), options.end(), "atgc"), options.end());
entry->fs_options = android::base::Join(options, ",");
- LINFO << "Removed ATGC in fs_options as " << entry->fs_options;
- } else {
- LWARNING << "Warning: cannot find the zoned device: " << arg;
+ LINFO << "Removed ATGC in fs_options as " << entry->fs_options
+ << " for zoned device=" << entry->zoned_device;
}
} else {
LWARNING << "Warning: unknown flag: " << flag;
diff --git a/init/devices.cpp b/init/devices.cpp
index 8bc6e52..39442a0 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -431,6 +431,12 @@
}
}
+ std::string model;
+ if (ReadFileToString("/sys/class/block/" + uevent.device_name + "/queue/zoned", &model) &&
+ !StartsWith(model, "none")) {
+ links.emplace_back("/dev/block/by-name/zoned_device");
+ }
+
auto last_slash = uevent.path.rfind('/');
links.emplace_back(link_path + "/" + uevent.path.substr(last_slash + 1));