mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Found during testing, the issue was with lfs_migrate in combination with wear leveling. Normally, we can expect lfs_migrate to be able to respect the user-configured block_cycles. It already has allocation information on which blocks are used by both v1 and v2, so it should be safe to relocate blocks as needed. However, this fell apart when root was relocated. If lfs_migrate found a root that needed migration, it would happily relocate the root. This would normally be fine, except relocating the root has a side-effect of needed to update the superblock. Which, during migration, is in a delicate state of containing both v1's and v2's superblocks in the same metadata pair. If the superblock ends up needing to compact, this would clobber the v1 superblock and corrupt the filesystem during migration. The best fix I could come up with is to specifically dissallow migrating the root directory during migration. Fortunately this is behind the LFS_MIGRATE macro, so the code cost for this check is not normally paid.
		
			
				
	
	
	
		
			142 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			142 KiB