Loading fs_mgr/fs_mgr_fstab.cpp +17 −15 Original line number Diff line number Diff line Loading @@ -711,19 +711,17 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab) { TransformFstabForDsu(fstab, dsu_slot, Split(lp_names, ",")); } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif SkipMountingPartitions(fstab, false /* verbose */); EnableMandatoryFlags(fstab); return true; } // Returns fstab entries parsed from the device tree if they exist bool ReadFstabFromDt(Fstab* fstab, bool log) { bool ReadFstabFromDt(Fstab* fstab, bool verbose) { std::string fstab_buf = ReadFstabFromDt(); if (fstab_buf.empty()) { if (log) LINFO << __FUNCTION__ << "(): failed to read fstab from dt"; if (verbose) LINFO << __FUNCTION__ << "(): failed to read fstab from dt"; return false; } Loading @@ -731,34 +729,36 @@ bool ReadFstabFromDt(Fstab* fstab, bool log) { fmemopen(static_cast<void*>(const_cast<char*>(fstab_buf.c_str())), fstab_buf.length(), "r"), fclose); if (!fstab_file) { if (log) PERROR << __FUNCTION__ << "(): failed to create a file stream for fstab dt"; if (verbose) PERROR << __FUNCTION__ << "(): failed to create a file stream for fstab dt"; return false; } if (!ReadFstabFile(fstab_file.get(), false, fstab)) { if (log) { if (verbose) { LERROR << __FUNCTION__ << "(): failed to load fstab from kernel:" << std::endl << fstab_buf; } return false; } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif SkipMountingPartitions(fstab, verbose); return true; } #ifndef NO_SKIP_MOUNT #ifdef NO_SKIP_MOUNT bool SkipMountingPartitions(Fstab*, bool) { return true; } #else // For GSI to skip mounting /product and /system_ext, until there are well-defined interfaces // between them and /system. Otherwise, the GSI flashed on /system might not be able to work with // device-specific /product and /system_ext. skip_mount.cfg belongs to system_ext partition because // only common files for all targets can be put into system partition. It is under // /system/system_ext because GSI is a single system.img that includes the contents of system_ext // partition and product partition under /system/system_ext and /system/product, respectively. bool SkipMountingPartitions(Fstab* fstab) { constexpr const char kSkipMountConfig[] = "/system/system_ext/etc/init/config/skip_mount.cfg"; bool SkipMountingPartitions(Fstab* fstab, bool verbose) { static constexpr char kSkipMountConfig[] = "/system/system_ext/etc/init/config/skip_mount.cfg"; std::string skip_config; auto save_errno = errno; Loading @@ -777,7 +777,9 @@ bool SkipMountingPartitions(Fstab* fstab) { }); if (it == fstab->end()) continue; fstab->erase(it, fstab->end()); LOG(INFO) << "Skip mounting partition: " << skip_mount_point; if (verbose) { LINFO << "Skip mounting partition: " << skip_mount_point; } } return true; Loading @@ -787,7 +789,7 @@ bool SkipMountingPartitions(Fstab* fstab) { // Loads the fstab file and combines with fstab entries passed in from device tree. bool ReadDefaultFstab(Fstab* fstab) { Fstab dt_fstab; ReadFstabFromDt(&dt_fstab, false); ReadFstabFromDt(&dt_fstab, false /* verbose */); *fstab = std::move(dt_fstab); Loading fs_mgr/include_fstab/fstab/fstab.h +2 −2 Original line number Diff line number Diff line Loading @@ -97,9 +97,9 @@ struct FstabEntry { using Fstab = std::vector<FstabEntry>; bool ReadFstabFromFile(const std::string& path, Fstab* fstab); bool ReadFstabFromDt(Fstab* fstab, bool log = true); bool ReadFstabFromDt(Fstab* fstab, bool verbose = true); bool ReadDefaultFstab(Fstab* fstab); bool SkipMountingPartitions(Fstab* fstab); bool SkipMountingPartitions(Fstab* fstab, bool verbose = false); FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path); // The Fstab can contain multiple entries for the same mount point with different configurations. Loading fs_mgr/libsnapshot/snapuserd.h +1 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,7 @@ class Snapuserd : public std::enable_shared_from_this<Snapuserd> { bool CommitMerge(int num_merge_ops); void CloseFds() { cow_fd_ = {}; } void FreeResources() { worker_threads_.clear(); } size_t GetMetadataAreaSize() { return vec_.size(); } void* GetExceptionBuffer(size_t i) { return vec_[i].get(); } Loading fs_mgr/libsnapshot/snapuserd_server.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,13 @@ void SnapuserdServer::RunThread(std::shared_ptr<DmUserHandler> handler) { auto iter = FindHandler(&lock, handler->misc_name()); if (iter == dm_users_.end()) { // RemoveAndJoinHandler() already removed us from the list, and is // now waiting on a join(), so just return. // now waiting on a join(), so just return. Additionally, release // all the resources held by snapuserd object which are shared // by worker threads. This should be done when the last reference // of "handler" is released; but we will explicitly release here // to make sure snapuserd object is freed as it is the biggest // consumer of memory in the daemon. handler->FreeResources(); LOG(INFO) << "Exiting handler thread to allow for join: " << misc_name; return; } Loading fs_mgr/libsnapshot/snapuserd_server.h +9 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,15 @@ class DmUserHandler { public: explicit DmUserHandler(std::shared_ptr<Snapuserd> snapuserd); void FreeResources() { snapuserd_ = nullptr; } void FreeResources() { // Each worker thread holds a reference to snapuserd. // Clear them so that all the resources // held by snapuserd is released if (snapuserd_) { snapuserd_->FreeResources(); snapuserd_ = nullptr; } } const std::shared_ptr<Snapuserd>& snapuserd() const { return snapuserd_; } std::thread& thread() { return thread_; } Loading Loading
fs_mgr/fs_mgr_fstab.cpp +17 −15 Original line number Diff line number Diff line Loading @@ -711,19 +711,17 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab) { TransformFstabForDsu(fstab, dsu_slot, Split(lp_names, ",")); } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif SkipMountingPartitions(fstab, false /* verbose */); EnableMandatoryFlags(fstab); return true; } // Returns fstab entries parsed from the device tree if they exist bool ReadFstabFromDt(Fstab* fstab, bool log) { bool ReadFstabFromDt(Fstab* fstab, bool verbose) { std::string fstab_buf = ReadFstabFromDt(); if (fstab_buf.empty()) { if (log) LINFO << __FUNCTION__ << "(): failed to read fstab from dt"; if (verbose) LINFO << __FUNCTION__ << "(): failed to read fstab from dt"; return false; } Loading @@ -731,34 +729,36 @@ bool ReadFstabFromDt(Fstab* fstab, bool log) { fmemopen(static_cast<void*>(const_cast<char*>(fstab_buf.c_str())), fstab_buf.length(), "r"), fclose); if (!fstab_file) { if (log) PERROR << __FUNCTION__ << "(): failed to create a file stream for fstab dt"; if (verbose) PERROR << __FUNCTION__ << "(): failed to create a file stream for fstab dt"; return false; } if (!ReadFstabFile(fstab_file.get(), false, fstab)) { if (log) { if (verbose) { LERROR << __FUNCTION__ << "(): failed to load fstab from kernel:" << std::endl << fstab_buf; } return false; } #ifndef NO_SKIP_MOUNT SkipMountingPartitions(fstab); #endif SkipMountingPartitions(fstab, verbose); return true; } #ifndef NO_SKIP_MOUNT #ifdef NO_SKIP_MOUNT bool SkipMountingPartitions(Fstab*, bool) { return true; } #else // For GSI to skip mounting /product and /system_ext, until there are well-defined interfaces // between them and /system. Otherwise, the GSI flashed on /system might not be able to work with // device-specific /product and /system_ext. skip_mount.cfg belongs to system_ext partition because // only common files for all targets can be put into system partition. It is under // /system/system_ext because GSI is a single system.img that includes the contents of system_ext // partition and product partition under /system/system_ext and /system/product, respectively. bool SkipMountingPartitions(Fstab* fstab) { constexpr const char kSkipMountConfig[] = "/system/system_ext/etc/init/config/skip_mount.cfg"; bool SkipMountingPartitions(Fstab* fstab, bool verbose) { static constexpr char kSkipMountConfig[] = "/system/system_ext/etc/init/config/skip_mount.cfg"; std::string skip_config; auto save_errno = errno; Loading @@ -777,7 +777,9 @@ bool SkipMountingPartitions(Fstab* fstab) { }); if (it == fstab->end()) continue; fstab->erase(it, fstab->end()); LOG(INFO) << "Skip mounting partition: " << skip_mount_point; if (verbose) { LINFO << "Skip mounting partition: " << skip_mount_point; } } return true; Loading @@ -787,7 +789,7 @@ bool SkipMountingPartitions(Fstab* fstab) { // Loads the fstab file and combines with fstab entries passed in from device tree. bool ReadDefaultFstab(Fstab* fstab) { Fstab dt_fstab; ReadFstabFromDt(&dt_fstab, false); ReadFstabFromDt(&dt_fstab, false /* verbose */); *fstab = std::move(dt_fstab); Loading
fs_mgr/include_fstab/fstab/fstab.h +2 −2 Original line number Diff line number Diff line Loading @@ -97,9 +97,9 @@ struct FstabEntry { using Fstab = std::vector<FstabEntry>; bool ReadFstabFromFile(const std::string& path, Fstab* fstab); bool ReadFstabFromDt(Fstab* fstab, bool log = true); bool ReadFstabFromDt(Fstab* fstab, bool verbose = true); bool ReadDefaultFstab(Fstab* fstab); bool SkipMountingPartitions(Fstab* fstab); bool SkipMountingPartitions(Fstab* fstab, bool verbose = false); FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path); // The Fstab can contain multiple entries for the same mount point with different configurations. Loading
fs_mgr/libsnapshot/snapuserd.h +1 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,7 @@ class Snapuserd : public std::enable_shared_from_this<Snapuserd> { bool CommitMerge(int num_merge_ops); void CloseFds() { cow_fd_ = {}; } void FreeResources() { worker_threads_.clear(); } size_t GetMetadataAreaSize() { return vec_.size(); } void* GetExceptionBuffer(size_t i) { return vec_[i].get(); } Loading
fs_mgr/libsnapshot/snapuserd_server.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,13 @@ void SnapuserdServer::RunThread(std::shared_ptr<DmUserHandler> handler) { auto iter = FindHandler(&lock, handler->misc_name()); if (iter == dm_users_.end()) { // RemoveAndJoinHandler() already removed us from the list, and is // now waiting on a join(), so just return. // now waiting on a join(), so just return. Additionally, release // all the resources held by snapuserd object which are shared // by worker threads. This should be done when the last reference // of "handler" is released; but we will explicitly release here // to make sure snapuserd object is freed as it is the biggest // consumer of memory in the daemon. handler->FreeResources(); LOG(INFO) << "Exiting handler thread to allow for join: " << misc_name; return; } Loading
fs_mgr/libsnapshot/snapuserd_server.h +9 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,15 @@ class DmUserHandler { public: explicit DmUserHandler(std::shared_ptr<Snapuserd> snapuserd); void FreeResources() { snapuserd_ = nullptr; } void FreeResources() { // Each worker thread holds a reference to snapuserd. // Clear them so that all the resources // held by snapuserd is released if (snapuserd_) { snapuserd_->FreeResources(); snapuserd_ = nullptr; } } const std::shared_ptr<Snapuserd>& snapuserd() const { return snapuserd_; } std::thread& thread() { return thread_; } Loading