Quantcast

[xen stable-4.4] oxenstored: only record operations with side-effects in history

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[xen stable-4.4] oxenstored: only record operations with side-effects in history

patchbot
commit 2547b6133e3d1198a433eb5e6cb2ebc28ff4b6bd
Author:     Jonathan Davies <[hidden email]>
AuthorDate: Thu Mar 23 14:20:33 2017 +0000
Commit:     Ian Jackson <[hidden email]>
CommitDate: Wed Apr 5 15:26:38 2017 +0100

    oxenstored: only record operations with side-effects in history
   
    There is no need to record "read" operations as they will never cause another
    transaction to fail.
   
    Signed-off-by: Jonathan Davies <[hidden email]>
    Reviewed-by: Thomas Sanders <[hidden email]>
   
    Backport 4.6 -> 4.5 by removing reference to XS_RESET_WATCHES.
   
    Reported-by: Juergen Gross <[hidden email]>
    Signed-off-by: Ian Jackson <[hidden email]>
---
 tools/ocaml/xenstored/process.ml | 46 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml
index b48df05..502e1d6 100644
--- a/tools/ocaml/xenstored/process.ml
+++ b/tools/ocaml/xenstored/process.ml
@@ -443,6 +443,36 @@ let function_of_type ty =
  | _                              -> function_of_type_simple_op ty
 
 (**
+ * Determines which individual (non-transactional) operations we want to retain.
+ * We only want to retain operations that have side-effects in the store since
+ * these can be the cause of transactions failing.
+ *)
+let retain_op_in_history ty =
+ match ty with
+ | Xenbus.Xb.Op.Write
+ | Xenbus.Xb.Op.Mkdir
+ | Xenbus.Xb.Op.Rm
+ | Xenbus.Xb.Op.Setperms          -> true
+ | Xenbus.Xb.Op.Debug
+ | Xenbus.Xb.Op.Directory
+ | Xenbus.Xb.Op.Read
+ | Xenbus.Xb.Op.Getperms
+ | Xenbus.Xb.Op.Watch
+ | Xenbus.Xb.Op.Unwatch
+ | Xenbus.Xb.Op.Transaction_start
+ | Xenbus.Xb.Op.Transaction_end
+ | Xenbus.Xb.Op.Introduce
+ | Xenbus.Xb.Op.Release
+ | Xenbus.Xb.Op.Getdomainpath
+ | Xenbus.Xb.Op.Watchevent
+ | Xenbus.Xb.Op.Error
+ | Xenbus.Xb.Op.Isintroduced
+ | Xenbus.Xb.Op.Resume
+ | Xenbus.Xb.Op.Set_target
+ | Xenbus.Xb.Op.Restrict
+ | Xenbus.Xb.Op.Invalid           -> false
+
+(**
  * Nothrow guarantee.
  *)
 let process_packet ~store ~cons ~doms ~con ~req =
@@ -458,10 +488,18 @@ let process_packet ~store ~cons ~doms ~con ~req =
  Connection.get_transaction con tid
  in
 
- let before = Store.copy store in
- let response = input_handle_error ~cons ~doms ~fct ~con ~t ~req in
- let after = Store.copy store in
- if tid = Transaction.none then record_commit ~con ~tid ~before ~after;
+ let execute () = input_handle_error ~cons ~doms ~fct ~con ~t ~req in
+
+ let response =
+ (* Note that transactions are recorded in history separately. *)
+ if tid = Transaction.none && retain_op_in_history ty then begin
+ let before = Store.copy store in
+ let response = execute () in
+ let after = Store.copy store in
+ record_commit ~con ~tid ~before ~after;
+ response
+ end else execute ()
+ in
 
  let response = try
  if tid <> Transaction.none then
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.4

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog
Loading...