Skip to content

Commit 061b378

Browse files
Revert "logging: backend: log_backend_fs: add dir cache helper functions"
1 parent ff37fb7 commit 061b378

File tree

2 files changed

+6
-77
lines changed

2 files changed

+6
-77
lines changed

include/zephyr/logging/log_backend_fs.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,8 @@
88
#ifndef ZEPHYR_LOG_BACKEND_FS_H_
99
#define ZEPHYR_LOG_BACKEND_FS_H_
1010

11-
#include <zephyr/sys/hash_map.h>
12-
13-
struct file_list_item {
14-
sys_snode_t node;
15-
uint32_t bid;
16-
uint64_t ts;
17-
};
18-
1911
const struct log_backend *log_backend_fs_get(void);
2012
uint32_t log_backend_fs_get_boot_id(void);
2113
int log_backend_fs_clear_logs(bool activate);
22-
struct file_list_item *log_backend_fs_flist_get_next(struct file_list_item *item);
23-
int log_backend_fs_flist_get_max_ts(struct sys_hashmap *map);
2414

2515
#endif /* ZEPHYR_LOG_BACKEND_FS_H_ */

subsys/logging/backends/log_backend_fs.c

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ struct logfs_msg {
3737
#define MSG_SIZE 4
3838

3939
sys_slist_t file_list = SYS_SLIST_STATIC_INIT(&file_list);
40-
struct k_mutex file_list_lock;
40+
41+
struct file_list_item {
42+
sys_snode_t node;
43+
uint32_t bid;
44+
uint64_t ts;
45+
};
4146

4247
K_MSGQ_DEFINE(log_msgq, sizeof(struct logfs_msg), MSG_SIZE, 1);
4348
K_THREAD_STACK_DEFINE(logfs_queue_stack_area, CONFIG_LOG_BACKEND_FS_STACK_SIZE);
@@ -151,12 +156,8 @@ static int file_list_add_item(uint32_t boot_id, uint64_t timestamp)
151156
item->bid = boot_id;
152157
item->ts = timestamp;
153158

154-
k_mutex_lock(&file_list_lock, K_FOREVER);
155-
156159
sys_slist_append(&file_list, &item->node);
157160

158-
k_mutex_unlock(&file_list_lock);
159-
160161
return 0;
161162
}
162163

@@ -196,34 +197,6 @@ static int file_list_update(void)
196197
return cnt;
197198
}
198199

199-
int log_backend_fs_flist_get_max_ts(struct sys_hashmap *map)
200-
{
201-
struct file_list_item *pn;
202-
struct file_list_item *cur = NULL;
203-
uint64_t ts;
204-
205-
k_mutex_lock(&file_list_lock, K_FOREVER);
206-
207-
cur = SYS_SLIST_PEEK_HEAD_CONTAINER(&file_list, cur, node);
208-
if (cur == NULL) {
209-
k_mutex_unlock(&file_list_lock);
210-
return -ENODATA;
211-
}
212-
213-
sys_hashmap_clear(map, NULL, NULL);
214-
sys_hashmap_insert(map, cur->bid, cur->ts, NULL);
215-
216-
SYS_SLIST_FOR_EACH_CONTAINER(&file_list, pn, node) {
217-
if (!sys_hashmap_get(map, pn->bid, &ts) || pn->ts > ts) {
218-
sys_hashmap_insert(map, pn->bid, pn->ts, NULL);
219-
}
220-
}
221-
222-
k_mutex_unlock(&file_list_lock);
223-
224-
return 0;
225-
}
226-
227200
static struct file_list_item *file_list_get_oldest_file(void)
228201
{
229202
struct file_list_item *pn;
@@ -243,34 +216,6 @@ static struct file_list_item *file_list_get_oldest_file(void)
243216
return cur;
244217
}
245218

246-
struct file_list_item *log_backend_fs_flist_get_next(struct file_list_item *item)
247-
{
248-
struct file_list_item *pn, *next = item;
249-
250-
k_mutex_lock(&file_list_lock, K_FOREVER);
251-
252-
SYS_SLIST_FOR_EACH_CONTAINER(&file_list, pn, node) {
253-
if (pn->bid >= item->bid) {
254-
if ((next == item && (pn->bid > item->bid || pn->ts > item->ts)) ||
255-
(pn->bid < next->bid && pn->bid > item->bid) ||
256-
(pn->bid == next->bid && pn->bid > item->bid && pn->ts < next->ts) ||
257-
(pn->bid == item->bid && pn->bid < next->bid && pn->ts > item->ts) ||
258-
(pn->bid == item->bid && pn->bid == next->bid && pn->ts < next->ts &&
259-
pn->ts > item->ts)) {
260-
next = pn;
261-
}
262-
}
263-
}
264-
265-
k_mutex_unlock(&file_list_lock);
266-
267-
if (next == item) {
268-
return NULL;
269-
}
270-
271-
return next;
272-
}
273-
274219
#if !defined(CONFIG_LOG_BACKEND_FS_TIME_BASED_ROTATION)
275220
static int check_log_file_exist(int num)
276221
{
@@ -847,12 +792,6 @@ static void log_backend_fs_init(const struct log_backend *const backend)
847792
K_THREAD_STACK_SIZEOF(logfs_queue_stack_area), THREAD_PRIORITY, &cfg);
848793
k_work_init(&logfs_msg_work, logfs_consumer);
849794

850-
rc = k_mutex_init(&file_list_lock);
851-
if (rc != 0) {
852-
printf("%s: mutex init failed, rc = %d\n", __func__, rc);
853-
return;
854-
}
855-
856795
if (backend_state == BACKEND_FS_NOT_INITIALIZED) {
857796
if (check_log_volume_available()) {
858797
/* will try to re-init later */

0 commit comments

Comments
 (0)