public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Tomas Alvarez Vanoli <tomas.alvarez-vanoli@hitachienergy.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: [BUG] UBIFS corruption on powerpc 32-bit targets
Date: Wed, 11 Feb 2026 14:58:36 +0800	[thread overview]
Message-ID: <abfe8c37-11ea-a76d-5aea-014b39fcdf2e@huawei.com> (raw)
In-Reply-To: <DB9PR06MB78496CB06BF8E60582CF40F7C262A@DB9PR06MB7849.eurprd06.prod.outlook.com>

在 2026/2/11 0:40, Tomas Alvarez Vanoli 写道:
>> Is the ubifs mounted in readonly mode in 4.14?
>> If not, the do_kill_orphan process will be committed on flash.
> 
> No, it is not read only.
> 
>> The commit 3af2d3a8c56fe7dc24f60c4df0ab85b7ac941902("ubifs: Fix
>> unattached inode when powercut happens in creating") [v6.11] is
>> introduced between 6.1 and 6.12, which will add every inode into orphan
>> area at the begining of creation.
> 
> By creation you mean the first occurence of it or whenever there's an update?
> 
> If I understand correctly, what you suggest is that it's possible that as
> the new inode is added to orphan area and the board is reset and booted into the
> older kernel, which then cleans all the orphans even if they have link count,
> leaving the fs broken?
> 
> So, in other words, my understanding of what you say is that for
> 3af2d3a8c56fe7dc24f60c4df0ab85b7ac941902 to not break anything, any kernel that
> mounts the same partition needs ee1438ce5dc4d67dd8dd1ff51583122a61f5bd9e and
> 4ab25ac8b2b5514151d5f91cf9514df08dd26938 .

Correct.
> 
>> So, you may try option  1 or 2 and check whether the problem could happen:
>> 1. mount 4.14 readonly
>> 2. backport fix patches on 4.14
> 
> Potentially also replacing the 4.14 application with an application based on
> 6.1?

What does 'application' mean?
> 
> I am also interested in consistently reproducing this at my desk. I have been
> tinkering with adding a message + a 10 second delay at points in the ubifs code
> so that I can reset the board and boot the old kernel to trigger this behaviour.
> Would you know at which exact point/conditions it would make sense to add this?
> Or is it not possible?
> I do not fully understand your theory, I have read the docs for the fs but I
> have little experience with filesystem implementation in general, so I am not
> sure how feasible this "hack" is.

Apply following patch in 6.12:


Apply following patch in 4.14:


Run:
start kernel 6.12
$ touch $MNT/file # cmd will stuck, $MNT is the ubifs mntpoint
$ dmesg # you will see kernel message 'wait sync and write orphans', 
open another terminal
$ sync # open another terminal, you will see kernel message 'write 
orphan XX', and the 'touch' cmd goes on
$ dd if=/dev/mtd0 of=flash bs=1M
$ sync and poweroff

start kernel 4.14
$ flash_eraseall /dev/mtd0
$ dd if=flash of=/dev/mtd0 bs=1M # make sure mtd0 is not attached by ubi
$ ubiattach -m0
$ mount /dev/ubi0_0 temp # dmesg will show 'remove ino XX'
$ ls temp
ls: cannot access 'temp/file': No such file or directory
file
$ dmesg
[   69.200639] UBIFS error (ubi0:0 pid 1587): ubifs_iget [ubifs]: failed 
to read inode 65, error -2
[   69.206214] UBIFS error (ubi0:0 pid 1587): ubifs_lookup [ubifs]: dead 
directory entry 'file', error -2
[   69.207482] UBIFS warning (ubi0:0 pid 1587): ubifs_ro_mode [ubifs]: 
switched to read-only mode, error -2
[   69.208783] CPU: 2 PID: 1587 Comm: ls Not tainted 
4.19.90-00006-g332043630ae1-dirty #50
[   69.209837] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 
04/01/2014
[   69.211545] Call Trace:
[   69.211921]  dump_stack+0xb8/0xef
[   69.212370]  ubifs_ro_mode+0x54/0x60 [ubifs]
[   69.212950]  ubifs_lookup+0x3b6/0x550 [ubifs]
[   69.213535]  __lookup_slow+0x9e/0x210
[   69.214045]  lookup_slow+0x46/0x70
[   69.214491]  walk_component+0x265/0x4c0
[   69.215013]  path_lookupat.isra.0+0x9e/0x360
[   69.215588]  filename_lookup+0xb5/0x230
[   69.216107]  ? _raw_spin_unlock_irqrestore+0x3f/0x80
[   69.216769]  ? __this_cpu_preempt_check+0x17/0x20
[   69.217386]  ? __local_bh_enable_ip+0x62/0x110
[   69.218038]  ? _raw_spin_unlock_bh+0x2e/0x40
[   69.218761]  ? wb_wakeup_delayed+0x56/0x90
[   69.219301]  ? kmem_cache_alloc+0x110/0x3d0
[   69.219852]  user_path_at_empty+0x43/0x60
[   69.220391]  vfs_statx+0x90/0x150
[   69.220847]  ? __sb_end_write+0x5f/0xb0
[   69.221354]  __se_sys_newlstat+0x46/0xa0
[   69.221892]  ? __se_sys_getdents+0xe0/0x1c0
[   69.222465]  ? filldir64+0x340/0x340
[   69.222958]  __x64_sys_newlstat+0x1a/0x30
[   69.223499]  do_syscall_64+0x95/0x460
[   69.224004]  ? prepare_exit_to_usermode+0xaa/0x180
[   69.224652]  entry_SYSCALL_64_after_hwframe+0x5c/0xc1

> 
> Thanks for all your support!
> Best regards,
> Tomas
> .
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2026-02-11  6:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 10:30 [BUG] UBIFS corruption on powerpc 32-bit targets Tomas Alvarez Vanoli
2026-01-30  1:34 ` Zhihao Cheng
2026-02-03  9:12   ` Tomas Alvarez Vanoli
2026-02-04  4:54     ` Zhihao Cheng
2026-02-04 14:04       ` Tomas Alvarez Vanoli
2026-02-05  2:14         ` Zhihao Cheng
2026-02-05 15:47           ` Tomas Alvarez Vanoli
2026-02-06  2:21             ` Zhihao Cheng
2026-02-06 16:14               ` Tomas Alvarez Vanoli
2026-02-07  2:58                 ` Zhihao Cheng
2026-02-09 15:45                   ` Tomas Alvarez Vanoli
2026-02-10  2:38                     ` Zhihao Cheng
2026-02-10 16:40                       ` Tomas Alvarez Vanoli
2026-02-11  6:58                         ` Zhihao Cheng [this message]
2026-02-11  7:01                           ` Zhihao Cheng
2026-02-11 16:51                             ` Tomas Alvarez Vanoli
2026-02-12  1:19                               ` Zhihao Cheng
2026-02-12 15:43                                 ` Tomas Alvarez Vanoli
2026-02-13  1:16                                   ` Zhihao Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abfe8c37-11ea-a76d-5aea-014b39fcdf2e@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=tomas.alvarez-vanoli@hitachienergy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox