* @brief Mark a page as dirty and manage dirty list * * This function marks a page as dirty and adds it to the dirty list if not already present. * It also triggers a write-back operation if more than 1 second has passed since last write-back. * * @param[in] page The page to be marked as dirty * @return int Always returns 0 on success */
| 1346 | * @return int Always returns 0 on success |
| 1347 | */ |
| 1348 | static int dfs_page_dirty(struct dfs_page *page) |
| 1349 | { |
| 1350 | struct dfs_aspace *aspace = page->aspace; |
| 1351 | |
| 1352 | dfs_aspace_lock(aspace); |
| 1353 | |
| 1354 | if (page->dirty_node.next == RT_NULL && page->space_node.next != RT_NULL) |
| 1355 | { |
| 1356 | rt_list_insert_before(&aspace->list_dirty, &page->dirty_node); |
| 1357 | } |
| 1358 | |
| 1359 | page->is_dirty = 1; |
| 1360 | page->tick_ms = rt_tick_get_millisecond(); |
| 1361 | |
| 1362 | if (rt_tick_get_millisecond() - __pcache.last_time_wb >= 1000) |
| 1363 | { |
| 1364 | dfs_pcache_mq_work(PCACHE_MQ_WB); |
| 1365 | __pcache.last_time_wb = rt_tick_get_millisecond(); |
| 1366 | } |
| 1367 | |
| 1368 | dfs_aspace_unlock(aspace); |
| 1369 | |
| 1370 | return 0; |
| 1371 | } |
| 1372 | |
| 1373 | /** |
| 1374 | * @brief Search for a page in the address space AVL tree |
no test coverage detected