Skip to content

Commit 17e66ff

Browse files
committed
CA-402901: Update leaked dp to Sr
When add leaked datapath: 1. add leaked datapath to Sr.vdis 2. write to db file 3. log enhance If there are storage exceptions raised when destroying datapath. Then the procedure fails and the state of VDI becomes incorrect, which leads to various abnormalresults in subsequent operations. To handle this, the leaked datapath is designed to redestroy the datapath and refresh the state before next storage operation via function remove_datapaths_andthen_nolock. But this mechanism doesn't take effect in current code. This commit is to fix this bug. Leaked datapath should be added to Sr.vdis to make the leaked datapath really work. And write to db file to avoid losing the leaked datapath if xapi restarts. Signed-off-by: Changlei Li <[email protected]>
1 parent f14fcdf commit 17e66ff

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ocaml/xapi/storage_smapiv1_wrapper.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ functor
453453
List.fold_left perform_one vdi_t ops
454454

455455
let perform_nolock context ~dbg ~dp ~sr ~vdi ~vm this_op =
456+
debug "perform_nolock dp=%s, sr=%s, vdi=%s, vm=%s, op=%s" dp
457+
(s_of_sr sr) (s_of_vdi vdi) (s_of_vm vm)
458+
(Vdi_automaton.string_of_op this_op) ;
456459
match Host.find sr !Host.host with
457460
| None ->
458461
raise (Storage_error (Sr_not_attached (s_of_sr sr)))
@@ -473,6 +476,15 @@ functor
473476
superstate to superstate'. These may fail: if so we revert the
474477
datapath+VDI state to the most appropriate value. *)
475478
let ops = Vdi_automaton.( - ) superstate superstate' in
479+
debug "perform_nolock %s -> %s: %s"
480+
(Vdi_automaton.string_of_state superstate)
481+
(Vdi_automaton.string_of_state superstate')
482+
(String.concat ", "
483+
(List.map
484+
(fun (op, _) -> Vdi_automaton.string_of_op op)
485+
ops
486+
)
487+
) ;
476488
side_effects context dbg dp sr sr_t vdi vdi_t vm ops
477489
with e ->
478490
let e =
@@ -529,7 +541,8 @@ functor
529541
)
530542
with e ->
531543
if not allow_leak then (
532-
ignore (Vdi.add_leaked dp vdi_t) ;
544+
Sr.add_or_replace vdi (Vdi.add_leaked dp vdi_t) sr_t ;
545+
Everything.to_file !host_state_path (Everything.make ()) ;
533546
raise e
534547
) else (
535548
(* allow_leak means we can forget this dp *)

0 commit comments

Comments
 (0)