Skip to content

Commit f6c0e04

Browse files
committed
zms: remove non needed lookup cache before writing
When the CONFIG_ZMS_NO_DOUBLE_WRITE is not enabled there is no need to search in the cache for matching ID Signed-off-by: Riadh Ghaddab <[email protected]>
1 parent 4658dc2 commit f6c0e04

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

subsys/fs/zms/zms.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,8 +1392,6 @@ ssize_t zms_write(struct zms_fs *fs, uint32_t id, const void *data, size_t len)
13921392
{
13931393
int rc;
13941394
size_t data_size;
1395-
uint64_t wlk_addr;
1396-
uint64_t rd_addr;
13971395
uint32_t gc_count;
13981396
uint32_t required_space = 0U; /* no space, appropriate for delete ate */
13991397

@@ -1414,19 +1412,19 @@ ssize_t zms_write(struct zms_fs *fs, uint32_t id, const void *data, size_t len)
14141412
return -EINVAL;
14151413
}
14161414

1415+
#ifdef CONFIG_ZMS_NO_DOUBLE_WRITE
14171416
/* find latest entry with same id */
14181417
#ifdef CONFIG_ZMS_LOOKUP_CACHE
1419-
wlk_addr = fs->lookup_cache[zms_lookup_cache_pos(id)];
1418+
uint64_t wlk_addr = fs->lookup_cache[zms_lookup_cache_pos(id)];
14201419

14211420
if (wlk_addr == ZMS_LOOKUP_CACHE_NO_ADDR) {
14221421
goto no_cached_entry;
14231422
}
14241423
#else
14251424
wlk_addr = fs->ate_wra;
1426-
#endif
1427-
rd_addr = wlk_addr;
1425+
#endif /* CONFIG_ZMS_LOOKUP_CACHE */
1426+
uint64_t rd_addr = wlk_addr;
14281427

1429-
#ifdef CONFIG_ZMS_NO_DOUBLE_WRITE
14301428
/* Search for a previous valid ATE with the same ID */
14311429
struct zms_ate wlk_ate;
14321430
int prev_found = zms_find_ate_with_id(fs, id, wlk_addr, fs->ate_wra, &wlk_ate, &rd_addr);
@@ -1470,11 +1468,11 @@ ssize_t zms_write(struct zms_fs *fs, uint32_t id, const void *data, size_t len)
14701468
return 0;
14711469
}
14721470
}
1473-
#endif
1474-
14751471
#ifdef CONFIG_ZMS_LOOKUP_CACHE
14761472
no_cached_entry:
1477-
#endif
1473+
#endif /* CONFIG_ZMS_LOOKUP_CACHE */
1474+
#endif /* CONFIG_ZMS_NO_DOUBLE_WRITE */
1475+
14781476
/* calculate required space if the entry contains data */
14791477
if (data_size) {
14801478
/* Leave space for delete ate */

0 commit comments

Comments
 (0)