update to pxar 0.1.9, update ReadAt implementations

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-06-24 11:57:12 +02:00
parent c1769a749c
commit a6f8728339
3 changed files with 35 additions and 19 deletions

View File

@ -42,7 +42,7 @@ proxmox = { version = "0.1.40", features = [ "sortable-macro", "api-macro" ] }
#proxmox = { git = "ssh://gitolite3@proxdev.maurer-it.com/rust/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] } #proxmox = { git = "ssh://gitolite3@proxdev.maurer-it.com/rust/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] }
#proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro" ] } #proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro" ] }
proxmox-fuse = "0.1.0" proxmox-fuse = "0.1.0"
pxar = { version = "0.1.8", features = [ "tokio-io", "futures-io" ] } pxar = { version = "0.1.9", features = [ "tokio-io", "futures-io" ] }
#pxar = { path = "../pxar", features = [ "tokio-io", "futures-io" ] } #pxar = { path = "../pxar", features = [ "tokio-io", "futures-io" ] }
regex = "1.2" regex = "1.2"
rustyline = "6" rustyline = "6"

View File

@ -4,7 +4,7 @@ use std::ops::Range;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::task::{Context, Poll}; use std::task::Context;
use std::pin::Pin; use std::pin::Pin;
use anyhow::{bail, format_err, Error}; use anyhow::{bail, format_err, Error};
@ -13,6 +13,7 @@ use proxmox::tools::io::ReadExt;
use proxmox::tools::uuid::Uuid; use proxmox::tools::uuid::Uuid;
use proxmox::tools::vec; use proxmox::tools::vec;
use proxmox::tools::mmap::Mmap; use proxmox::tools::mmap::Mmap;
use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
use super::chunk_stat::ChunkStat; use super::chunk_stat::ChunkStat;
use super::chunk_store::ChunkStore; use super::chunk_store::ChunkStore;
@ -416,19 +417,26 @@ impl<R: ReadChunk> LocalDynamicReadAt<R> {
} }
} }
impl<R: ReadChunk> pxar::accessor::ReadAt for LocalDynamicReadAt<R> { impl<R: ReadChunk> ReadAt for LocalDynamicReadAt<R> {
fn poll_read_at( fn start_read_at<'a>(
self: Pin<&Self>, self: Pin<&'a Self>,
_cx: &mut Context, _cx: &mut Context,
buf: &mut [u8], buf: &'a mut [u8],
offset: u64, offset: u64,
) -> Poll<io::Result<usize>> { ) -> MaybeReady<io::Result<usize>, ReadAtOperation<'a>> {
use std::io::Read; use std::io::Read;
tokio::task::block_in_place(move || { MaybeReady::Ready(tokio::task::block_in_place(move || {
let mut reader = self.inner.lock().unwrap(); let mut reader = self.inner.lock().unwrap();
reader.seek(SeekFrom::Start(offset))?; reader.seek(SeekFrom::Start(offset))?;
Poll::Ready(Ok(reader.read(buf)?)) Ok(reader.read(buf)?)
}) }))
}
fn poll_complete<'a>(
self: Pin<&'a Self>,
_op: ReadAtOperation<'a>,
) -> MaybeReady<io::Result<usize>, ReadAtOperation<'a>> {
panic!("LocalDynamicReadAt::start_read_at returned Pending");
} }
} }

View File

@ -6,7 +6,7 @@ use std::os::unix::io::RawFd;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::pin::Pin; use std::pin::Pin;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::task::{Context, Poll}; use std::task::Context;
use anyhow::{bail, format_err, Error}; use anyhow::{bail, format_err, Error};
use chrono::{Local, DateTime, Utc, TimeZone}; use chrono::{Local, DateTime, Utc, TimeZone};
@ -27,6 +27,7 @@ use proxmox::api::{ApiHandler, ApiMethod, RpcEnvironment};
use proxmox::api::schema::*; use proxmox::api::schema::*;
use proxmox::api::cli::*; use proxmox::api::cli::*;
use proxmox::api::api; use proxmox::api::api;
use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
use proxmox_backup::tools; use proxmox_backup::tools;
use proxmox_backup::api2::types::*; use proxmox_backup::api2::types::*;
@ -2029,19 +2030,26 @@ impl BufferedDynamicReadAt {
} }
} }
impl pxar::accessor::ReadAt for BufferedDynamicReadAt { impl ReadAt for BufferedDynamicReadAt {
fn poll_read_at( fn start_read_at<'a>(
self: Pin<&Self>, self: Pin<&'a Self>,
_cx: &mut Context, _cx: &mut Context,
buf: &mut [u8], buf: &'a mut [u8],
offset: u64, offset: u64,
) -> Poll<io::Result<usize>> { ) -> MaybeReady<io::Result<usize>, ReadAtOperation<'a>> {
use std::io::Read; use std::io::Read;
tokio::task::block_in_place(move || { MaybeReady::Ready(tokio::task::block_in_place(move || {
let mut reader = self.inner.lock().unwrap(); let mut reader = self.inner.lock().unwrap();
reader.seek(SeekFrom::Start(offset))?; reader.seek(SeekFrom::Start(offset))?;
Poll::Ready(Ok(reader.read(buf)?)) Ok(reader.read(buf)?)
}) }))
}
fn poll_complete<'a>(
self: Pin<&'a Self>,
_op: ReadAtOperation<'a>,
) -> MaybeReady<io::Result<usize>, ReadAtOperation<'a>> {
panic!("LocalDynamicReadAt::start_read_at returned Pending");
} }
} }