Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/propolis/src/hw/nvme/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ struct QueueState<QS> {
/// a `SubQueueState` for a Submission Queue.
inner: Mutex<QueueInner<QS>>,

pub acc_mem: MemAccessor,
/// This queue's memory accessor node.
///
/// Be careful about lock ordering when using this accessor; access_borrow()
/// holds this node's lock. If a user of this queue state requires both
/// `access_borrow()` and `QueueInner`, the protocol is to lock queue
/// state first and this accessor second.
Comment on lines +116 to +121
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

acc_mem: MemAccessor,
}
impl<QS> QueueState<QS> {
fn new(size: u32, acc_mem: MemAccessor, inner: QS) -> Self {
Expand Down Expand Up @@ -649,12 +655,15 @@ impl SubQueue {
pub fn pop(
self: &Arc<SubQueue>,
) -> Option<(GuestData<SubmissionQueueEntry>, Permit, u16)> {
// Lock the SubQueueState early to conform to lock ordering requirement;
// see docs on QueueState::acc_mem.
let mut state = self.state.lock();

let Some(mem) = self.state.acc_mem.access_borrow() else { return None };
let mem = mem.view();

// Attempt to reserve an entry on the Completion Queue
let permit = self.cq.reserve_entry(&self, &mem)?;
let mut state = self.state.lock();

// Check for last-minute updates to the tail via any configured doorbell
// page, prior to attempting the pop itself.
Expand Down
Loading