@@ -76,10 +76,11 @@ impl PendingCommands {
76
76
const MAX_CIDS : usize = 1 << Self :: CID_KEY_BITS ;
77
77
const CID_SEQ_OFFSET : Wrapping < u16 > = Wrapping ( 1 << Self :: CID_KEY_BITS ) ;
78
78
79
- fn new ( ) -> Self {
79
+ fn new ( qid : u16 ) -> Self {
80
80
Self {
81
81
commands : Slab :: new ( ) ,
82
82
next_cid_high_bits : Wrapping ( 0 ) ,
83
+ qid,
83
84
}
84
85
}
85
86
@@ -109,11 +110,13 @@ impl PendingCommands {
109
110
let command = self
110
111
. commands
111
112
. try_remove ( ( cid & Self :: CID_KEY_MASK ) as usize )
112
- . expect ( "completion for unknown cid" ) ;
113
+ . unwrap_or_else ( || panic ! ( "completion for unknown cid: qid={}, cid={}" , self . qid , cid ) ) ;
113
114
assert_eq ! (
114
115
command. command. cdw0. cid( ) ,
115
116
cid,
116
- "cid sequence number mismatch"
117
+ "cid sequence number mismatch: qid={}, command_opcode={:#x}" ,
118
+ self . qid,
119
+ command. command. cdw0. opcode( ) ,
117
120
) ;
118
121
command. respond
119
122
}
@@ -136,7 +139,7 @@ impl PendingCommands {
136
139
}
137
140
138
141
/// Restore pending commands from the saved state.
139
- pub fn restore ( saved_state : & PendingCommandsSavedState ) -> anyhow:: Result < Self > {
142
+ pub fn restore ( saved_state : & PendingCommandsSavedState , qid : u16 ) -> anyhow:: Result < Self > {
140
143
let PendingCommandsSavedState {
141
144
commands,
142
145
next_cid_high_bits,
@@ -161,6 +164,7 @@ impl PendingCommands {
161
164
} )
162
165
. collect :: < Slab < PendingCommand > > ( ) ,
163
166
next_cid_high_bits : Wrapping ( * next_cid_high_bits) ,
167
+ qid,
164
168
} )
165
169
}
166
170
}
@@ -241,7 +245,7 @@ impl QueuePair {
241
245
QueueHandler {
242
246
sq : SubmissionQueue :: new ( qid, sq_entries, sq_mem_block) ,
243
247
cq : CompletionQueue :: new ( qid, cq_entries, cq_mem_block) ,
244
- commands : PendingCommands :: new ( ) ,
248
+ commands : PendingCommands :: new ( qid ) ,
245
249
stats : Default :: default ( ) ,
246
250
drain_after_restore : false ,
247
251
}
@@ -609,6 +613,7 @@ struct PendingCommands {
609
613
commands : Slab < PendingCommand > ,
610
614
#[ inspect( hex) ]
611
615
next_cid_high_bits : Wrapping < u16 > ,
616
+ qid : u16 ,
612
617
}
613
618
614
619
#[ derive( Inspect ) ]
@@ -749,7 +754,7 @@ impl QueueHandler {
749
754
Ok ( Self {
750
755
sq : SubmissionQueue :: restore ( sq_mem_block, sq_state) ?,
751
756
cq : CompletionQueue :: restore ( cq_mem_block, cq_state) ?,
752
- commands : PendingCommands :: restore ( pending_cmds) ?,
757
+ commands : PendingCommands :: restore ( pending_cmds, sq_state . sqid ) ?,
753
758
stats : Default :: default ( ) ,
754
759
// Only drain pending commands for I/O queues.
755
760
// Admin queue is expected to have pending Async Event requests.
0 commit comments