* @brief Flush dirty pages in an address space to storage * * This function writes all dirty pages in the specified address space to storage, * ensuring data persistence. It handles page size adjustments and clears dirty flags * after successful writes. * * @param[in] aspace Pointer to the address space containing dirty pages * * @return Always returns 0 (success) */
| 1717 | * @return Always returns 0 (success) |
| 1718 | */ |
| 1719 | int dfs_aspace_flush(struct dfs_aspace *aspace) |
| 1720 | { |
| 1721 | if (aspace) |
| 1722 | { |
| 1723 | rt_list_t *next; |
| 1724 | struct dfs_page *page; |
| 1725 | |
| 1726 | dfs_aspace_lock(aspace); |
| 1727 | |
| 1728 | if (aspace->pages_count > 0 && aspace->vnode) |
| 1729 | { |
| 1730 | rt_list_for_each(next, &aspace->list_dirty) |
| 1731 | { |
| 1732 | page = rt_list_entry(next, struct dfs_page, dirty_node); |
| 1733 | if (page->is_dirty == 1 && aspace->vnode) |
| 1734 | { |
| 1735 | if (aspace->vnode->size < page->fpos + page->size) |
| 1736 | { |
| 1737 | page->len = aspace->vnode->size - page->fpos; |
| 1738 | } |
| 1739 | else |
| 1740 | { |
| 1741 | page->len = page->size; |
| 1742 | } |
| 1743 | |
| 1744 | if (aspace->ops->write) |
| 1745 | { |
| 1746 | aspace->ops->write(page); |
| 1747 | } |
| 1748 | |
| 1749 | page->is_dirty = 0; |
| 1750 | } |
| 1751 | RT_ASSERT(page->is_dirty == 0); |
| 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | dfs_aspace_unlock(aspace); |
| 1756 | } |
| 1757 | return 0; |
| 1758 | } |
| 1759 | |
| 1760 | /** |
| 1761 | * @brief Clean all pages from an address space |
no test coverage detected