Skip to content

Commit 59236c6

Browse files
committed
Remove receive_start(2) from storage_migrate
These functions will not be exposed in storage_migrate.ml any more. `receive_start` is kept in the mux for backwards compatability reasons, and will go straight to the SMAPIv1 implemenetation. `receive_start2` calls will not be directed to the storage_mux any more, instead it will be multiplexed by the new layer in storage_migrate. Signed-off-by: Vincent Liu <[email protected]>
1 parent 1fe6389 commit 59236c6

File tree

2 files changed

+9
-123
lines changed

2 files changed

+9
-123
lines changed

ocaml/xapi/storage_migrate.ml

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -40,111 +40,6 @@ let choose_backend dbg sr =
4040
(** module [MigrateRemote] is similar to [MigrateLocal], but most of these functions
4141
tend to be executed on the receiver side. *)
4242
module MigrateRemote = struct
43-
let receive_start_common ~dbg ~sr ~vdi_info ~id ~similar ~vm =
44-
let on_fail : (unit -> unit) list ref = ref [] in
45-
let vdis = Local.SR.scan dbg sr in
46-
(* We drop cbt_metadata VDIs that do not have any actual data *)
47-
let vdis = List.filter (fun vdi -> vdi.ty <> "cbt_metadata") vdis in
48-
let leaf_dp = Local.DP.create dbg Uuidx.(to_string (make ())) in
49-
try
50-
let vdi_info = {vdi_info with sm_config= [("base_mirror", id)]} in
51-
let leaf = Local.VDI.create dbg sr vdi_info in
52-
info "Created leaf VDI for mirror receive: %s" (string_of_vdi_info leaf) ;
53-
on_fail := (fun () -> Local.VDI.destroy dbg sr leaf.vdi) :: !on_fail ;
54-
(* dummy VDI is created so that the leaf VDI becomes a differencing disk,
55-
useful for calling VDI.compose later on *)
56-
let dummy = Local.VDI.snapshot dbg sr leaf in
57-
on_fail := (fun () -> Local.VDI.destroy dbg sr dummy.vdi) :: !on_fail ;
58-
debug "%s Created dummy snapshot for mirror receive: %s" __FUNCTION__
59-
(string_of_vdi_info dummy) ;
60-
let _ : backend = Local.VDI.attach3 dbg leaf_dp sr leaf.vdi vm true in
61-
Local.VDI.activate3 dbg leaf_dp sr leaf.vdi vm ;
62-
let nearest =
63-
List.fold_left
64-
(fun acc content_id ->
65-
match acc with
66-
| Some _ ->
67-
acc
68-
| None -> (
69-
try
70-
Some
71-
(List.find
72-
(fun vdi ->
73-
vdi.content_id = content_id
74-
&& vdi.virtual_size <= vdi_info.virtual_size
75-
)
76-
vdis
77-
)
78-
with Not_found -> None
79-
)
80-
)
81-
None similar
82-
in
83-
debug "Nearest VDI: content_id=%s vdi=%s"
84-
(Option.fold ~none:"None" ~some:(fun x -> x.content_id) nearest)
85-
(Option.fold ~none:"None"
86-
~some:(fun x -> Storage_interface.Vdi.string_of x.vdi)
87-
nearest
88-
) ;
89-
let parent =
90-
match nearest with
91-
| Some vdi ->
92-
debug "Cloning VDI" ;
93-
let vdi = add_to_sm_config vdi "base_mirror" id in
94-
let vdi_clone = Local.VDI.clone dbg sr vdi in
95-
debug "Clone: %s" (Storage_interface.Vdi.string_of vdi_clone.vdi) ;
96-
( if vdi_clone.virtual_size <> vdi_info.virtual_size then
97-
let new_size =
98-
Local.VDI.resize dbg sr vdi_clone.vdi vdi_info.virtual_size
99-
in
100-
debug "Resize local clone VDI to %Ld: result %Ld"
101-
vdi_info.virtual_size new_size
102-
) ;
103-
vdi_clone
104-
| None ->
105-
debug "Creating a blank remote VDI" ;
106-
Local.VDI.create dbg sr vdi_info
107-
in
108-
debug "Parent disk content_id=%s" parent.content_id ;
109-
State.add id
110-
State.(
111-
Recv_op
112-
Receive_state.
113-
{
114-
sr
115-
; dummy_vdi= dummy.vdi
116-
; leaf_vdi= leaf.vdi
117-
; leaf_dp
118-
; parent_vdi= parent.vdi
119-
; remote_vdi= vdi_info.vdi
120-
; mirror_vm= vm
121-
}
122-
) ;
123-
let nearest_content_id = Option.map (fun x -> x.content_id) nearest in
124-
Mirror.Vhd_mirror
125-
{
126-
Mirror.mirror_vdi= leaf
127-
; mirror_datapath= leaf_dp
128-
; copy_diffs_from= nearest_content_id
129-
; copy_diffs_to= parent.vdi
130-
; dummy_vdi= dummy.vdi
131-
}
132-
with e ->
133-
List.iter
134-
(fun op ->
135-
try op ()
136-
with e ->
137-
debug "Caught exception in on_fail: %s" (Printexc.to_string e)
138-
)
139-
!on_fail ;
140-
raise e
141-
142-
let receive_start ~dbg ~sr ~vdi_info ~id ~similar =
143-
receive_start_common ~dbg ~sr ~vdi_info ~id ~similar ~vm:(Vm.of_string "0")
144-
145-
let receive_start2 ~dbg ~sr ~vdi_info ~id ~similar ~vm =
146-
receive_start_common ~dbg ~sr ~vdi_info ~id ~similar ~vm
147-
14843
let receive_finalize ~dbg ~id =
14944
let recv_state = State.find_active_receive_mirror id in
15045
let open State.Receive_state in
@@ -630,10 +525,6 @@ let killall = MigrateLocal.killall
630525

