Skip to content

Commit

Permalink
Replace Xapi_sr.scan with Xapi_sr.scan2
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Vincent-lau committed Sep 4, 2024
1 parent b01cdbe commit 23c4a0c
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions ocaml/xapi/xapi_sr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -820,19 +787,15 @@ 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 =
Db.VDI.get_records_where ~__context
~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)
Expand Down

0 comments on commit 23c4a0c

Please sign in to comment.