4556609 [rkeene@sledge /home/rkeene/tmp]$ cat ceph-rbd-cp-not-consistent.txt
1. Seems to be point-in-time consistent at first:
	root@ceph-test:~# rbd create --size 2048 test
	root@ceph-test:~# rbd map test 
	/dev/rbd1
	root@ceph-test:~# openssl sha1 /dev/rbd1
	SHA1(/dev/rbd1)= 91d50642dd930e9542c39d36f0516d45f4e1af0d
	root@ceph-test:~# rbd cp test test1 & ( sleep 0.3; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1 ) &
	[1] 14008
	[2] 14009
	Image copy: 18% complete...1+0 records in
	1+0 records out
	1024 bytes (1.0 kB) copied, 0.0121455 s, 84.3 kB/s
	Image copy: 100% complete...done.

	[1]-  Done                    rbd cp test test1
	[2]+  Done                    ( sleep 0.3; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1 )
	root@ceph-test:~# rbd map test1
	/dev/rbd2
	root@ceph-test:~# openssl sha1 /dev/rbd2
	SHA1(/dev/rbd2)= 91d50642dd930e9542c39d36f0516d45f4e1af0d
	root@ceph-test:~# openssl sha1 /dev/rbd1 
	SHA1(/dev/rbd1)= 52a8313306bd3141a28c2186baa74fff224588e8

Because it already copied the first 1KB during the cloning, so the source image changed and the destnation did not.

Let's prove that by changing the end of the image.

2. RBD now has the CHANGED image:
	root@ceph-test:~# openssl sha1 /dev/rbd1 
	SHA1(/dev/rbd1)= 52a8313306bd3141a28c2186baa74fff224588e8
	root@ceph-test:~# rbd cp test test2 & ( sleep 0.3; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1 seek=$[1024*2040] ) &
	[1] 14629
	[2] 14630
	Image copy: 11% complete...1+0 records in
	1+0 records out
	1024 bytes (1.0 kB) copied, 0.0166253 s, 61.6 kB/s
	Image copy: 100% complete...done.
	
	[1]-  Done                    rbd cp test test2
	[2]+  Done                    ( sleep 0.3; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1 seek=$[1024*2040] )
	root@ceph-test:~# rbd map test2
	/dev/rbd3
	root@ceph-test:~# openssl sha1 /dev/rbd3
	SHA1(/dev/rbd3)= 45ead44d2e81f3b2b67cb8bfa93b2cefe9c9c670
	root@ceph-test:~# openssl sha1 /dev/rbd1
	SHA1(/dev/rbd1)= 45ead44d2e81f3b2b67cb8bfa93b2cefe9c9c670

3. So we should be able to, by combining these, to make the destination not match the source or destination image:
	root@ceph-test:~# openssl sha1 /dev/rbd1
	SHA1(/dev/rbd1)= 45ead44d2e81f3b2b67cb8bfa93b2cefe9c9c670
	root@ceph-test:~# rbd cp test test3 & ( sleep 0.3; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1 seek=$[1024*2040] ) &
	[1] 15605
	[2] 15606
	Image copy: 18% complete...1+0 records in
	1+0 records out
	1024 bytes (1.0 kB) copied, 0.0105316 s, 97.2 kB/s
	1+0 records in
	1+0 records out
	1024 bytes (1.0 kB) copied, 0.00195211 s, 525 kB/s
	Image copy: 100% complete...done.
	
	[1]-  Done                    rbd cp test test3
	[2]+  Done                    ( sleep 0.3; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1; dd if=/dev/urandom of=/dev/rbd1 bs=1024 count=1 seek=$[1024*2040] )
	root@ceph-test:~# rbd map test3
	/dev/rbd4
	root@ceph-test:~# openssl sha1 /dev/rbd4
	SHA1(/dev/rbd4)= 4e9a4de72b5fbe0e20b7885385554ec708ed892b
	root@ceph-test:~# openssl sha1 /dev/rbd1
	SHA1(/dev/rbd1)= 4a3c9a9ae67f4facf0e9dbf34e07fdf8057fccd1
	root@ceph-test:~# 

4556610 [rkeene@sledge /home/rkeene/tmp]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2015-06-25 13:15:53