1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-06-16 20:23:53 +02:00
openwrt/package/base-files/files/etc
Rafał Miłecki f44f8b07b0 base-files: call "sync" after initial setup
OpenWrt uses a lot of (b)ash scripts for initial setup. This isn't the
best solution as they almost never consider syncing files / data. Still
this is what we have and we need to try living with it.

Without proper syncing OpenWrt can easily get into an inconsistent state
on power cut. It's because:
1. Actual (flash) inode and data writes are not synchronized
2. Data writeback can take up to 30 seconds (dirty_expire_centisecs)
3. ubifs adds extra 5 seconds (dirty_writeback_centisecs) "delay"

Some possible cases (examples) for new files:
1. Power cut during 5 seconds after write() can result in all data loss
2. Power cut happening between 5 and 35 seconds after write() can result
   in empty file (inode flushed after 5 seconds, data flush queued)

Above affects e.g. uci-defaults. After executing some migration script
it may get deleted (whited out) without generated data getting actually
written. Power cut will result in missing data and deleted file.

There are three ways of dealing with that:
1. Rewriting all user-space init to proper C with syncs
2. Trying bash hacks (like creating tmp files & moving them)
3. Adding sync and hoping for no power cut during critical section

This change introduces the last solution that is the simplest. It
reduces time during which things may go wrong from ~35 seconds to
probably less than a second. Of course it applies only to IO operations
performed before /etc/init.d/boot . It's probably the stage when the
most new files get created.

All later changes are usually done using smarter C apps (e.g. busybox or
uci) that creates tmp files and uses rename() that is expected to be
atomic.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
(cherry picked from commit 9851d4b6ce)
2022-03-14 08:51:02 +01:00
..
board.d base-files: remove default /etc/config/network, generate it via board.d instead 2016-01-25 16:30:41 +00:00
hotplug.d/net base-files: evaluate /etc/sysctl.d/* before /etc/sysctl.conf 2018-04-13 10:16:45 +02:00
init.d base-files: call "sync" after initial setup 2022-03-14 08:51:02 +01:00
iproute2 base-files: install missing /etc/iproute2/ematch_map 2018-12-19 07:33:35 +01:00
rc.button base-files: add reboot only button handler 2019-05-30 11:55:49 +02:00
sysctl.d base-files: enable BPF JIT sysctl by default 2019-02-11 20:18:48 +00:00
uci-defaults base-files: replace backticks by $(...) 2020-07-11 12:52:01 +02:00
banner merge: release/banner: drop release name and update banner 2017-12-08 19:41:18 +01:00
banner.failsafe base-files: fix links in banner.failsafe 2018-06-18 07:10:15 +02:00
device_info base-files: add URL option for OEM manufacturer info 2015-10-05 10:28:53 +00:00
diag.sh base-files: diag: restore default trigger for 'boot' LED 2020-02-24 23:27:50 +01:00
ethers base-files: create /etc/ethers by default 2018-08-21 15:55:00 +02:00
fstab base-files: remove fstab symlink 2016-06-17 04:13:07 +02:00
group base-files/hotplug: fix dedicated group for tty devices 2019-04-04 17:09:40 +02:00
hosts base-files: add /etc/hosts entries for ::1, ff02::1 and ff02::2 2015-09-02 11:54:03 +00:00
inittab image / basefiles: make console password configurable 2016-04-18 21:53:07 +02:00
openwrt_release merge: properly remove %n / %N references 2017-12-09 16:01:14 +01:00
openwrt_version build: adjust version number handling 2016-12-02 16:02:02 +01:00
os-release base-files: Add standard os-release file 2016-06-24 13:52:53 +02:00
passwd base-files: prime root password with "x" to notify programs that there is a shadow record, fix /bin/login.sh password detection accordingly. Solves broken key based dropbear login with empty password after r28935. 2011-11-14 19:02:01 +00:00
preinit preinit: use only the image config options 2016-08-10 03:04:08 +02:00
profile base-files: Add /etc/shinit for non-login shell init 2020-03-01 21:35:59 +01:00
protocols base-files: add DCCP to /etc/protocols 2015-11-15 22:09:13 +00:00
rc.common base-files: fix service_running check 2021-12-29 21:40:40 +01:00
rc.local base-files: introduce a ready-to-use /etc/rc.local to let users run custom commands on init without creating custom init scripts 2009-09-11 21:35:03 +00:00
services base-files: /etc/services: add missing 'rpcbind' alias 2018-09-10 10:44:03 +02:00
shadow the root password should be empty for real, like before 2014-02-21 10:39:14 +00:00
shells rename default/ to files/ 2006-11-22 23:30:57 +00:00
shinit base-files: shinit: properly handle dashes in service names 2021-05-12 12:45:38 +02:00
sysctl.conf base-files: move sysctl defaults to /etc/sysctl.d/10-default.conf 2018-04-13 10:16:45 +02:00
sysupgrade.conf base-files: - add sysupgrade support for keepfile hints * introduces /lib/upgrade/keep.d/ for per-package keepfile lists * introduces /etc/sysupgrade.conf for user defined keepfile hints - prime /lib/upgrade/keep.d/base-files-essential to keep sysupgrade usable for images without opkg - change sysupgrade to build the keepfile list from /lib/upgrade/keep.d/, /etc/sysupgrade.conf and opkg list-changed-conffiles 2010-10-05 19:24:12 +00:00