This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

what is the possible cases that Inode gets deleted



hi,

I am using SD-card for booting linux, i have created one partition for boot and one for rootfs and tried both EXT2 and EXT3 fs, but the problem is inode reference gets deleted and its trowing message as: 

EXT2-fs (mmcblk0p2): error: ext2_lookup: deleted inode referenced: 161612.

The thing is in our board we directly switch off the board using a switch, as i am thinking its the problem of power cycling, later i tried to switch off using software also both the cases we are facing same issue, but the issue is not repeatedly happening.

This problem is heavy while we deal with mini USB, buy using cable we connect to the host system after the boot, then if we transfer any file to rootfs using mini USB, the changes dosent reflect in the rootfs as that we observe that through URAT,  "g_file_storage file" module is using for the mini Usb 

I want to know the other reasons of this problem and also the possible remedy for this issue. 

Thank you,

Sreenivas

  • Directly turn off power right after writing data to rootfs definitely will corrupt the filesystem.

    Is it possible you can run 'sync' command before using software to turn off the board?

  • Hi Bin Liu,

    Thanks for the reply,

    Actually we are using just a switch to on and off the board, so we cant use the sync command before power off, i have tried to directly mount the rootfs with sync option by specifying  sync in /etc/fstab file, by using this the board has successfully booted but the problem is when ever i connect mini usb to host total file system gets corrupted, showing a message that inode deleted.

    can any body tell why this happening, i am not able to under stand that whether the problem with file system or g_file_storage module which is used for mini usb. 

    is there any way to place sync option to g_file_storage module that in the host when ever we write something it gets directly reflected in to SD-Card not to the I/O caches.

    Thank you,

    Sreenivas

  • What is the parameter passed to g_file_storage driver? I guess it is /dev/mmcblk0p2, which is the partition of the root filesystem. If it is the case, you cannot do this way, because the partition passed into g_file_storage will be modified by host without synchronization with the system on your board, that will cause corruption, it has nothing to do with the power cycle, I think.

    You can only give the partition which is not mounted to your local filesystem to g_file_storage driver.

  • yes Mr.Bin Liu, what you said was correct, i am passing file=/dev/mmcblk0p2 as a argument to the g_file_storage driver which is the partition of  rootfs.

    My intention is when ever if any changes required in the file system, with out removing the SD-Card from the board, by using Mini USB i want to do modifications in the file system, to do this i have used g_file_storage driver.

    Is there any way to make the partition sync which is passed to g_file_storage?  

    or is there any other driver or any possible way which can do this...

    Thank you,

    Sreenvias

  • Sreenias,

    There are many ways to archive that. But before giving further comments, I'd like to understand more about your usb use case.

    1. What are the files transferred from host to your system on /dev/mmcblk0p2? Are they part of the root filesystem or user data files?

    2. Is this transfer is only used for project development or is it a functionality in the final product?

  • Hi Bin Liu,

    we want to transfer the files regarding applications like matrix-gui etc..

    at present this transfer is only used for project development, in the future we want to implement this for final product also.

    As you said there are may ways, can u please let me know 2 or 3 ways to achieve it, so that i can select best way to implement this.

    Thank you,

    Sreenivas.

  • Ok, you are trying to update the root filesystem in runtime. Please keep in mind that the root filesystem should not be modified by two different systems simultaneously without synchronization, or corruption might happen.

    Updating rootfs in development is kind of simple because you know what you are doing and the solution does not have to be fail-safe.

    because /dev/mmcblk0p2 is a running rootfs and cannot be unmounted, so you cannot directly pass it to g_file_storage. But one thing you can do is create one more partition (/dev/mmcblk0p3), unmount it from rootfs and pass it when loading g_file_storage; after transfered the file from host to mmcblk0p3, disconnect from host USB port, mount mmcblk0p3 to rootfs, and copy the file to the right location. In this solution, /dev/mmcblk0p3 is not accessed by rootfs and host pc simultaneously, so no corruption.

    If you cannot create the extra partition, you can create a loopback file which is big enough to hold the files to be transfered, and pass it to g_file_storage.

    A side note is that you might consider using g_mass_storage instead. g_file_storage is deprecated in newer kernel.

    In final product it is kind of complicated because you have to keep the whole thing transparent to end user and it has to be fail-safe.

    I would think you either have to implement something in application to wrap the procedure mentioned above, or use some methods like dual system to update one from another.

  • Hi Bin Liu,

    Thanks for giving the idea of using loop back file, can we directly pass the loop back file as a argument to g_file_storage.

    and one thing i dint get is what is dual system to update, can you please elaborate this.

    Thank you.

  • I don't have the instruction ready for how to use the loopback file. But if you search on the Internet, you should be able to find plenty of the info.

    Regarding the dual system, you have to have two systems populated on the board. For example, one is for normal operation (#1), another is for recovery (#2).

    In normal use, the system always use system #1, but when the system needs update, reboot it then hold on a special button (for example, power or volume button), then the system will boots into recovery mode (#2), and the system #1 is not mounted, so the recovery system can update the normal system in whatever way you want.

    Another implementation could be that both system can be used equally. Then the running system update the other one, then set some flags indicating another system is updated successfully. Then the system will reboot into the updated system by reading the flags. In this case, you have to have some flags in a global area, where both bootloader and kernel can access. The flags will tell about status of each system.

  • Hi Bin Liu,

    Thank you for the superb ideas of dual partition and also the loop back file,

    First i will go with loop back file type and then i will go with dual partition.

    Sreenivas