Skip to content

Commit 42b9b5a

Browse files
rghaddabkartben
authored andcommitted
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 c0a75da commit 42b9b5a

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
@@ -1433,8 +1433,6 @@ ssize_t zms_write(struct zms_fs *fs, uint32_t id, const void *data, size_t len)
14331433
{
14341434
int rc;
14351435
size_t data_size;
1436-
uint64_t wlk_addr;
1437-
uint64_t rd_addr;
14381436
uint32_t gc_count;
14391437
uint32_t required_space = 0U; /* no space, appropriate for delete ate */
14401438

@@ -1455,19 +1453,19 @@ ssize_t zms_write(struct zms_fs *fs, uint32_t id, const void *data, size_t len)
14551453
return -EINVAL;
14561454
}
14571455

1456+
#ifdef CONFIG_ZMS_NO_DOUBLE_WRITE
14581457
/* find latest entry with same id */
14591458
#ifdef CONFIG_ZMS_LOOKUP_CACHE
1460-
wlk_addr = fs->lookup_cache[zms_lookup_cache_pos(id)];
1459+
uint64_t wlk_addr = fs->lookup_cache[zms_lookup_cache_pos(id)];
14611460

14621461
if (wlk_addr == ZMS_LOOKUP_CACHE_NO_ADDR) {
14631462
goto no_cached_entry;
14641463
}
14651464
#else
14661465
wlk_addr = fs->ate_wra;
1467-
#endif
1468-
rd_addr = wlk_addr;
1466+
#endif /* CONFIG_ZMS_LOOKUP_CACHE */
1467+
uint64_t rd_addr = wlk_addr;
14691468

1470-
#ifdef CONFIG_ZMS_NO_DOUBLE_WRITE
14711469
/* Search for a previous valid ATE with the same ID */
14721470
struct zms_ate wlk_ate;
14731471
int prev_found = zms_find_ate_with_id(fs, id, wlk_addr, fs->ate_wra, &wlk_ate, &rd_addr);
@@ -1511,11 +1509,11 @@ ssize_t zms_write(struct zms_fs *fs, uint32_t id, const void *data, size_t len)
15111509
return 0;
15121510
}
15131511
}
1514-
#endif
1515-
15161512
#ifdef CONFIG_ZMS_LOOKUP_CACHE
15171513
no_cached_entry:
1518-
#endif
1514+
#endif /* CONFIG_ZMS_LOOKUP_CACHE */
1515+
#endif /* CONFIG_ZMS_NO_DOUBLE_WRITE */
1516+
15191517
/* calculate required space if the entry contains data */
15201518
if (data_size) {
15211519
/* Leave space for delete ate */

0 commit comments

Comments
 (0)