diff --git a/pageserver/src/tenant/blob_io.rs b/pageserver/src/tenant/blob_io.rs index bedf09a40c..132176fac7 100644 --- a/pageserver/src/tenant/blob_io.rs +++ b/pageserver/src/tenant/blob_io.rs @@ -20,10 +20,10 @@ use std::io::{Error, ErrorKind}; impl<'a> BlockCursor<'a> { /// Read a blob into a new buffer. - pub async fn read_blob( + pub async fn read_blob<'c>( &self, offset: u64, - ctx: &RequestContext, + ctx: &'c RequestContext, ) -> Result, std::io::Error> { let mut buf = Vec::new(); self.read_blob_into_buf(offset, &mut buf, ctx).await?; @@ -31,11 +31,11 @@ impl<'a> BlockCursor<'a> { } /// Read blob into the given buffer. Any previous contents in the buffer /// are overwritten. - pub async fn read_blob_into_buf( + pub async fn read_blob_into_buf<'c>( &self, offset: u64, dstbuf: &mut Vec, - ctx: &RequestContext, + ctx: &'c RequestContext, ) -> Result<(), std::io::Error> { let mut blknum = (offset / PAGE_SZ as u64) as u32; let mut off = (offset % PAGE_SZ as u64) as usize; diff --git a/pageserver/src/tenant/block_io.rs b/pageserver/src/tenant/block_io.rs index 6d51a1d616..05e25fc16a 100644 --- a/pageserver/src/tenant/block_io.rs +++ b/pageserver/src/tenant/block_io.rs @@ -21,14 +21,14 @@ pub trait BlockReader { /// /// A cursor caches the last accessed page, allowing for faster /// access if the same block is accessed repeatedly. - fn block_cursor(&self) -> BlockCursor<'_, '_>; + fn block_cursor(&self) -> BlockCursor<'_>; } impl BlockReader for &B where B: BlockReader, { - fn block_cursor(&self) -> BlockCursor<'_, '_> { + fn block_cursor(&self) -> BlockCursor<'_> { (*self).block_cursor() } } @@ -71,7 +71,7 @@ impl<'c, 'a> Deref for BlockLease<'c, 'a> { /// similar to using traits for this purpose. /// /// Unlike traits, we also support the read function to be async though. -pub(crate) enum BlockReaderRef<'c, 'a> { +pub(crate) enum BlockReaderRef<'a> { FileBlockReader(&'a FileBlockReader), EphemeralFile(&'a EphemeralFile), Adapter(Adapter<&'a DeltaLayerInner>), @@ -81,13 +81,13 @@ pub(crate) enum BlockReaderRef<'c, 'a> { VirtualFile(&'a VirtualFile), } -impl<'c, 'a> BlockReaderRef<'c, 'a> { +impl<'a> BlockReaderRef<'a> { #[inline(always)] - async fn read_blk( + async fn read_blk<'c>( &self, blknum: u32, ctx: &'c RequestContext, - ) -> Result, std::io::Error> { + ) -> Result, std::io::Error> { use BlockReaderRef::*; match self { FileBlockReader(r) => r.read_blk(blknum, ctx).await, @@ -120,12 +120,12 @@ impl<'c, 'a> BlockReaderRef<'c, 'a> { /// // do stuff with 'buf' /// ``` /// -pub struct BlockCursor<'c, 'a> { - reader: BlockReaderRef<'c, 'a>, +pub struct BlockCursor<'a> { + reader: BlockReaderRef<'a>, } -impl<'c, 'a> BlockCursor<'c, 'a> { - pub(crate) fn new(reader: BlockReaderRef<'c, 'a>) -> Self { +impl<'a> BlockCursor<'a> { + pub(crate) fn new(reader: BlockReaderRef<'a>) -> Self { BlockCursor { reader } } // Needed by cli @@ -141,11 +141,11 @@ impl<'c, 'a> BlockCursor<'c, 'a> { /// access to the contents of the page. (For the page cache, the /// lease object represents a lock on the buffer.) #[inline(always)] - pub async fn read_blk( + pub async fn read_blk<'c>( &self, blknum: u32, - ctx: &RequestContext, - ) -> Result { + ctx: &'c RequestContext, + ) -> Result, std::io::Error> { self.reader.read_blk(blknum, ctx).await } } @@ -206,7 +206,7 @@ impl FileBlockReader { } impl BlockReader for FileBlockReader { - fn block_cursor(&self) -> BlockCursor<'_, '_> { + fn block_cursor(&self) -> BlockCursor<'_> { BlockCursor::new(BlockReaderRef::FileBlockReader(self)) } } diff --git a/pageserver/src/tenant/ephemeral_file.rs b/pageserver/src/tenant/ephemeral_file.rs index 5b99a1dd03..d2e6bc3760 100644 --- a/pageserver/src/tenant/ephemeral_file.rs +++ b/pageserver/src/tenant/ephemeral_file.rs @@ -64,11 +64,11 @@ impl EphemeralFile { self.len } - pub(crate) async fn read_blk( + pub(crate) async fn read_blk<'c>( &self, blknum: u32, - ctx: &RequestContext, - ) -> Result { + ctx: &'c RequestContext, + ) -> Result, io::Error> { let flushed_blknums = 0..self.len / PAGE_SZ as u64; if flushed_blknums.contains(&(blknum as u64)) { let cache = page_cache::get(); diff --git a/pageserver/src/tenant/storage_layer/delta_layer.rs b/pageserver/src/tenant/storage_layer/delta_layer.rs index 538d560298..c49d1eafb1 100644 --- a/pageserver/src/tenant/storage_layer/delta_layer.rs +++ b/pageserver/src/tenant/storage_layer/delta_layer.rs @@ -320,7 +320,7 @@ impl DeltaLayer { let keys = DeltaLayerInner::load_keys(&inner, ctx).await?; // A subroutine to dump a single blob - async fn dump_blob(val: ValueRef<'_, '_>, ctx: &RequestContext) -> Result { + async fn dump_blob(val: ValueRef<'_>, ctx: &RequestContext) -> Result { let buf = val.reader.read_blob(val.blob_ref.pos(), ctx).await?; let val = Value::des(&buf)?; let desc = match val { @@ -549,7 +549,7 @@ impl DeltaLayer { /// Loads all keys stored in the layer. Returns key, lsn, value size and value reference. /// /// The value can be obtained via the [`ValueRef::load`] function. - pub(crate) async fn load_keys<'c>(&self, ctx: &RequestContext) -> Result>> { + pub(crate) async fn load_keys<'c>(&self, ctx: &RequestContext) -> Result>> { let inner = self .load(LayerAccessKind::KeyIter, ctx) .await @@ -971,7 +971,7 @@ impl DeltaLayerInner { pub(super) async fn load_keys<'a, 'b, T: AsRef + Clone>( this: &'a T, ctx: &'b RequestContext, - ) -> Result>> { + ) -> Result>> { let dl = this.as_ref(); let file = &dl.file; @@ -1023,22 +1023,22 @@ impl DeltaLayerInner { } /// A set of data associated with a delta layer key and its value -pub struct DeltaEntry<'c, 'a> { +pub struct DeltaEntry<'a> { pub key: Key, pub lsn: Lsn, /// Size of the stored value pub size: u64, /// Reference to the on-disk value - pub val: ValueRef<'c, 'a>, + pub val: ValueRef<'a>, } /// Reference to an on-disk value -pub struct ValueRef<'c, 'a> { +pub struct ValueRef<'a> { blob_ref: BlobRef, - reader: BlockCursor<'c, 'a>, + reader: BlockCursor<'a>, } -impl<'c, 'a> ValueRef<'c, 'a> { +impl<'c, 'a> ValueRef<'a> { /// Loads the value from disk pub async fn load(&self, ctx: &'c RequestContext) -> Result { // theoretically we *could* record an access time for each, but it does not really matter @@ -1051,11 +1051,11 @@ impl<'c, 'a> ValueRef<'c, 'a> { pub(crate) struct Adapter(T); impl> Adapter { - pub(crate) async fn read_blk( + pub(crate) async fn read_blk<'c>( &self, blknum: u32, - ctx: &RequestContext, - ) -> Result { + ctx: &'c RequestContext, + ) -> Result, std::io::Error> { self.0.as_ref().file.read_blk(blknum, ctx).await } } diff --git a/pageserver/src/virtual_file.rs b/pageserver/src/virtual_file.rs index a2e8f30e15..5665cfb55b 100644 --- a/pageserver/src/virtual_file.rs +++ b/pageserver/src/virtual_file.rs @@ -544,7 +544,7 @@ impl VirtualFile { pub(crate) async fn read_blk( &self, blknum: u32, - ) -> Result, std::io::Error> { + ) -> Result, std::io::Error> { use crate::page_cache::PAGE_SZ; let mut buf = [0; PAGE_SZ]; self.read_exact_at(&mut buf, blknum as u64 * (PAGE_SZ as u64))