From 4c874178b0b5e99de2d069aba9c6d2b6599cf095 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 11 Dec 2023 17:57:49 +0000 Subject: [PATCH] make the repro work by removing the lifetime param from FileGuard --- repro-problem/src/virtual_file.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/repro-problem/src/virtual_file.rs b/repro-problem/src/virtual_file.rs index 83999960cb..72d5737f63 100644 --- a/repro-problem/src/virtual_file.rs +++ b/repro-problem/src/virtual_file.rs @@ -485,7 +485,7 @@ impl VirtualFile { /// /// We are doing it via a macro as Rust doesn't support async closures that /// take on parameters with lifetimes. - async fn lock_file(&self) -> Result, Error> { + async fn lock_file(&self) -> Result { let open_files = get_open_files(); let mut handle_guard = { @@ -604,13 +604,11 @@ impl VirtualFile { } with_file!(self, StorageIoOperation::Read, |file_guard| { - assert_send(Self::read_exact_at0(unsafe { - OwnedFd::from_raw_fd(file_guard.as_fd()) - }, page, offset)).await + assert_send(Self::read_exact_at0(file_guard, page, offset)).await }) } async fn read_exact_at0( - file_guard: OwnedFd, + file_guard: FileGuard, write_guard: PageWriteGuard<'static>, offset: u64, ) -> Result, Error> { @@ -689,11 +687,11 @@ impl VirtualFile { } } -struct FileGuard<'a> { - slot_guard: RwLockReadGuard<'a, SlotInner>, +struct FileGuard { + slot_guard: RwLockReadGuard<'static, SlotInner>, } -impl AsRef for FileGuard<'static> { +impl AsRef for FileGuard { fn as_ref(&self) -> &OwnedFd { // This unwrap is safe because we only create `FileGuard`s // if we know that the file is Some. @@ -701,7 +699,7 @@ impl AsRef for FileGuard<'static> { } } -impl FileGuard<'static> { +impl FileGuard { // TODO: switch to tokio-epoll-uring native operations. #[deprecated] fn with_std_file(&mut self, with: F) -> R @@ -716,7 +714,7 @@ impl FileGuard<'static> { } } -impl tokio_epoll_uring::IoFd for FileGuard<'static> { +impl tokio_epoll_uring::IoFd for FileGuard { unsafe fn as_fd(&self) -> RawFd { let owned_fd: &OwnedFd = self.as_ref(); owned_fd.as_raw_fd()