From f8a20b442cebfb0d9cb42e62788ca2dfc6eec96a Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Wed, 20 May 2026 14:12:41 +0800 Subject: [PATCH] Simplify VMO APIs and break long lines --- kernel/src/vm/page_cache/vmo/mod.rs | 14 +++++++++----- kernel/src/vm/vmar/vm_mapping.rs | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/src/vm/page_cache/vmo/mod.rs b/kernel/src/vm/page_cache/vmo/mod.rs index 2d921a371..a8850cbbd 100644 --- a/kernel/src/vm/page_cache/vmo/mod.rs +++ b/kernel/src/vm/page_cache/vmo/mod.rs @@ -214,8 +214,9 @@ impl Vmo { /// /// For anonymous VMOs the page is zero-filled on first access. /// For VMOs with a backend this may perform synchronous I/O. - pub fn commit_on(&self, page_idx: usize) -> Result { - self.commit_on_internal(page_idx, CommitMode::Read) + pub fn commit_on(&self, page_idx: usize) -> Result<()> { + self.commit_on_internal(page_idx, CommitMode::Read)?; + Ok(()) } fn commit_on_internal(&self, page_idx: usize, commit_mode: CommitMode) -> Result { @@ -416,7 +417,8 @@ impl Vmo { page_offset = 0; } - // `current_idx < page_idx_range.end` guarantees at least one page is successfully collected here. + // `current_idx < page_idx_range.end` guarantees at least one page is successfully + // collected here. current_idx = page_batch.last().unwrap().0 + 1; } @@ -548,7 +550,8 @@ impl Vmo { *page_offset = 0; } - // `current_idx < page_idx_range.end` guarantees at least one page is successfully collected here. + // `current_idx < page_idx_range.end` guarantees at least one page is successfully + // collected here. current_idx = page_batch.last().unwrap().0 + 1; } @@ -573,7 +576,8 @@ impl Vmo { while current_idx < page_idx_range.end { self.collect_pages(current_idx, page_idx_range.end, commit_mode, page_batch)?; - // `current_idx < page_idx_range.end` guarantees at least one page is successfully collected here. + // `current_idx < page_idx_range.end` guarantees at least one page is successfully + // collected here. let next_idx = page_batch.last().unwrap().0 + 1; for (_, page) in page_batch.drain(..) { diff --git a/kernel/src/vm/vmar/vm_mapping.rs b/kernel/src/vm/vmar/vm_mapping.rs index 1402940e6..2a2fcf82b 100644 --- a/kernel/src/vm/vmar/vm_mapping.rs +++ b/kernel/src/vm/vmar/vm_mapping.rs @@ -909,8 +909,8 @@ impl MappedVmo { /// /// This method may involve I/O operations if the VMO needs to fetch /// a page from the underlying page cache. - pub fn commit_on(&self, page_idx: usize) -> Result { - self.vmo.commit_on(page_idx).map(|frame| frame.into()) + pub fn commit_on(&self, page_idx: usize) -> Result<()> { + self.vmo.commit_on(page_idx) } /// Traverses the indices within a specified range of a VMO sequentially.