From 88468fce3e1443705ccaa7b6ce4337eef62e6a43 Mon Sep 17 00:00:00 2001 From: Sherlock Holo Date: Thu, 11 Jul 2024 16:42:13 +0800 Subject: [PATCH] fix: fusion driver miss release_buffer_pool implement --- compio-driver/src/fusion/buffer_pool.rs | 16 ++++++++++++++++ compio-driver/src/fusion/mod.rs | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/compio-driver/src/fusion/buffer_pool.rs b/compio-driver/src/fusion/buffer_pool.rs index c30c8249..7d47e3b1 100644 --- a/compio-driver/src/fusion/buffer_pool.rs +++ b/compio-driver/src/fusion/buffer_pool.rs @@ -44,6 +44,22 @@ impl BufferPool { inner: BufferPollInner::Poll(buffer_pool), } } + + pub(crate) fn into_poll(self) -> crate::fallback_buffer_pool::BufferPool { + match self.inner { + BufferPollInner::IoUring(_) => { + panic!("BufferPool type is not io-uring type") + } + BufferPollInner::Poll(inner) => inner, + } + } + + pub(crate) fn into_io_uring(self) -> super::iour::buffer_pool::BufferPool { + match self.inner { + BufferPollInner::IoUring(inner) => inner, + BufferPollInner::Poll(_) => panic!("BufferPool type is not poll type"), + } + } } enum BufferPollInner { diff --git a/compio-driver/src/fusion/mod.rs b/compio-driver/src/fusion/mod.rs index 64b71b16..d633cd87 100644 --- a/compio-driver/src/fusion/mod.rs +++ b/compio-driver/src/fusion/mod.rs @@ -200,8 +200,11 @@ impl Driver { /// # Safety /// /// caller must make sure release the buffer pool with correct driver - pub unsafe fn release_buffer_pool(&mut self, _: BufferPool) -> io::Result<()> { - todo!() + pub unsafe fn release_buffer_pool(&mut self, buffer_pool: BufferPool) -> io::Result<()> { + match &mut self.fuse { + FuseDriver::Poll(driver) => driver.release_buffer_pool(buffer_pool.into_poll()), + FuseDriver::IoUring(driver) => driver.release_buffer_pool(buffer_pool.into_io_uring()), + } } }