Wider volume mutation lock, move force adoptable.
We eventually should move back to per-disk locks, but use a giant lock to keep development rolling forward. Also move force adoptable flag to framework since, since encrypted devices don't have persisted properties loaded early during boot. Bug: 19993667 Change-Id: Ifa3016ef41b038f8f71fc30bc81596cfd21dcd2a
This commit is contained in:
parent
f3ee200303
commit
c8e04c5a82
6 changed files with 14 additions and 18 deletions
|
@ -138,6 +138,7 @@ int CommandListener::VolumeCmd::runCommand(SocketClient *cli,
|
|||
}
|
||||
|
||||
VolumeManager *vm = VolumeManager::Instance();
|
||||
std::lock_guard<std::mutex> lock(vm->getLock());
|
||||
|
||||
// TODO: tease out methods not directly related to volumes
|
||||
|
||||
|
|
6
Disk.cpp
6
Disk.cpp
|
@ -242,8 +242,6 @@ status_t Disk::readMetadata() {
|
|||
}
|
||||
|
||||
status_t Disk::readPartitions() {
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
|
||||
int8_t maxMinors = getMaxMinors();
|
||||
if (maxMinors < 0) {
|
||||
return -ENOTSUP;
|
||||
|
@ -337,8 +335,6 @@ status_t Disk::unmountAll() {
|
|||
}
|
||||
|
||||
status_t Disk::partitionPublic() {
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
|
||||
// TODO: improve this code
|
||||
destroyAllVolumes();
|
||||
mJustPartitioned = true;
|
||||
|
@ -385,8 +381,6 @@ status_t Disk::partitionPrivate() {
|
|||
}
|
||||
|
||||
status_t Disk::partitionMixed(int8_t ratio) {
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
|
||||
int res;
|
||||
|
||||
destroyAllVolumes();
|
||||
|
|
3
Disk.h
3
Disk.h
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace android {
|
||||
|
@ -101,8 +100,6 @@ private:
|
|||
int mFlags;
|
||||
/* Flag indicating object is created */
|
||||
bool mCreated;
|
||||
/* Lock held while partitioning */
|
||||
std::mutex mLock;
|
||||
/* Flag that we just partitioned and should format all volumes */
|
||||
bool mJustPartitioned;
|
||||
|
||||
|
|
|
@ -257,6 +257,7 @@ int VolumeManager::start() {
|
|||
|
||||
// Assume that we always have an emulated volume on internal
|
||||
// storage; the framework will decide if it should be mounted.
|
||||
CHECK(mInternalEmulated == nullptr);
|
||||
mInternalEmulated = std::shared_ptr<android::vold::VolumeBase>(
|
||||
new android::vold::EmulatedVolume("/data/media"));
|
||||
mInternalEmulated->create();
|
||||
|
@ -265,12 +266,15 @@ int VolumeManager::start() {
|
|||
}
|
||||
|
||||
int VolumeManager::stop() {
|
||||
CHECK(mInternalEmulated != nullptr);
|
||||
mInternalEmulated->destroy();
|
||||
mInternalEmulated = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
|
||||
if (mDebug) {
|
||||
LOG(VERBOSE) << "----------------";
|
||||
LOG(VERBOSE) << "handleBlockEvent with action " << (int) evt->getAction();
|
||||
|
@ -433,6 +437,8 @@ int VolumeManager::shutdown() {
|
|||
}
|
||||
|
||||
int VolumeManager::unmountAll() {
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
|
||||
// First, try gracefully unmounting all known devices
|
||||
if (mInternalEmulated != nullptr) {
|
||||
mInternalEmulated->unmount();
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include <cutils/multiuser.h>
|
||||
#include <utils/List.h>
|
||||
|
@ -82,6 +83,9 @@ private:
|
|||
public:
|
||||
virtual ~VolumeManager();
|
||||
|
||||
// TODO: pipe all requests through VM to avoid exposing this lock
|
||||
std::mutex& getLock() { return mLock; }
|
||||
|
||||
int start();
|
||||
int stop();
|
||||
|
||||
|
@ -186,6 +190,8 @@ private:
|
|||
|
||||
int linkPrimary(userid_t userId);
|
||||
|
||||
std::mutex mLock;
|
||||
|
||||
std::list<std::shared_ptr<DiskSource>> mDiskSources;
|
||||
std::list<std::shared_ptr<android::vold::Disk>> mDisks;
|
||||
|
||||
|
|
8
main.cpp
8
main.cpp
|
@ -42,8 +42,6 @@ static int process_config(VolumeManager *vm);
|
|||
static void coldboot(const char *path);
|
||||
static void parse_args(int argc, char** argv);
|
||||
|
||||
//#define DEBUG_FSTAB "/data/local/tmp/fstab.debug"
|
||||
|
||||
struct fstab *fstab;
|
||||
|
||||
struct selabel_handle *sehandle;
|
||||
|
@ -228,12 +226,6 @@ static int process_config(VolumeManager *vm) {
|
|||
flags |= android::vold::Disk::Flags::kDefaultPrimary;
|
||||
}
|
||||
|
||||
if (property_get_bool("vold.force_adoptable", false)
|
||||
|| property_get_bool("persist.vold.force_adoptable", false)) {
|
||||
LOG(DEBUG) << "Forcing " << sysPattern << " to be adoptable";
|
||||
flags |= android::vold::Disk::Flags::kAdoptable;
|
||||
}
|
||||
|
||||
vm->addDiskSource(std::shared_ptr<VolumeManager::DiskSource>(
|
||||
new VolumeManager::DiskSource(sysPattern, nickname, flags)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue