[OpenWrt-Devel] fstools: factory reset on power failure during startup
eckert.florian at googlemail.com
Mon Nov 30 04:35:26 EST 2015
i think the patch fixes the issue.
We could reproduce a factory reset with the dc/dc test very often
befor we apply your patch.
But now i think there is an other problem with ubifs! See log
The system fails at Saturday evening with this error
Press the [f] key and hit [enter] to enter failsafe mode
Press the , ,  or  key and hit [enter] to select the debug level
[ 7.184000] random: nonblocking pool is initialized
[ 10.236000] mount_root: Boot cmd:
[ 10.264000] UBIFS: background thread "ubifs_bgt0_1" started, PID 302
[ 10.288000] UBIFS: recovery needed
[ 10.292000] UBIFS error (pid 300): check_lpt_type: invalid type
(15) in LPT node type 2
[ 10.300000] CPU: 0 PID: 300 Comm: mount_root Not tainted 3.18.23 #37
[ 10.304000] Stack : 00000000 00000000 00000000 00000000 804e45f2
00000038 00000000 00000000
87bb9350 00000001 8041316c 80490b43 0000012c 804e382c 87bb9350 00000001
87013db8 87013dbc c01bd000 80055e54 00000006 8002d3e8 00000000 00000000
804179e8 87013d2c 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 10.340000] Call Trace:
[ 10.344000] [<800199a8>] show_stack+0x50/0x84
[ 10.348000] [<80161b88>] check_lpt_type.constprop.9+0x4c/0x60
[ 10.352000] [<80163bc0>] ubifs_lpt_init+0x148/0x4e8
[ 10.360000] [<8014adc8>] ubifs_mount+0xfec/0x1794
[ 10.364000] [<800cba38>] mount_fs+0x20/0xdc
[ 10.368000] [<800e4634>] vfs_kern_mount+0x64/0x138
[ 10.372000] [<800e7f74>] do_mount+0x95c/0xb20
[ 10.376000] [<800e8478>] SyS_mount+0x90/0xd4
[ 10.380000] [<8000875c>] handle_sys+0x11c/0x140
[ 10.388000] UBIFS: background thread "ubifs_bgt0_1" stops
[ 10.392000] mount_root: failed to mount -t ubifs /dev/ubi0_1
/tmp/overlay: Invalid argument
[ 10.400000] mount_root: TDT readlink return value of file
/tmp/overlay/.fs_state is -1
[ 10.408000] mount_root: TDT readlink error string is ** No such
file or directory **
[ 10.416000] mount_root: TDT actual filystem state is 0
[ 10.420000] mount_root: TDT readlink return value of file
/tmp/overlay/.fs_state is -1
[ 10.428000] mount_root: TDT readlink error string is ** No such
file or directory **
[ 10.436000] mount_root: TDT readlink return value of file
/tmp/overlay/.fs_state is 1
[ 10.444000] mount_root: overlay filesystem has not been fully initialized yet
[ 10.452000] mount_root: switching to jffs2 overlay
[ 10.456000] mount_root: TDT olddir /tmp/overlay failed: No such
file or directory
[ 10.464000] mount_root: switching to jffs2 failed - fallback to ramoverlay
[ 10.472000] mount_root: failed /rom/overlay /overlay: Invalid argument
[ 10.488000] procd: - early -
[ 10.492000] procd: - watchdog -
[ 11.212000] procd: - ubus -
[ 12.220000] procd: - init -
Please press Enter to activate this console.
I dont know if you are the right persons?
I think it has do to with the ubifs layer and not with your fstool.
2015-11-27 13:17 GMT+01:00 Florian Eckert <eckert.florian at googlemail.com>:
> I have tested your patch since last day when I got the patch from you.
> I am using an programmable dc/dc power supply, who switches the power
> between startup randomly.
> I will run the test during the weekend. And then I will see what
> happend on Monday morning.
> But for now i havn't lost the configuration anymore.
> 2015-11-26 14:25 GMT+01:00 Florian Eckert <eckert.florian at googlemail.com>:
>> thank your very much for your fast reply and the fix :-).
>> I will try it and give you an respond.
>> 2015-11-26 14:05 GMT+01:00 Felix Fietkau <nbd at openwrt.org>:
>>> On 2015-11-26 09:24, Florian Eckert wrote:
>>>> I am using openwrt CC and an ubifs filesystem on top of ubi.
>>>> If I plug off the power during startup, some times my configuration
>>>> get lost and i am back to factory reset.
>>>> In the package fstools there is the bin "mount_root" it is called
>>>> twice during startup.
>>>> 1. S10boot at line 10
>>>> 2. S95done at line 6
>>>> this calles edit the ./fs_state link
>>>> Because ubifs is doing filesystem handling in a background process
>>>> "ubi_bgt0d", could it be possible,
>>>> that (see code) ./.fs_state is not rewritten written anymore?
>>>> So that at next boot the system thinks he is in upgrade mode?
>>>> If I add a sleep(10) between unlink and symlink function call i can
>>>> reproduce the failure if i unplug the power.
>>>> I think the first think what should be done is to call
>>>> "snprintf(valstr, sizeof(valstr), "%d", state);" before "unlink(path).
>>>> Or this this a deeper Problem?
>>> I think you're right that there's a race here. When I wrote this code,
>>> I never actually intended for the file to get re-written after the
>>> first boot, it seems that I simply forgot to add the necessary check
>>> for it.
>>> Please test if this fstools patch fixes the problem:
>>> --- a/libfstools/overlay.c
>>> +++ b/libfstools/overlay.c
>>> @@ -311,6 +311,9 @@ int fs_state_set(const char *dir, enum fs_state state)
>>> char valstr;
>>> char *path;
>>> + if (fs_state_get(dir) == state)
>>> + return 0;
>>> path = alloca(strlen(dir) + 1 + sizeof("/.fs_state"));
>>> sprintf(path, "%s/.fs_state", dir);
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
More information about the openwrt-devel