Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support no validation to improve write performance #381

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int lfs_bd_flush(lfs_t *lfs,
return err;
}

if (validate) {
if (lfs->cfg->validate >= 0 && validate) {
// check data on disk
lfs_cache_drop(lfs, rcache);
int res = lfs_bd_cmp(lfs,
Expand Down Expand Up @@ -3593,14 +3593,14 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
".lookahead_size=%"PRIu32", .read_buffer=%p, "
".prog_buffer=%p, .lookahead_buffer=%p, "
".name_max=%"PRIu32", .file_max=%"PRIu32", "
".attr_max=%"PRIu32"})",
".attr_max=%"PRIu32", .validate=%"PRIu32"})",
(void*)lfs, (void*)cfg, cfg->context,
(void*)(uintptr_t)cfg->read, (void*)(uintptr_t)cfg->prog,
(void*)(uintptr_t)cfg->erase, (void*)(uintptr_t)cfg->sync,
cfg->read_size, cfg->prog_size, cfg->block_size, cfg->block_count,
cfg->block_cycles, cfg->cache_size, cfg->lookahead_size,
cfg->read_buffer, cfg->prog_buffer, cfg->lookahead_buffer,
cfg->name_max, cfg->file_max, cfg->attr_max);
cfg->name_max, cfg->file_max, cfg->attr_max, cfg->validate);
int err = lfs_init(lfs, cfg);
if (err) {
LFS_TRACE("lfs_mount -> %d", err);
Expand Down
9 changes: 8 additions & 1 deletion lfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ extern "C"
#define LFS_DISK_VERSION_MAJOR (0xffff & (LFS_DISK_VERSION >> 16))
#define LFS_DISK_VERSION_MINOR (0xffff & (LFS_DISK_VERSION >> 0))


/// Definitions ///

// Type definitions
Expand Down Expand Up @@ -240,6 +239,14 @@ struct lfs_config {
// larger attributes size but must be <= LFS_ATTR_MAX. Defaults to
// LFS_ATTR_MAX when zero.
lfs_size_t attr_max;

// Whether read and validate after writing. The positive number means
// enable while the negative number means disable. The zero means
// enable for compatible. It can imporve write performance if no
// validation, but drivers must ensure data integrity.
int validate;
#define LFS_ENABLE_VALIDATE 1
#define LFS_DISABLE_VALIDATE -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these defines up to? It looks like they're unused.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are defined for user to assign option validate. To me, using these macro is more clarity than number.

};

// File info structure
Expand Down