Here is the snippet about why UBIFS suddenly became read-only from Linux MTD forum and how to check.
UBIFS suddenly became read-only - what is this?
Read-write UBIFS file-system may suddenly become read-only because of an error. This is how UBIFS reacts on unexpected errors which it cannot properly handle - it immediately switches to read-only mode in order to protect the data from any possible further corruption.
If this happened, you should look at UBIFS-related
dmesg messages. UBIFS usually prints error messages before switching to read-only mode. The messages may shed some light on what happened. Feel free to ask for help from the MTD mailing list. If you think this is an UBIFS bug, please, send a bug report.
How do I detect if UBIFS became read-only?
If you use up-to-date UBIFS which includes commit
UBIFS: mark VFS SB RO too ), then you should be able to find this out from
/proc/mounts . You should also be able to use something like
inotify to catch events when UBIFS becomes R/O (e.g., due to some errors).
Still this answer from forum doesn’t locate the exact code location in UBIFS driver that make UBIFS read-only when it faces any non-recoverable error and even doesn’t tell what non-recoverable errors are there.
Looking into kernel sources, I could locate the UBIFS kernel codes related with the non-recoverable errors that set UBIFS read-only mode as follows.
- If the read-only happened following any base station reboot or manual power cycle reboot, then it might be related mostly with Journaling, I/O related errors.
- Otherwise i.e. it happened following the progressively happening file-system full, it might be related with commit errors or possibly I/O, journaling too.
- error in do_commit() – logical block to physical block commit
ubifs_err(c, “commit failed, error %d”, err)
- error in ubifs_bg_thread()
err = ubifs_bg_wbufs_sync©;
*ubifs_bg_wbufs_sync - synchronize write-buffers.
- error in ubifs_leb_write()
ubifs_err(c, “writing %d bytes to LEB %d:%d failed, error %d”,len, lnum, offs, err);
- error in ubifs_leb_change()
ubifs_err(c, “changing %d bytes in LEB %d failed, error %d”, len, lnum, err);
- error in ubifs_leb_unmap()
ubifs_err(c, “unmap LEB %d failed, error %d”, lnum, err);
- error in ubifs_leb_map()
ubifs_err(c, “mapping LEB %d failed, error %d”, lnum, err);
- error in next_sqnum()
- next_sqnum - get next sequence number
ubifs_err(c, “sequence number overflow %llu, end of life”, sqnum);
- error in ubifs_bg_wbufs_sync()
- ubifs_bg_wbufs_sync - synchronize write-buffers
ubifs_err(c, “cannot sync write-buffer, error %d”, err);
- error in ubifs_sync_wbufs_by_inode()
- ubifs_sync_wbufs_by_inode - synchronize write-buffers for an inode
err = ubifs_wbuf_sync_nolock()
*ubifs_wbuf_sync_nolock - synchronize write-buffer.
- error in ubifs_jnl_update()
- ubifs_jnl_update - update inode
- error in ubifs_jnl_write_data()
*ubifs_jnl_write_data - write a data node to the journal
- error in ubifs_jnl_write_inode()
- ubifs_jnl_write_inode - flush inode to the journal
- error in ubifs_jnl_delete_inode()
*ubifs_jnl_delete_inode - delete an inode
- error in ubifs_jnl_rename()
- ubifs_jnl_rename - rename a directory entry
- error in ubifs_jnl_truncate()
- ubifs_jnl_truncate - update the journal for a truncation
- error in ubifs_jnl_delete_xattr()
- ubifs_jnl_delete_xattr - delete an extended attribute
- error in ubifs_jnl_change_xattr()
- ubifs_jnl_change_xattr - change an extended attribute