631526
let stat = MigrateLocal.stat
632527

633-
let receive_start = MigrateRemote.receive_start
634-
635-
let receive_start2 = MigrateRemote.receive_start2
636-
637528
let receive_finalize = MigrateRemote.receive_finalize
638529

639530
let receive_finalize2 = MigrateRemote.receive_finalize2

ocaml/xapi/storage_mux.ml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -826,25 +826,20 @@ module Mux = struct
826826
u "DATA.MIRROR.send_start" (* see storage_smapi{v1,v3}_migrate.ml *)
827827

828828
let receive_start () ~dbg ~sr ~vdi_info ~id ~similar =
829-
with_dbg ~name:"DATA.MIRROR.receive_start" ~dbg @@ fun di ->
829+
with_dbg ~name:"DATA.MIRROR.receive_start" ~dbg @@ fun _di ->
830830
info "%s dbg: %s sr: %s vdi_info: %s mirror_id: %s similar: %s"
831831
__FUNCTION__ dbg (s_of_sr sr)
832832
(string_of_vdi_info vdi_info)
833833
id
834834
(String.concat ";" similar) ;
835-
Storage_migrate.receive_start ~dbg:di.log ~sr ~vdi_info ~id ~similar
836-
837-
let receive_start2 () ~dbg ~sr ~vdi_info ~id ~similar ~vm =
838-
with_dbg ~name:"DATA.MIRROR.receive_start2" ~dbg @@ fun di ->
839-
info "%s dbg: %s sr: %s vdi_info: %s mirror_id: %s similar: %s vm: %s"
840-
__FUNCTION__ dbg (s_of_sr sr)
841-
(string_of_vdi_info vdi_info)
842-
id
843-
(String.concat ";" similar)
844-
(s_of_vm vm) ;
845-
info "%s dbg:%s" __FUNCTION__ dbg ;
846-
Storage_migrate.receive_start2 ~dbg:di.log ~sr ~vdi_info ~id ~similar
847-
~vm
835+
(* This goes straight to storage_smapiv1_migrate for backwards compatability
836+
reasons, new code should not call receive_start any more *)
837+
Storage_smapiv1_migrate.MIRROR.receive_start () ~dbg ~sr ~vdi_info ~id
838+
~similar
839+
840+
(** see storage_smapiv{1,3}_migrate.receive_start2 *)
841+
let receive_start2 () ~dbg:_ ~sr:_ ~vdi_info:_ ~id:_ ~similar:_ ~vm:_ =
842+
u __FUNCTION__
848843

849844
let receive_finalize () ~dbg ~id =
850845
with_dbg ~name:"DATA.MIRROR.receive_finalize" ~dbg @@ fun di ->

0 commit comments

Comments
 (0)