diff --git a/pageserver/src/tenant/blob_io.rs b/pageserver/src/tenant/blob_io.rs index 11946cdaa5..4502382fb1 100644 --- a/pageserver/src/tenant/blob_io.rs +++ b/pageserver/src/tenant/blob_io.rs @@ -169,12 +169,12 @@ impl BlobWriter { src_buf: Slice, ctx: &RequestContext, ) -> (Slice, Result<(), Error>) { - let begin_end = (src_buf.begin(), src_buf.end()); + let orig_bounds = src_buf.bounds(); - macro_rules! return_ { + macro_rules! return_orig_bounds { ($buf:expr, $val:expr) => {{ let buf = $buf.into_inner(); - return (buf.slice(begin_end.0..begin_end.1), $val); + return (buf.slice(orig_bounds), $val); }}; } @@ -196,7 +196,7 @@ impl BlobWriter { // Then, if the buffer is full, flush it out if self.buf.len() == Self::CAPACITY { if let Err(e) = self.flush_buffer(ctx).await { - return_!(src_buf, Err(e)); + return_orig_bounds!(src_buf, Err(e)); } } // Finally, write the tail of src_buf: @@ -213,14 +213,14 @@ impl BlobWriter { } else { let (src_buf, res) = self.write_all_unbuffered(src_buf, ctx).await; if let Err(e) = res { - return_!(src_buf, Err(e)); + return_orig_bounds!(src_buf, Err(e)); } src_buf } } else { src_buf }; - return_!(src_buf, Ok(())); + return_orig_bounds!(src_buf, Ok(())); } /// Write a blob of data. Returns the offset that it was written to, diff --git a/pageserver/src/virtual_file.rs b/pageserver/src/virtual_file.rs index 48396c3180..32188c1c8c 100644 --- a/pageserver/src/virtual_file.rs +++ b/pageserver/src/virtual_file.rs @@ -680,12 +680,12 @@ impl VirtualFile { buf: Slice, ctx: &RequestContext, ) -> (Slice, Result) { - let begin_end = (buf.begin(), buf.end()); + let begin_end = buf.bounds(); - macro_rules! return_ { + macro_rules! return_orig_bounds { ($buf:expr, $val:expr) => {{ let buf = $buf.into_inner(); - return (buf.slice(begin_end.0..begin_end.1), $val); + return (buf.slice(begin_end), $val); }}; } @@ -699,7 +699,7 @@ impl VirtualFile { (buf, res) = self.write(buf, ctx).await; match res { Ok(0) => { - return_!( + return_orig_bounds!( buf, Err(Error::new( std::io::ErrorKind::WriteZero, @@ -711,11 +711,11 @@ impl VirtualFile { buf = buf.slice(n..); } Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => {} - Err(e) => return_!(buf, Err(e)), + Err(e) => return_orig_bounds!(buf, Err(e)), } } - return_!(buf, Ok(nbytes)); + return_orig_bounds!(buf, Ok(nbytes)); } async fn write(