Skip to content

Commit 82dfbd5

Browse files
authored
Merge pull request xapi-project#3329 from mcintyre94/private/callumiandam/CA-271014-master
[CA-271014] Only get local SRs on the physical utilisation thread
2 parents 3d24692 + 6142f97 commit 82dfbd5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

ocaml/xapi/helpers.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,20 @@ let i_am_srmaster ~__context ~sr =
10121012
get_srmaster ~__context ~sr = get_localhost ~__context
10131013

10141014
let get_all_plugged_srs ~__context =
1015-
let pbds = Db.PBD.get_all ~__context in
1016-
let pbds_plugged_in = List.filter (fun self -> Db.PBD.get_currently_attached ~__context ~self) pbds in
1015+
let pbds_plugged_in = Db.PBD.get_refs_where ~__context ~expr:(
1016+
Eq (Field "currently_attached", Literal "true")) in
10171017
List.setify (List.map (fun self -> Db.PBD.get_SR ~__context ~self) pbds_plugged_in)
10181018

1019+
let get_local_plugged_srs ~__context =
1020+
let localhost = get_localhost __context in
1021+
let localhost = Ref.string_of localhost in
1022+
let my_pbds_plugged_in = Db.PBD.get_refs_where ~__context ~expr:(And (
1023+
Eq (Field "host", Literal localhost),
1024+
Eq (Field "currently_attached", Literal "true")
1025+
))
1026+
in
1027+
List.setify (List.map (fun self -> Db.PBD.get_SR ~__context ~self) my_pbds_plugged_in)
1028+
10191029
let find_health_check_task ~__context ~sr =
10201030
Db.Task.get_refs_where ~__context ~expr:(And (
10211031
Eq (Field "name__label", Literal Xapi_globs.sr_health_check_task_label),

ocaml/xapi/xapi_sr.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ let physical_utilisation_thread ~__context () =
665665
let sr_cache : bool SRMap.t ref = ref SRMap.empty in
666666

667667
let srs_to_update () =
668-
let plugged_srs = Helpers.get_all_plugged_srs ~__context in
668+
let plugged_srs = Helpers.get_local_plugged_srs ~__context in
669669
(* Remove SRs that are no longer plugged *)
670670
sr_cache := SRMap.filter (fun sr _ -> List.mem sr plugged_srs) !sr_cache;
671671
(* Cache wether we should manage stats for newly plugged SRs *)

0 commit comments

Comments
 (0)