[LEDE-DEV] [PATCH fstools] overlay: fix race condition when switching to jffs2
Roman Yeryomin
roman at advem.lv
Sun Jan 7 10:05:46 PST 2018
On 2018-01-03 22:54, Hauke Mehrtens wrote:
> On 12/15/2017 03:10 PM, Roman Yeryomin wrote:
>> There is a race between `cp -a /tmp/root/* /rom/overlay` from
>> libfstools/overlay.c and a process creating new file(s) before
>> pivot(/rom, /mnt) occured.
>> That is a process can create a file and it will not be copied.
>>
>> To workaround this, do additional copy after jffs2 is ready.
>> This doesn't completely solve the problem but since there
>> was no other fix provided since original RFC [1], it is better
>> than nothiing.
>>
>> [1]
>> https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg38218.html
>>
>> Signed-off-by: Roman Yeryomin <roman at advem.lv>
>> ---
>> libfstools/overlay.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/libfstools/overlay.c b/libfstools/overlay.c
>> index 7ada5ff..8423a57 100644
>> --- a/libfstools/overlay.c
>> +++ b/libfstools/overlay.c
>> @@ -243,6 +243,10 @@ jffs2_switch(struct volume *v)
>> ULOG_INFO("performing overlay whiteout\n");
>> umount2("/tmp/root", MNT_DETACH);
>> foreachdir("/overlay/", handle_whiteout);
>> +
>> + /* try hard to be in sync */
>> + ULOG_INFO("syncronizing overlay\n");
>> + system("cp -a /tmp/root/upper/* / 2>/dev/null");
>> break;
>>
>> case FS_EXT4:
>>
>
> This patch causes the following compile problem when compiled with
> glibc
> on x86:
>
> [ 50%] Building C object CMakeFiles/fstools.dir/libfstools/overlay.c.o
> /home/hauke/openwrt/lede/build_dir/target-x86_64_glibc/fstools-2018-01-02-11efbf3b/libfstools/overlay.c:
> In function 'jffs2_switch':
> /home/hauke/openwrt/lede/build_dir/target-x86_64_glibc/fstools-2018-01-02-11efbf3b/libfstools/overlay.c:249:3:
> warning: ignoring return value of 'system', declared with attribute
> warn_unused_result [-Wunused-result]
> system("cp -a /tmp/root/upper/* / 2>/dev/null");
> ^
> /home/hauke/openwrt/lede/build_dir/target-x86_64_glibc/fstools-2018-01-02-11efbf3b/libfstools/overlay.c:
> At top level:
> cc1: error: unrecognized command line option '-Wno-format-truncation'
> [-Werror]
> cc1: all warnings being treated as errors
> CMakeFiles/fstools.dir/build.make:110: recipe for target
> 'CMakeFiles/fstools.dir/libfstools/overlay.c.o' failed
>
Patch sent to list, thanks!
Regards,
Roman
More information about the Lede-dev
mailing list