vold: metadata encryption: ensure F2FS GC targets correct device.

This fixes F2FS GC failure in idle-maint.

Bug: 111953875
Change-Id: I1d10802121d5641cf9ba780fee249affd2cf6ffe
Merged-In: I1d10802121d5641cf9ba780fee249affd2cf6ffe
Test: Tested by hand
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
This commit is contained in:
Jaegeuk Kim 2018-07-29 06:56:57 -07:00 committed by Paul Crowley
parent 6418bb7d34
commit 1251ef0bcf
2 changed files with 6 additions and 3 deletions

View file

@ -15,6 +15,7 @@
*/ */
#include "IdleMaint.h" #include "IdleMaint.h"
#include "FileDeviceUtils.h"
#include "Utils.h" #include "Utils.h"
#include "VolumeManager.h" #include "VolumeManager.h"
#include "model/PrivateVolume.h" #include "model/PrivateVolume.h"
@ -92,8 +93,8 @@ static void addFromVolumeManager(std::list<std::string>* paths,
} else if (path_type == PathTypes::kBlkDevice) { } else if (path_type == PathTypes::kBlkDevice) {
std::string gc_path; std::string gc_path;
const std::string& fs_type = vol->getFsType(); const std::string& fs_type = vol->getFsType();
if (fs_type == "f2fs" && if (fs_type == "f2fs" && (Realpath(vol->getRawDmDevPath(), &gc_path) ||
Realpath(vol->getRawDevPath(), &gc_path)) { Realpath(vol->getRawDevPath(), &gc_path))) {
paths->push_back(std::string("/sys/fs/") + fs_type + paths->push_back(std::string("/sys/fs/") + fs_type +
"/" + Basename(gc_path)); "/" + Basename(gc_path));
} }
@ -137,7 +138,8 @@ static void addFromFstab(std::list<std::string>* paths, PathTypes path_type) {
} else if (path_type == PathTypes::kBlkDevice) { } else if (path_type == PathTypes::kBlkDevice) {
std::string gc_path; std::string gc_path;
if (std::string(fstab->recs[i].fs_type) == "f2fs" && if (std::string(fstab->recs[i].fs_type) == "f2fs" &&
Realpath(fstab->recs[i].blk_device, &gc_path)) { Realpath(android::vold::BlockDeviceForPath(
std::string(fstab->recs[i].mount_point) + "/"), &gc_path)) {
paths->push_back(std::string("/sys/fs/") + fstab->recs[i].fs_type + paths->push_back(std::string("/sys/fs/") + fstab->recs[i].fs_type +
"/" + Basename(gc_path)); "/" + Basename(gc_path));
} }

View file

@ -41,6 +41,7 @@ public:
virtual ~PrivateVolume(); virtual ~PrivateVolume();
const std::string& getFsType() { return mFsType; }; const std::string& getFsType() { return mFsType; };
const std::string& getRawDevPath() { return mRawDevPath; }; const std::string& getRawDevPath() { return mRawDevPath; };
const std::string& getRawDmDevPath() { return mDmDevPath; };
protected: protected:
status_t doCreate() override; status_t doCreate() override;