MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_page_search

Function dfs_page_search

components/dfs/dfs_v2/src/dfs_pcache.c:1383–1427  ·  view source on GitHub ↗

* @brief Search for a page in the address space AVL tree * * This function searches for a page at the specified file position in the address space's AVL tree. * If found, it marks the page as active and increments its reference count. * * @param[in] aspace The address space to search in * @param[in] fpos The file position to search for * @return struct dfs_page* The found page, or RT_NULL i

Source from the content-addressed store, hash-verified

1381 * @return struct dfs_page* The found page, or RT_NULL if not found
1382 */
1383static struct dfs_page *dfs_page_search(struct dfs_aspace *aspace, off_t fpos)
1384{
1385 int cmp;
1386 struct dfs_page *page;
1387 struct util_avl_struct *avl_node;
1388
1389 dfs_aspace_lock(aspace);
1390
1391 if (aspace->avl_page && dfs_page_compare(fpos, aspace->avl_page->fpos) == 0)
1392 {
1393 page = aspace->avl_page;
1394 dfs_page_active(page);
1395 dfs_page_ref(page);
1396 dfs_aspace_unlock(aspace);
1397 return page;
1398 }
1399
1400 avl_node = aspace->avl_root.root_node;
1401 while (avl_node)
1402 {
1403 page = rt_container_of(avl_node, struct dfs_page, avl_node);
1404 cmp = dfs_page_compare(fpos, page->fpos);
1405
1406 if (cmp < 0)
1407 {
1408 avl_node = avl_node->avl_left;
1409 }
1410 else if (cmp > 0)
1411 {
1412 avl_node = avl_node->avl_right;
1413 }
1414 else
1415 {
1416 aspace->avl_page = page;
1417 dfs_page_active(page);
1418 dfs_page_ref(page);
1419 dfs_aspace_unlock(aspace);
1420 return page;
1421 }
1422 }
1423
1424 dfs_aspace_unlock(aspace);
1425
1426 return RT_NULL;
1427}
1428
1429/**
1430 * @brief Load a page from file into address space cache

Callers 3

dfs_page_lookupFunction · 0.85
dfs_aspace_page_unmapFunction · 0.85
dfs_aspace_page_dirtyFunction · 0.85

Calls 5

dfs_aspace_lockFunction · 0.85
dfs_page_compareFunction · 0.85
dfs_page_activeFunction · 0.85
dfs_page_refFunction · 0.85
dfs_aspace_unlockFunction · 0.85

Tested by

no test coverage detected