Merge "Make android_logger_set_prune_list() sane"
diff --git a/init/persistent_properties.cpp b/init/persistent_properties.cpp
index baa9ad4..3b5a41d 100644
--- a/init/persistent_properties.cpp
+++ b/init/persistent_properties.cpp
@@ -31,10 +31,11 @@
#include "util.h"
+using android::base::Dirname;
using android::base::ReadFdToString;
using android::base::StartsWith;
-using android::base::WriteStringToFd;
using android::base::unique_fd;
+using android::base::WriteStringToFd;
namespace android {
namespace init {
@@ -191,6 +192,18 @@
unlink(temp_filename.c_str());
return Error(saved_errno) << "Unable to rename persistent property file";
}
+
+ // rename() is atomic with regards to the kernel's filesystem buffers, but the parent
+ // directories must be fsync()'ed otherwise, the rename is not necessarily written to storage.
+ // Note in this case, that the source and destination directories are the same, so only one
+ // fsync() is required.
+ auto dir = Dirname(persistent_property_filename);
+ auto dir_fd = unique_fd{open(dir.c_str(), O_DIRECTORY | O_RDONLY)};
+ if (dir_fd < 0) {
+ return ErrnoError() << "Unable to open persistent properties directory for fsync()";
+ }
+ fsync(dir_fd);
+
return {};
}
diff --git a/rootdir/init.rc b/rootdir/init.rc
index ff68734..e2ecad4 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -770,6 +770,11 @@
write /sys/fs/f2fs/${dev.mnt.blk.data}/cp_interval 200
write /sys/fs/f2fs/${dev.mnt.blk.data}/gc_urgent_sleep_time 50
+ # limit discard size to 128MB in order to avoid long IO latency
+ # for filesystem tuning first (dm or sda)
+ # Note that, if dm-<num> is used, sda/mmcblk0 should be tuned in vendor/init.rc
+ write /sys/devices/virtual/block/${dev.mnt.blk.data}/queue/discard_max_bytes 134217728
+
# Permissions for System Server and daemons.
chown system system /sys/power/autosleep