diff options
author | Christopher Haster <chaster@utexas.edu> | 2017-05-14 20:01:45 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2017-05-15 08:40:56 +0300 |
commit | fd1da602d77a812c15db8113960517ac99f5f6f7 (patch) | |
tree | d8a464fb4f92a564ef54832f5b4c2538e96ce62c /lfs.h | |
parent | b35d7611964d1470409269bf25e3499721dcbe7d (diff) |
Added support for handling corrupted blocks
This provides a limited form of wear leveling. While wear is
not actually balanced across blocks, the filesystem can recover
from corrupted blocks and extend the lifetime of a device nearly
as much as dynamic wear leveling.
For use-cases where wear is important, it would be better to use
a full form of dynamic wear-leveling at the block level. (or
consider a logging filesystem).
Corrupted block handling was simply added on top of the existing
logic in place for the filesystem, so it's a bit more noodly than
it may have to be, but it gets the work done.
Diffstat (limited to 'lfs.h')
-rw-r--r-- | lfs.h | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -43,7 +43,7 @@ enum lfs_error { enum lfs_type { LFS_TYPE_REG = 0x01, LFS_TYPE_DIR = 0x02, - LFS_TYPE_SUPERBLOCK = 0x10, + LFS_TYPE_SUPERBLOCK = 0x12, }; enum lfs_open_flags { @@ -193,15 +193,16 @@ typedef struct lfs_superblock { struct lfs_disk_superblock { uint16_t type; uint16_t len; + lfs_block_t root[2]; uint32_t version; char magic[8]; uint32_t block_size; uint32_t block_count; - lfs_block_t root[2]; } d; } lfs_superblock_t; typedef struct lfs_free { + lfs_block_t end; lfs_block_t start; lfs_block_t off; uint32_t *lookahead; @@ -212,8 +213,8 @@ typedef struct lfs { const struct lfs_config *cfg; lfs_block_t root[2]; - lfs_dir_t *scratch; lfs_file_t *files; + bool deorphaned; lfs_cache_t rcache; lfs_cache_t pcache; @@ -257,8 +258,8 @@ int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file); lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file); // miscellaneous lfs specific operations -int lfs_deorphan(lfs_t *lfs); int lfs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); +int lfs_deorphan(lfs_t *lfs); #endif |