From 23c4a0c5b16b6f0bc4e909c90171bc39b3860d6d Mon Sep 17 00:00:00 2001 From: Vincent Liu Date: Thu, 29 Aug 2024 17:13:41 +0100 Subject: [PATCH] Replace Xapi_sr.scan with Xapi_sr.scan2 In other words rename scan2 to scan and delete the original scan implementation. This is fine since the function signature remains the same, but internally Xapi_sr.scan will now call SR.scan2 rather than SR.scan. scans in other places, such as storage_mux.ml are left untouched for backwards compatability. Signed-off-by: Vincent Liu --- ocaml/xapi/xapi_sr.ml | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/ocaml/xapi/xapi_sr.ml b/ocaml/xapi/xapi_sr.ml index 5856cab4ad3..fc7e5dd768a 100644 --- a/ocaml/xapi/xapi_sr.ml +++ b/ocaml/xapi/xapi_sr.ml @@ -776,39 +776,6 @@ let update_vdis ~__context ~sr db_vdis vdi_infos = ) to_update -let scan2 ~__context ~sr = - let open Storage_access in - let task = Context.get_task_id __context in - let module C = Storage_interface.StorageAPI (Idl.Exn.GenClient (struct - let rpc = rpc - end)) in - let sr' = Ref.string_of sr in - SRScanThrottle.execute (fun () -> - transform_storage_exn (fun () -> - let sr_uuid = Db.SR.get_uuid ~__context ~self:sr in - let vs, sr_info = - C.SR.scan2 (Ref.string_of task) - (Storage_interface.Sr.of_string sr_uuid) - in - let db_vdis = - Db.VDI.get_records_where ~__context - ~expr:(Eq (Field "SR", Literal sr')) - in - update_vdis ~__context ~sr db_vdis vs ; - let virtual_allocation = - List.fold_left Int64.add 0L - (List.map (fun v -> v.Storage_interface.virtual_size) vs) - in - Db.SR.set_virtual_allocation ~__context ~self:sr - ~value:virtual_allocation ; - Db.SR.set_physical_size ~__context ~self:sr ~value:sr_info.total_space ; - Db.SR.set_physical_utilisation ~__context ~self:sr - ~value:(Int64.sub sr_info.total_space sr_info.free_space) ; - Db.SR.remove_from_other_config ~__context ~self:sr ~key:"dirty" ; - Db.SR.set_clustered ~__context ~self:sr ~value:sr_info.clustered - ) - ) - (* Perform a scan of this locally-attached SR *) let scan ~__context ~sr = let open Storage_access in @@ -820,8 +787,8 @@ let scan ~__context ~sr = SRScanThrottle.execute (fun () -> transform_storage_exn (fun () -> let sr_uuid = Db.SR.get_uuid ~__context ~self:sr in - let vs = - C.SR.scan (Ref.string_of task) + let vs, sr_info = + C.SR.scan2 (Ref.string_of task) (Storage_interface.Sr.of_string sr_uuid) in let db_vdis = @@ -829,10 +796,6 @@ let scan ~__context ~sr = ~expr:(Eq (Field "SR", Literal sr')) in update_vdis ~__context ~sr db_vdis vs ; - let sr_info = - C.SR.stat (Ref.string_of task) - (Storage_interface.Sr.of_string sr_uuid) - in let virtual_allocation = List.fold_left Int64.add 0L (List.map (fun v -> v.Storage_interface.virtual_size) vs)