ubifs: corrupted dirent (ENOENT), problably related to O_TMPFILE and linkat

Sebastian Gross sebastian.gross at emlix.com
Thu Aug 12 05:01:38 PDT 2021


Hi all,

On 7/27/21 11:06 PM, Richard Weinberger wrote:
> On Thu, Jul 22, 2021 at 12:56 PM Sebastian Gross
> <sebastian.gross at emlix.com> wrote:
>>> Can you reproduce using a recent kernel?
I have finally been able to look into it.
For v5.13 the error on replay no longer occurs. The tmp file in question is there and happy.

I was able to create a sandbox with qemu, generic Debian 10 rootfs and nandsim.
A simple reproducer was as stated before:
- open(O_TMPFILE)
- write (some MB; at least 32 seemed to suffice)
- linkat
After that the wbuf has been synced according to dmesg
{{{
UBIFS DBG io (pid 1681): synchronize
UBIFS DBG io (pid 1681): LEB 7775:1024, 392 bytes, jhead 1 (base)
UBIFS DBG lp (pid 1681): LEB 7775, free 14456, dirty 864, flags 16
UBIFS DBG lp (pid 1681): LEB 7775, free 14336, dirty 984, flags 16
UBIFS DBG lp (pid 1681): LEB 7775, free 14456, dirty 864, flags 16
}}}

Powercut has been simulated by dumping mtd0 at this stage.

This left me with a ready to (RE-)use NAND image.

> But often it is more complicated. Especially when the bug is in the
> recovery code when the filesystem
> is mounted the next time.
This seems to actually be the case.

> If you enable /sys/kernel/debug/ubifs/chk_fs, it will do a full scan
> upon mount time.
 > This can detect such problems. But not fix them.

Much appreciated, thanks. This did in fact discover the missing inode though the dirent was there (ls did work, ls -l not).

(On a related note the local ubifs_debug_info has also an entry for chk_fs but it will never be used :\)


With the method above I was able to "poor-man's" bisect the minor kernel versions.

The replay was fixed in v5.3. From there I bisected down to ee1438ce5dc4d67dd8dd1ff51583122a61f5bd9e.
This one might be a candidate to integrate into the LTS branches.

For 4.19.202 I had to pull in 988bec41318f3fa897e2f8af271bd456936d6caf also.


TYVM for your support so far

Kind regards


Sebastian

-- 
B.Sc. Sebastian Groß, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11,
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke
Ust-IdNr.: DE 205 198 055

emlix - your embedded linux partner



More information about the linux-mtd mailing list