WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] The checksumming for meta-data of mlvm now agrees with

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] The checksumming for meta-data of mlvm now agrees with the original lvm
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Thu, 8 Jul 2010 15:03:05 +0100
Delivery-date: Thu, 08 Jul 2010 07:17:37 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
# HG changeset patch
# User Matthias Goergens <matthias.goergens@xxxxxxxxxx>
# Date 1278597747 -3600
# Node ID 03a96a2679360d969de2641814559c60211d98b3
# Parent  9e891e13c6c0f2eefc26d4b73a1bcffb6b406792
The checksumming for meta-data of mlvm now agrees with the original lvm.

Signed-off-by: Matthias Goergens <matthias.goergens@xxxxxxxxxx>

diff -r 9e891e13c6c0 -r 03a96a267936 mlvm/pv.ml
--- a/mlvm/pv.ml        Thu Jul 08 15:00:49 2010 +0100
+++ b/mlvm/pv.ml        Thu Jul 08 15:02:27 2010 +0100
@@ -300,38 +300,40 @@
     if written <> Constants.sector_size then failwith "Wrote short!";
     Unix.close fd
       
-  let read_md dev mdah n =
-    (* debug *)
-    let oc = open_out "/tmp/hdr" in
-    Printf.fprintf oc "%s\n%!" (to_ascii mdah);
-    close_out oc;
+       let read_md dev mdah n =
+               (* debug *)
+               let oc = open_out "/tmp/hdr" in
+               Printf.fprintf oc "%s\n%!" (to_ascii mdah);
+               close_out oc;
 
-    let locn = List.nth mdah.mdah_raw_locns n in
-    let fd = 
-      if !Constants.dummy_mode then begin
-       Unix.openfile (dummy_fname dev "md") [Unix.O_RDONLY] 0o000
-      end else begin
-       let fd = Unix.openfile dev [Unix.O_RDONLY] 0o000 in
-       ignore(Unix.LargeFile.lseek fd (Int64.add mdah.mdah_start 
locn.mrl_offset) Unix.SEEK_SET);  
-       fd
-      end
-    in
-    let md = 
-      if(Int64.add locn.mrl_offset locn.mrl_size > mdah.mdah_size) 
-      then
-       let firstbit = Int64.to_int (Int64.sub mdah.mdah_size locn.mrl_offset) 
in
-       let firstbitstr = really_read fd firstbit in
-       let secondbit = (Int64.to_int locn.mrl_size) - firstbit - 1 in
-       if not !Constants.dummy_mode then ignore(Unix.LargeFile.lseek fd 
(Int64.add mdah.mdah_start 512L) Unix.SEEK_SET);  
-       let secondbitstr = really_read fd secondbit in
-       firstbitstr ^ secondbitstr
-      else
-       really_read fd (Int64.to_int locn.mrl_size - 1) in
-    let checksum = Crc.crc md Crc.initial_crc in
-    Unix.close fd;
-    if checksum <> locn.mrl_checksum then
-      Printf.fprintf stderr "Checksum invalid in metadata: Found %lx, 
expecting %lx\n" checksum locn.mrl_checksum;
-    md
+               let locn = List.nth mdah.mdah_raw_locns n in
+               let fd =
+                       if !Constants.dummy_mode then begin
+                               Unix.openfile (dummy_fname dev "md") 
[Unix.O_RDONLY] 0o000
+                       end else begin
+                               let fd = Unix.openfile dev [Unix.O_RDONLY] 
0o000 in
+                               ignore(Unix.LargeFile.lseek fd (Int64.add 
mdah.mdah_start locn.mrl_offset) Unix.SEEK_SET);
+                               fd
+                       end
+               in
+               let md =
+                       (* Include terminating \0 in this string.
+                        * The checksum calculation in original lvm does so, 
too.*)
+                       if(Int64.add locn.mrl_offset locn.mrl_size > 
mdah.mdah_size)
+                       then (* wrap around *)
+                               let firstbit = Int64.to_int (Int64.sub 
mdah.mdah_size locn.mrl_offset) in
+                               let firstbitstr = really_read fd firstbit in
+                               let secondbit = (Int64.to_int locn.mrl_size) - 
firstbit in
+                               if not !Constants.dummy_mode then 
ignore(Unix.LargeFile.lseek fd (Int64.add mdah.mdah_start 512L) Unix.SEEK_SET);
+                               let secondbitstr = really_read fd secondbit in
+                               firstbitstr ^ secondbitstr
+                       else
+                               really_read fd (Int64.to_int locn.mrl_size) in
+               let checksum = Crc.crc md Crc.initial_crc in
+               Unix.close fd;
+               if checksum <> locn.mrl_checksum then
+                       Printf.fprintf stderr "Checksum invalid in metadata: 
Found %lx, expecting %lx\n" checksum locn.mrl_checksum;
+               md
       
   let write_md device mdah md =
     (* Find the current raw location of the metadata, assuming there's only 
one copy *)
 mlvm/pv.ml |  64 +++++++++++++++++++++++++++++++------------------------------
 1 files changed, 33 insertions(+), 31 deletions(-)


Attachment: xen-api-libs.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] The checksumming for meta-data of mlvm now agrees with the original lvm, David Scott <=