Lines Matching full:request
3 //! This module provides a wrapper for the C `struct request` type.
19 /// A wrapper around a blk-mq [`struct request`]. This represents an IO request.
23 /// There are four states for a request that the Rust bindings care about:
25 /// 1. Request is owned by block layer (refcount 0).
26 /// 2. Request is owned by driver but with zero [`ARef`]s in existence
28 /// 3. Request is owned by driver with exactly one [`ARef`] in existence
30 /// 4. Request is owned by driver with more than one [`ARef`] in existence
34 /// We need to track 1 and 2 to ensure we fail tag to request conversions for
37 /// We need to track 3 and 4 to ensure that it is safe to end the request and hand
42 /// [`struct request`].
46 /// * `self.0` is a valid [`struct request`] created by the C portion of the
48 /// * The private data area associated with this request must be an initialized
53 /// [`struct request`]: srctree/include/linux/blk-mq.h
56 pub struct Request<T: Operations>(Opaque<bindings::request>, PhantomData<T>); struct
58 impl<T: Operations> Request<T> { impl
59 /// Create an [`ARef<Request>`] from a [`struct request`] pointer.
65 /// * The type invariants for [`Request`] must hold for the pointee of `ptr`.
67 /// [`struct request`]: srctree/include/linux/blk-mq.h
68 pub(crate) unsafe fn aref_from_raw(ptr: *mut bindings::request) -> ARef<Self> { in aref_from_raw()
75 /// Notify the block layer that a request is going to be processed now.
79 /// drivers call this function when starting to process a request.
86 // SAFETY: By type invariant, `self.0` is a valid `struct request` and in start_unchecked()
93 /// [`Request`].
96 /// C [`struct request`]. If the operation fails, `this` is returned in the
99 /// [`struct request`]: srctree/include/linux/blk-mq.h
100 fn try_set_end(this: ARef<Self>) -> Result<*mut bindings::request, ARef<Self>> { in try_set_end() argument
117 /// Notify the block layer that the request has been completed without errors.
120 /// referencing the request.
124 // SAFETY: By type invariant, `this.0` was a valid `struct request`. The in end_ok()
126 // `ARef`s pointing to this request. Therefore it is safe to hand it in end_ok()
134 /// of the request structure.
141 let request_ptr = this.cast::<bindings::request>(); in wrapper_ptr()
152 /// area of the request structure.
155 // the private data associated with this request is initialized and in wrapper_ref()
162 /// A wrapper around data stored in the private area of the C [`struct request`].
164 /// [`struct request`]: srctree/include/linux/blk-mq.h
166 /// The Rust request refcount has the following states:
168 /// - 0: The request is owned by C block layer.
169 /// - 1: The request is owned by Rust abstractions but there are no [`ARef`] references to it.
170 /// - 2+: There are [`ARef`] references to the request.
175 /// Return a reference to the refcount of the request that is embedding
181 /// Return a pointer to the refcount of the request that is embedding the
194 // SAFETY: Exclusive access is thread-safe for `Request`. `Request` has no `&mut
197 unsafe impl<T: Operations> Send for Request<T> {} implementation
199 // SAFETY: Shared access is thread-safe for `Request`. `&self` methods that
201 unsafe impl<T: Operations> Sync for Request<T> {} implementation
229 // SAFETY: All instances of `Request<T>` are reference counted. This
233 unsafe impl<T: Operations> AlwaysRefCounted for Request<T> { implementation
242 panic!("Request refcount zero on clone") in inc_ref()
250 // SAFETY: The type invariant of `Request` guarantees that the private in dec_ref()
259 panic!("Request reached refcount zero in Rust abstractions"); in dec_ref()