@@ -61,6 +61,7 @@ static int settings_zms_dst(struct settings_zms *cf)
6161 return 0 ;
6262}
6363
64+ #ifndef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
6465static int settings_zms_unlink_ll_node (struct settings_zms * cf , uint32_t name_hash )
6566{
6667 int rc = 0 ;
@@ -119,6 +120,7 @@ static int settings_zms_unlink_ll_node(struct settings_zms *cf, uint32_t name_ha
119120
120121 return rc ;
121122}
123+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
122124
123125static int settings_zms_delete (struct settings_zms * cf , uint32_t name_hash )
124126{
@@ -131,7 +133,7 @@ static int settings_zms_delete(struct settings_zms *cf, uint32_t name_hash)
131133 if (rc < 0 ) {
132134 return rc ;
133135 }
134-
136+ #ifndef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
135137 rc = settings_zms_unlink_ll_node (cf , name_hash );
136138 if (rc < 0 ) {
137139 return rc ;
@@ -142,6 +144,7 @@ static int settings_zms_delete(struct settings_zms *cf, uint32_t name_hash)
142144 if (rc < 0 ) {
143145 return rc ;
144146 }
147+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
145148
146149 return rc ;
147150}
@@ -211,15 +214,26 @@ static int settings_zms_load(struct settings_store *cs, const struct settings_lo
211214 ZMS_NAME_HASH_ID (ll_hash_id ) + ZMS_DATA_ID_OFFSET );
212215
213216 if ((rc1 <= 0 ) || (rc2 <= 0 )) {
214- /* Settings item is not stored correctly in the ZMS.
215- * ZMS entry for its name or value is either missing
216- * or deleted. Clean dirty entries to make space for
217- * future settings item.
217+ /* In case we are not updating the linked list, this is an empty mode
218+ * Just continue
219+ */
220+ #ifndef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
221+ /* Otherwise, Settings item is not stored correctly in the ZMS.
222+ * ZMS entry for its name or value is either missing or deleted.
223+ * Clean dirty entries to make space for future settings item.
218224 */
219225 ret = settings_zms_delete (cf , ZMS_NAME_HASH_ID (ll_hash_id ));
220226 if (ret < 0 ) {
221227 return ret ;
222228 }
229+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
230+ /* update next ll_hash_id */
231+ ret = zms_read (& cf -> cf_zms , ll_hash_id , & settings_element ,
232+ sizeof (struct settings_hash_linked_list ));
233+ if (ret < 0 ) {
234+ return ret ;
235+ }
236+ ll_hash_id = settings_element .next_hash ;
223237 continue ;
224238 }
225239
@@ -287,7 +301,7 @@ static int settings_zms_save(struct settings_store *cs, const char *name, const
287301 }
288302#endif
289303
290- /* Let's find out if there is no hash collisions in the storage */
304+ /* Let's find out if there are hash collisions in the storage */
291305 write_name = true;
292306 hash_collision = true;
293307
@@ -363,6 +377,17 @@ static int settings_zms_save(struct settings_store *cs, const char *name, const
363377 if (rc < 0 ) {
364378 return rc ;
365379 }
380+ #ifdef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
381+ /* verify that the ll_node doesn't exist otherwise do not update it */
382+ rc = zms_read (& cf -> cf_zms , name_hash | 1 , & settings_element ,
383+ sizeof (struct settings_hash_linked_list ));
384+ if (rc >= 0 ) {
385+ goto no_ll_update ;
386+ } else if (rc != - ENOENT ) {
387+ return rc ;
388+ }
389+ /* else the LL node doesn't exist let's update it */
390+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
366391 /* write linked list structure element */
367392 settings_element .next_hash = 0 ;
368393 /* Verify first that the linked list last element is not broken.
@@ -392,7 +417,9 @@ static int settings_zms_save(struct settings_store *cs, const char *name, const
392417 cf -> second_to_last_hash_id = cf -> last_hash_id ;
393418 cf -> last_hash_id = name_hash | 1 ;
394419 }
395-
420+ #ifdef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
421+ no_ll_update :
422+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
396423#if CONFIG_SETTINGS_ZMS_NAME_CACHE
397424 if (!name_in_cache ) {
398425 settings_zms_cache_add (cf , name_hash & ZMS_HASH_MASK ,
0 commit comments