Skip to content

Multiversion data corruption #1167

@vrjtikonen

Description

@vrjtikonen

Hi, I don't know if what we're doing is supported but reporting in case this is a bug.
We have a following situation.

Filesystem has been created with LittleFS 2.5.0.
Library build flags LFS_NO_MALLOC.

// Major (top-nibble), incremented on backwards incompatible changes
// Minor (bottom-nibble), incremented on feature additions
#define LFS_VERSION 0x00020005
#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >>  0))

// Version of On-disk data structures
// Major (top-nibble), incremented on backwards incompatible changes
// Minor (bottom-nibble), incremented on feature additions
#define LFS_DISK_VERSION 0x00020000
#define LFS_DISK_VERSION_MAJOR (0xffff & (LFS_DISK_VERSION >> 16))
#define LFS_DISK_VERSION_MINOR (0xffff & (LFS_DISK_VERSION >>  0))

The we upgraded code to use LittleFS 2.11.2
Library build flags LFS_NO_MALLOC and LFS_MULTIVERSION

// Major (top-nibble), incremented on backwards incompatible changes
// Minor (bottom-nibble), incremented on feature additions
#define LFS_VERSION 0x0002000b
#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >>  0))

// Version of On-disk data structures
// Major (top-nibble), incremented on backwards incompatible changes
// Minor (bottom-nibble), incremented on feature additions
#define LFS_DISK_VERSION 0x00020001
#define LFS_DISK_VERSION_MAJOR (0xffff & (LFS_DISK_VERSION >> 16))
#define LFS_DISK_VERSION_MINOR (0xffff & (LFS_DISK_VERSION >>  0))

Reproduction (not sure if this is the minimal but it triggers the problem always):

  1. Format file system in v2.5.0. Create directories e.g. "/a" and /b"
  2. Mount file system in v2.11.2.
  3. Write a file in directory a. e.g. "/a/x.bin"
  4. Rename it to the other directory "/a/x.bin" -> "/b/x.bin"
  5. And finally delete the file "/b/x.bin".
  6. Attempt to mount file system with v2.5.0.

What happens:
lfs_mount returns error -84, filesystem corrupted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions