
Hi,
I have a customer who has a NAND device with two MTD partitions and each of the partitions contains one UBI volume with a UBIFS filesystem.
Now U-Boot can mount the UBIFS from the first partition just fine, but if the UBIFS from the second partition is mounted afterwards this fails in some cases.
I can reproduce the error and tracked it down to uboot_ubifs_mount() in fs/ubifs/super.c. If this function is run for the second mount, the struct ubifs_fs_type is reused and it contains a list fs_supers, that still holds one entry for the first mount.
I guess, that if the second mount would happen on a volume that is on the same MTD partition as the first volume, than this will work. The second entry is added to ubifs_fs_type.fs_supers.
In my case however, the second entry being added to ubifs_fs_type.fs_supers is invalid and causes the mount error.
Reinitializing the list in uboot_ubifs_mount() before each mount, solves the problem, but I guess that it will cause failures in other setups, where there are actually multiple volumes on one MTD device.
So how can I solve this properly? Do we need one instance of struct ubifs_fs_type for each MTD device?
I tested this on an old version (2017.03), but looking at the current code, it looks like the same problem applies to current mainline.
Thanks for any help and suggestions! Frieder