OSDN Git Service

Prefer f2fs for virtual (private) storage volumes.
authorMartijn Coenen <maco@google.com>
Wed, 11 Mar 2020 14:33:22 +0000 (15:33 +0100)
committerMartijn Coenen <maco@google.com>
Wed, 11 Mar 2020 14:36:14 +0000 (15:36 +0100)
Since ext4 currently doesn't have the required kernel patches in place
on cuttlefish.

Bug: 150935323
Test: sm set-virtual-disk true
      sm partition disk:7,xyz private
      inspect mount output
Change-Id: Ief5bd9ace9d39bdfbae8d3857044a2143801f6be

model/PrivateVolume.cpp

index a54b05e..75757f7 100644 (file)
@@ -43,6 +43,7 @@ using android::base::StringPrintf;
 namespace android {
 namespace vold {
 
+static const unsigned int kMajorBlockLoop = 7;
 static const unsigned int kMajorBlockMmc = 179;
 
 PrivateVolume::PrivateVolume(dev_t device, const KeyBuffer& keyRaw)
@@ -207,7 +208,9 @@ status_t PrivateVolume::doFormat(const std::string& fsType) {
     if (fsType == "auto") {
         // For now, assume that all MMC devices are flash-based SD cards, and
         // give everyone else ext4 because sysfs rotational isn't reliable.
-        if ((major(mRawDevice) == kMajorBlockMmc) && f2fs::IsSupported()) {
+        // Additionally, prefer f2fs for loop-bases devices
+        if ((major(mRawDevice) == kMajorBlockMmc || major(mRawDevice) == kMajorBlockLoop) &&
+            f2fs::IsSupported()) {
             resolvedFsType = "f2fs";
         } else {
             resolvedFsType = "ext4";