disk_backend

Struct Disk

Source
pub struct Disk(/* private fields */);
Expand description

An asynchronous block device.

This type is cheap to clone, for sharing the disk among multiple concurrent users.

Implementations§

Source§

impl Disk

Source

pub fn new(disk: impl 'static + DiskIo) -> Result<Self, InvalidDisk>

Returns a new disk wrapping the given backing object.

Source

pub fn sector_count(&self) -> u64

Returns the current sector count.

For some backing stores, this may change at runtime. Use wait_resize to detect this change.

Source

pub fn sector_size(&self) -> u32

Returns the logical sector size of the backing store.

Source

pub fn sector_shift(&self) -> u32

Returns log2 of the logical sector size of the backing store.

Source

pub fn disk_id(&self) -> Option<[u8; 16]>

Optionally returns a 16-byte identifier for the disk, if there is a natural one for this backing store.

This may be exposed to the guest as a unique disk identifier.

Source

pub fn physical_sector_size(&self) -> u32

Returns the physical sector size of the backing store.

Source

pub fn is_fua_respected(&self) -> bool

Returns true if the fua parameter to write_vectored is respected by the backing store by ensuring that the IO is immediately committed to disk.

Source

pub fn is_read_only(&self) -> bool

Returns true if the disk is read only.

Source

pub fn unmap( &self, sector: u64, count: u64, block_level_only: bool, ) -> impl use<'_> + Future<Output = Result<(), DiskError>> + Send

Unmap sectors from the disk.

Source

pub fn unmap_behavior(&self) -> UnmapBehavior

Returns the behavior of the unmap operation.

Source

pub fn optimal_unmap_sectors(&self) -> u32

Returns the optimal granularity for unmaps, in sectors.

Source

pub fn pr(&self) -> Option<&dyn PersistentReservation>

Optionally returns a trait object to issue persistent reservation requests.

Source

pub fn eject( &self, ) -> impl use<'_> + Future<Output = Result<(), DiskError>> + Send

Issues an asynchronous eject media operation to the disk.

Source

pub fn read_vectored<'a>( &'a self, buffers: &'a RequestBuffers<'_>, sector: u64, ) -> impl use<'a> + Future<Output = Result<(), DiskError>> + Send

Issues an asynchronous read-scatter operation to the disk.

§Arguments
  • buffers - An object representing the data buffers into which the disk data will be transferred.
  • sector - The logical sector at which the read operation starts.
Source

pub fn write_vectored<'a>( &'a self, buffers: &'a RequestBuffers<'_>, sector: u64, fua: bool, ) -> impl use<'a> + Future<Output = Result<(), DiskError>> + Send

Issues an asynchronous write-gather operation to the disk.

§Arguments
  • buffers - An object representing the data buffers containing the data to transfer to the disk.
  • sector - The logical sector at which the write operation starts.
  • fua - A flag indicates if FUA (force unit access) is requested.
§Panics

The caller must pass a buffer with an integer number of sectors.

Source

pub fn sync_cache( &self, ) -> impl use<'_> + Future<Output = Result<(), DiskError>> + Send

Issues an asynchronous flush operation to the disk.

Source

pub fn wait_resize( &self, sector_count: u64, ) -> impl use<'_> + Future<Output = u64>

Waits for the disk sector size to be different than the specified value.

Trait Implementations§

Source§

impl Clone for Disk

Source§

fn clone(&self) -> Disk

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Disk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Inspect for Disk

Source§

fn inspect(&self, req: Request<'_>)

Inspects the object.

Auto Trait Implementations§

§

impl Freeze for Disk

§

impl !RefUnwindSafe for Disk

§

impl Send for Disk

§

impl Sync for Disk

§

impl Unpin for Disk

§

impl !UnwindSafe for Disk

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more