Loading fs_mgr/blockdev.cpp +6 −11 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,6 @@ using android::base::Basename; using android::base::ErrnoError; using android::base::ErrnoError; using android::base::Error; using android::base::Error; using android::base::Result; using android::base::Result; using android::base::ResultError; using android::base::StartsWith; using android::base::StartsWith; using android::base::StringPrintf; using android::base::StringPrintf; using android::base::unique_fd; using android::base::unique_fd; Loading Loading @@ -94,10 +93,8 @@ static Result<uint32_t> BlockDeviceQueueDepth(const std::string& file_path) { std::string blockdev = "/dev/block/" + BlockdevName(statbuf.st_dev); std::string blockdev = "/dev/block/" + BlockdevName(statbuf.st_dev); LOG(DEBUG) << __func__ << ": " << file_path << " -> " << blockdev; LOG(DEBUG) << __func__ << ": " << file_path << " -> " << blockdev; if (blockdev.empty()) { if (blockdev.empty()) { const std::string err_msg = return Errorf("Failed to convert {}:{} (path {})", major(statbuf.st_dev), StringPrintf("Failed to convert %u:%u (path %s)", major(statbuf.st_dev), minor(statbuf.st_dev), file_path.c_str()); minor(statbuf.st_dev), file_path.c_str()); return ResultError(err_msg, 0); } } auto& dm = DeviceMapper::Instance(); auto& dm = DeviceMapper::Instance(); for (;;) { for (;;) { Loading @@ -110,7 +107,7 @@ static Result<uint32_t> BlockDeviceQueueDepth(const std::string& file_path) { } } std::optional<std::string> maybe_blockdev = android::dm::ExtractBlockDeviceName(blockdev); std::optional<std::string> maybe_blockdev = android::dm::ExtractBlockDeviceName(blockdev); if (!maybe_blockdev) { if (!maybe_blockdev) { return ResultError("Failed to remove /dev/block/ prefix from " + blockdev, 0); return Errorf("Failed to remove /dev/block/ prefix from {}", blockdev); } } blockdev = PartitionParent(*maybe_blockdev); blockdev = PartitionParent(*maybe_blockdev); LOG(DEBUG) << __func__ << ": " LOG(DEBUG) << __func__ << ": " Loading @@ -119,7 +116,7 @@ static Result<uint32_t> BlockDeviceQueueDepth(const std::string& file_path) { StringPrintf("/sys/class/block/%s/mq/0/nr_tags", blockdev.c_str()); StringPrintf("/sys/class/block/%s/mq/0/nr_tags", blockdev.c_str()); std::string nr_tags; std::string nr_tags; if (!android::base::ReadFileToString(nr_tags_path, &nr_tags)) { if (!android::base::ReadFileToString(nr_tags_path, &nr_tags)) { return ResultError("Failed to read " + nr_tags_path, 0); return Errorf("Failed to read {}", nr_tags_path); } } rtrim(nr_tags); rtrim(nr_tags); LOG(DEBUG) << __func__ << ": " << file_path << " is backed by /dev/" << blockdev LOG(DEBUG) << __func__ << ": " << file_path << " is backed by /dev/" << blockdev Loading @@ -137,11 +134,9 @@ Result<void> ConfigureQueueDepth(const std::string& loop_device_path, const std::string loop_device_name = Basename(loop_device_path); const std::string loop_device_name = Basename(loop_device_path); const Result<uint32_t> qd = BlockDeviceQueueDepth(file_path); const auto qd = BlockDeviceQueueDepth(file_path); if (!qd.ok()) { if (!qd.ok()) { LOG(DEBUG) << __func__ << ": " return qd.error(); << "BlockDeviceQueueDepth() returned " << qd.error(); return ResultError(qd.error()); } } const std::string nr_requests = StringPrintf("%u", *qd); const std::string nr_requests = StringPrintf("%u", *qd); const std::string sysfs_path = const std::string sysfs_path = Loading fs_mgr/fs_mgr.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -2044,7 +2044,9 @@ static bool PrepareZramBackingDevice(off64_t size) { ConfigureIoScheduler(loop_device); ConfigureIoScheduler(loop_device); ConfigureQueueDepth(loop_device, "/"); if (auto ret = ConfigureQueueDepth(loop_device, "/"); !ret.ok()) { LOG(DEBUG) << "Failed to config queue depth: " << ret.error().message(); } // set block size & direct IO // set block size & direct IO unique_fd loop_fd(TEMP_FAILURE_RETRY(open(loop_device.c_str(), O_RDWR | O_CLOEXEC))); unique_fd loop_fd(TEMP_FAILURE_RETRY(open(loop_device.c_str(), O_RDWR | O_CLOEXEC))); Loading init/builtins.cpp +3 −2 Original line number Original line Diff line number Diff line Loading @@ -88,6 +88,7 @@ using namespace std::literals::string_literals; using namespace std::literals::string_literals; using android::base::Basename; using android::base::Basename; using android::base::ResultError; using android::base::SetProperty; using android::base::SetProperty; using android::base::Split; using android::base::Split; using android::base::StartsWith; using android::base::StartsWith; Loading Loading @@ -116,7 +117,7 @@ class ErrorIgnoreEnoent { android::base::GetMinimumLogSeverity() > android::base::DEBUG) {} android::base::GetMinimumLogSeverity() > android::base::DEBUG) {} template <typename T> template <typename T> operator android::base::expected<T, ResultError>() { operator android::base::expected<T, ResultError<int>>() { if (ignore_error_) { if (ignore_error_) { return {}; return {}; } } Loading @@ -130,7 +131,7 @@ class ErrorIgnoreEnoent { } } private: private: Error error_; Error<> error_; bool ignore_error_; bool ignore_error_; }; }; Loading init/subcontext.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -297,7 +297,7 @@ Result<void> Subcontext::Execute(const std::vector<std::string>& args) { if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { auto& failure = subcontext_reply->failure(); auto& failure = subcontext_reply->failure(); return ResultError(failure.error_string(), failure.error_errno()); return ResultError<>(failure.error_string(), failure.error_errno()); } } if (subcontext_reply->reply_case() != SubcontextReply::kSuccess) { if (subcontext_reply->reply_case() != SubcontextReply::kSuccess) { Loading @@ -321,7 +321,7 @@ Result<std::vector<std::string>> Subcontext::ExpandArgs(const std::vector<std::s if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { auto& failure = subcontext_reply->failure(); auto& failure = subcontext_reply->failure(); return ResultError(failure.error_string(), failure.error_errno()); return ResultError<>(failure.error_string(), failure.error_errno()); } } if (subcontext_reply->reply_case() != SubcontextReply::kExpandArgsReply) { if (subcontext_reply->reply_case() != SubcontextReply::kExpandArgsReply) { Loading Loading
fs_mgr/blockdev.cpp +6 −11 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,6 @@ using android::base::Basename; using android::base::ErrnoError; using android::base::ErrnoError; using android::base::Error; using android::base::Error; using android::base::Result; using android::base::Result; using android::base::ResultError; using android::base::StartsWith; using android::base::StartsWith; using android::base::StringPrintf; using android::base::StringPrintf; using android::base::unique_fd; using android::base::unique_fd; Loading Loading @@ -94,10 +93,8 @@ static Result<uint32_t> BlockDeviceQueueDepth(const std::string& file_path) { std::string blockdev = "/dev/block/" + BlockdevName(statbuf.st_dev); std::string blockdev = "/dev/block/" + BlockdevName(statbuf.st_dev); LOG(DEBUG) << __func__ << ": " << file_path << " -> " << blockdev; LOG(DEBUG) << __func__ << ": " << file_path << " -> " << blockdev; if (blockdev.empty()) { if (blockdev.empty()) { const std::string err_msg = return Errorf("Failed to convert {}:{} (path {})", major(statbuf.st_dev), StringPrintf("Failed to convert %u:%u (path %s)", major(statbuf.st_dev), minor(statbuf.st_dev), file_path.c_str()); minor(statbuf.st_dev), file_path.c_str()); return ResultError(err_msg, 0); } } auto& dm = DeviceMapper::Instance(); auto& dm = DeviceMapper::Instance(); for (;;) { for (;;) { Loading @@ -110,7 +107,7 @@ static Result<uint32_t> BlockDeviceQueueDepth(const std::string& file_path) { } } std::optional<std::string> maybe_blockdev = android::dm::ExtractBlockDeviceName(blockdev); std::optional<std::string> maybe_blockdev = android::dm::ExtractBlockDeviceName(blockdev); if (!maybe_blockdev) { if (!maybe_blockdev) { return ResultError("Failed to remove /dev/block/ prefix from " + blockdev, 0); return Errorf("Failed to remove /dev/block/ prefix from {}", blockdev); } } blockdev = PartitionParent(*maybe_blockdev); blockdev = PartitionParent(*maybe_blockdev); LOG(DEBUG) << __func__ << ": " LOG(DEBUG) << __func__ << ": " Loading @@ -119,7 +116,7 @@ static Result<uint32_t> BlockDeviceQueueDepth(const std::string& file_path) { StringPrintf("/sys/class/block/%s/mq/0/nr_tags", blockdev.c_str()); StringPrintf("/sys/class/block/%s/mq/0/nr_tags", blockdev.c_str()); std::string nr_tags; std::string nr_tags; if (!android::base::ReadFileToString(nr_tags_path, &nr_tags)) { if (!android::base::ReadFileToString(nr_tags_path, &nr_tags)) { return ResultError("Failed to read " + nr_tags_path, 0); return Errorf("Failed to read {}", nr_tags_path); } } rtrim(nr_tags); rtrim(nr_tags); LOG(DEBUG) << __func__ << ": " << file_path << " is backed by /dev/" << blockdev LOG(DEBUG) << __func__ << ": " << file_path << " is backed by /dev/" << blockdev Loading @@ -137,11 +134,9 @@ Result<void> ConfigureQueueDepth(const std::string& loop_device_path, const std::string loop_device_name = Basename(loop_device_path); const std::string loop_device_name = Basename(loop_device_path); const Result<uint32_t> qd = BlockDeviceQueueDepth(file_path); const auto qd = BlockDeviceQueueDepth(file_path); if (!qd.ok()) { if (!qd.ok()) { LOG(DEBUG) << __func__ << ": " return qd.error(); << "BlockDeviceQueueDepth() returned " << qd.error(); return ResultError(qd.error()); } } const std::string nr_requests = StringPrintf("%u", *qd); const std::string nr_requests = StringPrintf("%u", *qd); const std::string sysfs_path = const std::string sysfs_path = Loading
fs_mgr/fs_mgr.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -2044,7 +2044,9 @@ static bool PrepareZramBackingDevice(off64_t size) { ConfigureIoScheduler(loop_device); ConfigureIoScheduler(loop_device); ConfigureQueueDepth(loop_device, "/"); if (auto ret = ConfigureQueueDepth(loop_device, "/"); !ret.ok()) { LOG(DEBUG) << "Failed to config queue depth: " << ret.error().message(); } // set block size & direct IO // set block size & direct IO unique_fd loop_fd(TEMP_FAILURE_RETRY(open(loop_device.c_str(), O_RDWR | O_CLOEXEC))); unique_fd loop_fd(TEMP_FAILURE_RETRY(open(loop_device.c_str(), O_RDWR | O_CLOEXEC))); Loading
init/builtins.cpp +3 −2 Original line number Original line Diff line number Diff line Loading @@ -88,6 +88,7 @@ using namespace std::literals::string_literals; using namespace std::literals::string_literals; using android::base::Basename; using android::base::Basename; using android::base::ResultError; using android::base::SetProperty; using android::base::SetProperty; using android::base::Split; using android::base::Split; using android::base::StartsWith; using android::base::StartsWith; Loading Loading @@ -116,7 +117,7 @@ class ErrorIgnoreEnoent { android::base::GetMinimumLogSeverity() > android::base::DEBUG) {} android::base::GetMinimumLogSeverity() > android::base::DEBUG) {} template <typename T> template <typename T> operator android::base::expected<T, ResultError>() { operator android::base::expected<T, ResultError<int>>() { if (ignore_error_) { if (ignore_error_) { return {}; return {}; } } Loading @@ -130,7 +131,7 @@ class ErrorIgnoreEnoent { } } private: private: Error error_; Error<> error_; bool ignore_error_; bool ignore_error_; }; }; Loading
init/subcontext.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -297,7 +297,7 @@ Result<void> Subcontext::Execute(const std::vector<std::string>& args) { if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { auto& failure = subcontext_reply->failure(); auto& failure = subcontext_reply->failure(); return ResultError(failure.error_string(), failure.error_errno()); return ResultError<>(failure.error_string(), failure.error_errno()); } } if (subcontext_reply->reply_case() != SubcontextReply::kSuccess) { if (subcontext_reply->reply_case() != SubcontextReply::kSuccess) { Loading @@ -321,7 +321,7 @@ Result<std::vector<std::string>> Subcontext::ExpandArgs(const std::vector<std::s if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { if (subcontext_reply->reply_case() == SubcontextReply::kFailure) { auto& failure = subcontext_reply->failure(); auto& failure = subcontext_reply->failure(); return ResultError(failure.error_string(), failure.error_errno()); return ResultError<>(failure.error_string(), failure.error_errno()); } } if (subcontext_reply->reply_case() != SubcontextReply::kExpandArgsReply) { if (subcontext_reply->reply_case() != SubcontextReply::kExpandArgsReply) { Loading