Snap for 12702769 from 117e6318e7 to 25Q1-release

Change-Id: I71133e269dedd78e8783f5fd6f10019665d215e6
This commit is contained in:
Android Build Coastguard Worker 2024-11-23 02:19:39 +00:00
commit caebfe3b56
8 changed files with 43 additions and 35 deletions

View file

@ -1,3 +0,0 @@
third_party {
license_type: NOTICE
}

View file

@ -39,10 +39,6 @@
#include "fstab_priv.h"
#include "logging_macros.h"
#if !defined(MS_LAZYTIME)
#define MS_LAZYTIME (1 << 25)
#endif
using android::base::EndsWith;
using android::base::ParseByteCount;
using android::base::ParseInt;

View file

@ -233,6 +233,11 @@ bool MergeWorker::MergeOrderedOpsAsync() {
return false;
}
std::optional<std::lock_guard<std::mutex>> buffer_lock;
// Acquire the buffer lock at this point so that RA thread
// doesn't step into this buffer. See b/377819507
buffer_lock.emplace(snapuserd_->GetBufferLock());
snapuserd_->SetMergeInProgress(ra_block_index_);
loff_t offset = 0;
@ -383,6 +388,9 @@ bool MergeWorker::MergeOrderedOpsAsync() {
// Mark the block as merge complete
snapuserd_->SetMergeCompleted(ra_block_index_);
// Release the buffer lock
buffer_lock.reset();
// Notify RA thread that the merge thread is ready to merge the next
// window
snapuserd_->NotifyRAForMergeReady();
@ -415,6 +423,11 @@ bool MergeWorker::MergeOrderedOps() {
return false;
}
std::optional<std::lock_guard<std::mutex>> buffer_lock;
// Acquire the buffer lock at this point so that RA thread
// doesn't step into this buffer. See b/377819507
buffer_lock.emplace(snapuserd_->GetBufferLock());
snapuserd_->SetMergeInProgress(ra_block_index_);
loff_t offset = 0;
@ -468,6 +481,9 @@ bool MergeWorker::MergeOrderedOps() {
// Mark the block as merge complete
snapuserd_->SetMergeCompleted(ra_block_index_);
// Release the buffer lock
buffer_lock.reset();
// Notify RA thread that the merge thread is ready to merge the next
// window
snapuserd_->NotifyRAForMergeReady();

View file

@ -186,6 +186,7 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> {
bool IsIouringSupported();
bool CheckPartitionVerification();
std::mutex& GetBufferLock() { return buffer_lock_; }
private:
bool ReadMetadata();
@ -216,6 +217,9 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> {
std::mutex lock_;
std::condition_variable cv;
// Lock the buffer used for snapshot-merge
std::mutex buffer_lock_;
void* mapped_addr_;
size_t total_mapped_addr_length_;

View file

@ -706,25 +706,32 @@ bool ReadAhead::ReadAheadIOStart() {
return false;
}
// Copy the data to scratch space
memcpy(metadata_buffer_, ra_temp_meta_buffer_.get(), snapuserd_->GetBufferMetadataSize());
memcpy(read_ahead_buffer_, ra_temp_buffer_.get(), total_blocks_merged_ * BLOCK_SZ);
// Acquire buffer lock before doing memcpy to the scratch buffer. Although,
// by now snapshot-merge thread shouldn't be working on this scratch space
// but we take additional measure to ensure that the buffer is not being
// used by the merge thread at this point. see b/377819507
{
std::lock_guard<std::mutex> buffer_lock(snapuserd_->GetBufferLock());
// Copy the data to scratch space
memcpy(metadata_buffer_, ra_temp_meta_buffer_.get(), snapuserd_->GetBufferMetadataSize());
memcpy(read_ahead_buffer_, ra_temp_buffer_.get(), total_blocks_merged_ * BLOCK_SZ);
loff_t offset = 0;
std::unordered_map<uint64_t, void*>& read_ahead_buffer_map = snapuserd_->GetReadAheadMap();
read_ahead_buffer_map.clear();
loff_t offset = 0;
std::unordered_map<uint64_t, void*>& read_ahead_buffer_map = snapuserd_->GetReadAheadMap();
read_ahead_buffer_map.clear();
for (size_t block_index = 0; block_index < blocks_.size(); block_index++) {
void* bufptr = static_cast<void*>((char*)read_ahead_buffer_ + offset);
uint64_t new_block = blocks_[block_index];
for (size_t block_index = 0; block_index < blocks_.size(); block_index++) {
void* bufptr = static_cast<void*>((char*)read_ahead_buffer_ + offset);
uint64_t new_block = blocks_[block_index];
read_ahead_buffer_map[new_block] = bufptr;
offset += BLOCK_SZ;
read_ahead_buffer_map[new_block] = bufptr;
offset += BLOCK_SZ;
}
total_ra_blocks_completed_ += total_blocks_merged_;
snapuserd_->SetMergedBlockCountForNextCommit(total_blocks_merged_);
}
total_ra_blocks_completed_ += total_blocks_merged_;
snapuserd_->SetMergedBlockCountForNextCommit(total_blocks_merged_);
// Flush the scratch data - Technically, we should flush only for overlapping
// blocks; However, since this region is mmap'ed, the dirty pages can still
// get flushed to disk at any random point in time. Instead, make sure

View file

@ -37,10 +37,6 @@
using namespace android::fs_mgr;
using namespace testing;
#if !defined(MS_LAZYTIME)
#define MS_LAZYTIME (1 << 25)
#endif
namespace {
const std::string cmdline =

View file

@ -16,7 +16,6 @@
#pragma once
#include <sys/cdefs.h>
#include <sys/types.h>
#include <initializer_list>
#include <span>
@ -24,8 +23,6 @@
#include <string_view>
#include <vector>
__BEGIN_DECLS
static constexpr std::string CGROUPV2_HIERARCHY_NAME = "cgroup2";
bool CgroupsAvailable();
@ -39,8 +36,6 @@ bool SetTaskProfiles(pid_t tid, const std::vector<std::string>& profiles,
bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles);
bool SetUserProfiles(uid_t uid, const std::vector<std::string>& profiles);
__END_DECLS
bool SetTaskProfiles(pid_t tid, std::initializer_list<std::string_view> profiles,
bool use_fd_cache = false);
bool SetProcessProfiles(uid_t uid, pid_t pid, std::initializer_list<std::string_view> profiles);
@ -50,7 +45,6 @@ bool SetTaskProfiles(pid_t tid, std::span<const std::string_view> profiles,
bool SetProcessProfiles(uid_t uid, pid_t pid, std::span<const std::string_view> profiles);
#endif
__BEGIN_DECLS
#ifndef __ANDROID_VNDK__
@ -96,5 +90,3 @@ bool getAttributePathForTask(const std::string& attr_name, pid_t tid, std::strin
bool isProfileValidForProcess(const std::string& profile_name, uid_t uid, pid_t pid);
#endif // __ANDROID_VNDK__
__END_DECLS

View file

@ -1128,9 +1128,9 @@ on boot
# System server manages zram writeback
chown root system /sys/block/zram0/idle
chmod 0664 /sys/block/zram0/idle
chmod 0220 /sys/block/zram0/idle
chown root system /sys/block/zram0/writeback
chmod 0664 /sys/block/zram0/writeback
chmod 0220 /sys/block/zram0/writeback
# to access F2FS sysfs on dm-<num> directly
mkdir /dev/sys/fs/by-name 0755 system system