ZFS: always consistent on disk (parte 2)

Con il precedente articolo abbiamo analizzato il comportamento di ZFS in caso di danneggiamento di alcuni blocchi su disco vediamo cosa accade mettendo a disposizione del filesystem un minimo di ridondanza. Negli esempi utilizzerò due dischi in mirroring, tuttavia lo stesso identico discorso vale in caso di utilizzo di RAIDZ.

ATTENZIONE: i test comportano l’alterazione dei dati presenti nei dischi utilizzati nei pool, quindi effettuate questi test su filesystem di prova, che non contengono dati e sopratutto A VOSTRO RISCHIO E PERICOLO!!!!

Anche qui andiamo a creare il nostro pool e un filesystem al suo interno, copiamo un file e andiamo a leggere il suo Object-ID:

$ mkfile 150m disk1 disk2
$ pfexec zpool create testPool mirror `pwd`/disk1 `pwd`/disk2
$ pfexec zfs create testPool/fs1
$ pfexec zpool status testPool
  pool: testPool
 state: ONLINE
 scrub: none requested
config:

	NAME                                      STATE     READ WRITE CKSUM
	testPool                                  ONLINE       0     0     0
	  mirror-0                                ONLINE       0     0     0
	    /export/home/luca/itl-osug/zfs/disk1  ONLINE       0     0     0
	    /export/home/luca/itl-osug/zfs/disk2  ONLINE       0     0     0

errors: No known data errors
$ pfexec cp /etc/bash/bash_completion /testPool/fs1/
$ ls -li /testPool/fs1/
total 1
5 -rwxr-xr-x 1 root root 217434 2009-12-16 11:29 bash_completion*

ora identifichiamo il DVA del primo blocco dati del nostro file ricorrendo sempre al tool zdb(1M):

$ pfexec zdb -ddddd testPool/fs1 5
Dataset testPool/fs1 [ZPL], ID 30, cr_txg 6, 280K, 5 objects,
rootbp DVA[0]=<0:5a600:200> DVA[1]=<0:1c1a600:200> [L0 DMU objset]
fletcher4 lzjb LE contiguous unique double size=800L/200P
birth=9L/9P fill=5
cksum=15c4f5e074:7dbede02443:17c06031a984a:31d9454fbe4275

    Object  lvl   iblk   dblk  dsize  lsize   %full  type
         5    2    16K   128K   258K   256K  100.00  ZFS plain file
                                        264   bonus  ZFS znode
	dnode flags: USED_BYTES USERUSED_ACCOUNTED
	dnode maxblkid: 1
	path	/bash_completion
	uid     0
	gid     0
	atime	Wed Dec 16 11:29:43 2009
	mtime	Wed Dec 16 11:29:43 2009
	ctime	Wed Dec 16 11:29:43 2009
	crtime	Wed Dec 16 11:29:43 2009
	gen	9
	mode	100755
	size	217434
	parent	3
	links	1
	xattr	0
	rdev	0x0000000000000000
Indirect blocks:
               0 L1  0:55a00:400 4000L/400P F=2 B=9/9
               0  L0 0:15800:20000 20000L/20000P F=1 B=9/9
           20000  L0 0:35800:20000 20000L/20000P F=1 B=9/9

		segment [0000000000000000, 0000000000040000) size  256K

e come al solito esportiamo il filesystem, spezzettiamo il disco, sporchiamo il settore che inizia al blocco 0x15800, ricomponiamo il tutto e rimontiamo il filesystem:

$ pfexec zpool export testPool
$ ./zsplit.sh disk1 0x15800
8364+0 records in
8364+0 records out
4282368 bytes (4.3 MB) copied, 0.101551 s, 42.2 MB/s
256+0 records in
256+0 records out
131072 bytes (131 kB) copied, 0.00645801 s, 20.3 MB/s
298580+0 records in
298580+0 records out
152872960 bytes (153 MB) copied, 3.40133 s, 44.9 MB/s
$ head disk1-p2
#
# This file contains an example set of shell completions that can be used with
# bash(1).  These completions allow a user to complete filenames, commands
# name, command line options, and command line arguments using the [tab] key.
# The completions defined here are specific to the GNU command set, as a result
# they will provide the choice of GNU command line options in response to the
# [tab] key.  For the completed options to match the command implementation,
# you may have to have /usr/gnu/bin at the head of your PATH.
#
# These completions are not included in the default bash(1) environment.  To
$ sed "s/ file / FILE /g" disk1-p2 > disk1-p2-bad
$ cat disk1-p1 disk1-p2-bad disk1-p3 > disk1
$ pfexec zpool import -d `pwd` testPool
$ pfexec zpool status testPool
  pool: testPool
 state: ONLINE
 scrub: none requested
config:

	NAME                                      STATE     READ WRITE CKSUM
	testPool                                  ONLINE       0     0     0
	  mirror-0                                ONLINE       0     0     0
	    /export/home/luca/itl-osug/zfs/disk1  ONLINE       0     0     0
	    /export/home/luca/itl-osug/zfs/disk2  ONLINE       0     0     0

errors: No known data errors

proviamo ad accedere al nostro file:

$ head /testPool/fs1/bash_completion
#
# This file contains an example set of shell completions that can be used with
# bash(1).  These completions allow a user to complete filenames, commands
# name, command line options, and command line arguments using the [tab] key.
# The completions defined here are specific to the GNU command set, as a result
# they will provide the choice of GNU command line options in response to the
# [tab] key.  For the completed options to match the command implementation,
# you may have to have /usr/gnu/bin at the head of your PATH.
#
# These completions are not included in the default bash(1) environment.  To
$ pfexec zpool status testPool
  pool: testPool
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
	attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
	using 'zpool clear' or replace the device with 'zpool replace'.
   see: http://www.sun.com/msg/ZFS-8000-9P
 scrub: none requested
config:

	NAME                                      STATE     READ WRITE CKSUM
	testPool                                  ONLINE       0     0     0
	  mirror-0                                ONLINE       0     0     0
	    /export/home/luca/itl-osug/zfs/disk1  ONLINE       0     0     1
	    /export/home/luca/itl-osug/zfs/disk2  ONLINE       0     0     0

errors: No known data errors

in questo caso siamo riusciti ad accedere al nostro file e tutto sembra essere al suo posto, tuttavia lo status di ZFS ci riporta che è stato riscontrato un errore di checksum nel disco numero 1 (quello da noi alterato) e ci “invita” a prendere qualche decisione in merito (sostituire il disco oppure azzerare il conteggio degli errorri)!!

Nella terza ed ultima parte scopriremo come aumentare la sicurezza dei nostri dati anche disponendo di un solo disco fisso.

1 comment to ZFS: always consistent on disk (parte 2)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>