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

Function dfs_aspace_page_unmap

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

* Unmap a page from virtual address space. * * @param[in] file The file object containing the page * @param[in] varea The virtual memory area * @param[in] vaddr The virtual address to unmap * * @return Always returns 0 on success * * @note This function removes the mapping between a virtual address and a physical page. * It handles cleanup of mmap structures and marks page

Source from the content-addressed store, hash-verified

1970 * It handles cleanup of mmap structures and marks pages dirty if needed.
1971 */
1972int dfs_aspace_page_unmap(struct dfs_file *file, struct rt_varea *varea, void *vaddr)
1973{
1974 struct dfs_page *page;
1975 struct dfs_aspace *aspace = file->vnode->aspace;
1976
1977 if (aspace)
1978 {
1979 dfs_aspace_lock(aspace);
1980
1981 page = dfs_page_search(aspace, dfs_aspace_fpos(varea, vaddr));
1982 if (page)
1983 {
1984 rt_list_t *node, *tmp;
1985 struct dfs_mmap *map;
1986 rt_varea_unmap_page(varea, vaddr);
1987
1988 node = page->mmap_head.next;
1989
1990 while (node != &page->mmap_head)
1991 {
1992 map = rt_list_entry(node, struct dfs_mmap, mmap_node);
1993 tmp = node;
1994 node = node->next;
1995
1996 if (map && varea->aspace == map->aspace && vaddr == map->vaddr)
1997 {
1998 if (!rt_varea_is_private_locked(varea))
1999 {
2000 dfs_page_dirty(page);
2001 }
2002 rt_list_remove(tmp);
2003 rt_free(map);
2004 break;
2005 }
2006 }
2007
2008 dfs_page_release(page);
2009 }
2010
2011 dfs_aspace_unlock(aspace);
2012 }
2013
2014 return 0;
2015}
2016
2017/**
2018 * Mark a page as dirty in the address space.

Callers 1

unmap_pagesFunction · 0.85

Calls 10

dfs_aspace_lockFunction · 0.85
dfs_page_searchFunction · 0.85
dfs_aspace_fposFunction · 0.85
rt_varea_unmap_pageFunction · 0.85
dfs_page_dirtyFunction · 0.85
rt_list_removeFunction · 0.85
rt_freeFunction · 0.85
dfs_page_releaseFunction · 0.85
dfs_aspace_unlockFunction · 0.85

Tested by

no test coverage detected