lvmsync 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/lvmsync +14 -2
- data/lib/lvm/helpers.rb +12 -3
- data/lib/lvm/snapshot.rb +3 -3
- metadata +4 -4
data/bin/lvmsync
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
#
|
20
20
|
require 'optparse'
|
21
21
|
require 'lvm'
|
22
|
+
require 'git-version-bump'
|
22
23
|
|
23
24
|
PROTOCOL_VERSION = "lvmsync PROTO[3]"
|
24
25
|
|
@@ -30,8 +31,9 @@ def main()
|
|
30
31
|
OptionParser.new do |opts|
|
31
32
|
opts.banner = "Usage: lvmsync [options]"
|
32
33
|
opts.separator ""
|
33
|
-
opts.separator " lvmsync [--snapback <file>] <snapshot device> [--stdout | [<desthost>:]<destdevice>]"
|
34
|
-
opts.separator " lvmsync [--snapback <file>] --apply <changes file> <destdevice>"
|
34
|
+
opts.separator " lvmsync [-v|--verbose] [--snapback <file>] <snapshot device> [--stdout | [<desthost>:]<destdevice>]"
|
35
|
+
opts.separator " lvmsync [-v|--verbose] [--snapback <file>] --apply <changes file> <destdevice>"
|
36
|
+
opts.separator " lvmsync <-V|--version>"
|
35
37
|
opts.separator ""
|
36
38
|
|
37
39
|
opts.on("--server", "Run in server mode (deprecated; use '--apply -' instead)") do |v|
|
@@ -50,6 +52,16 @@ def main()
|
|
50
52
|
opts.on("-s", "--stdout", "Write output data to stdout rather than another lvmsync process") do |v|
|
51
53
|
options[:stdout] = true
|
52
54
|
end
|
55
|
+
opts.on("-V", "--version", "Print version of lvmsync") do |v|
|
56
|
+
begin
|
57
|
+
puts "lvmsync #{GVB.version}"
|
58
|
+
exit 0
|
59
|
+
rescue GVB::VersionUnobtainable
|
60
|
+
$stderr.puts "Unable to determine lvmsync version."
|
61
|
+
$stderr.puts "Install lvmsync as a gem, or run it from within a git checkout"
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
end
|
53
65
|
end.parse!
|
54
66
|
|
55
67
|
if options[:apply]
|
data/lib/lvm/helpers.rb
CHANGED
@@ -3,16 +3,25 @@ module LVM; end
|
|
3
3
|
module LVM::Helpers
|
4
4
|
# Are we on a big-endian system? Needed for our htonq/ntohq methods
|
5
5
|
def big_endian?
|
6
|
-
@
|
6
|
+
@big_endian ||= [1].pack("s") == [1].pack("n")
|
7
7
|
end
|
8
8
|
|
9
9
|
def htonq val
|
10
10
|
# This won't work on a nUxi byte-order machine, but if you have one of
|
11
11
|
# those, I'm guessing you've got bigger problems
|
12
|
-
big_endian? ? val : (
|
12
|
+
big_endian? ? val : swap_longs(val)
|
13
13
|
end
|
14
14
|
|
15
15
|
def ntohq val
|
16
|
-
|
16
|
+
big_endian? ? val : swap_longs(val)
|
17
|
+
end
|
18
|
+
|
19
|
+
# On-disk (LVM) format (which is little-endian) to host byte order
|
20
|
+
def dtohq val
|
21
|
+
big_endian? ? swap_longs(val) : val
|
22
|
+
end
|
23
|
+
|
24
|
+
def swap_longs val
|
25
|
+
[val].pack("Q").reverse.unpack("Q").first
|
17
26
|
end
|
18
27
|
end
|
data/lib/lvm/snapshot.rb
CHANGED
@@ -30,15 +30,15 @@ class LVM::Snapshot
|
|
30
30
|
|
31
31
|
while in_progress
|
32
32
|
# The snapshot on-disk format is a stream of <blocklist>, <blockdata>
|
33
|
-
# sets; within each <blocklist>, it's
|
33
|
+
# sets; within each <blocklist>, it's little-endian 64-bit block
|
34
34
|
# IDs -- the first is the location (chunk_size * offset) in the origin
|
35
35
|
# LV that the data has been changed, the second is the location (again,
|
36
36
|
# chunk_size * offset) in the metadata LV where the changed data is
|
37
37
|
# being stored.
|
38
38
|
(chunk_size / 16).times do
|
39
39
|
origin_offset, snap_offset = metafd.read(16).unpack("QQ")
|
40
|
-
origin_offset =
|
41
|
-
snap_offset =
|
40
|
+
origin_offset = dtohq(origin_offset)
|
41
|
+
snap_offset = dtohq(snap_offset)
|
42
42
|
|
43
43
|
# A snapshot offset of 0 would point back to the metadata
|
44
44
|
# device header, so that's clearly invalid -- hence it's the
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lvmsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: git-version-bump
|
@@ -221,7 +221,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
segments:
|
223
223
|
- 0
|
224
|
-
hash: -
|
224
|
+
hash: -3110588239684965704
|
225
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
226
|
none: false
|
227
227
|
requirements:
|
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
230
|
version: '0'
|
231
231
|
segments:
|
232
232
|
- 0
|
233
|
-
hash: -
|
233
|
+
hash: -3110588239684965704
|
234
234
|
requirements: []
|
235
235
|
rubyforge_project:
|
236
236
|
rubygems_version: 1.8.23
|