sbin/hammer: Fix bug in get_buffer_data()
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 17 Dec 2016 11:26:17 +0000 (20:26 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 17 Dec 2016 18:48:50 +0000 (03:48 +0900)
commite4323571a2e8310683120148b720a92f801c618f
tree696163f6623d6155f30c1011b07ad88aedee19e6
parent0942cbbcb0916b68533d8df4fad644f2021041d5
sbin/hammer: Fix bug in get_buffer_data()

The previous commit made clear that xor part of get_buffer_data()
was wrong. Since buf_offset is in any zone not limited to zone-2,
xor of two offsets doesn't necessarily show the right result to
know whether they belong to the same buffer, even if ->zone2_offset
is originally translated from the same zone within the same buffer.

It needs to take xor of long offsets instead of full 64 bits.

The reason cache releasing is now limited to directly translated
zones is because for indirectly translated zones (i.e. undo zone),
it can't tell overlap by xor of offsets regardless of long format.

Prior to this commit, get_buffer_data() has been releasing buffers
that don't need to be released (i.e. *bufferp being the right cache),
and has resulted in huge overhead as shown in below comparison.
In the first example, get_buffer_data() is releasing *bufferp for
undo fifo entries everytime when it doesn't need to release.

-- Prior to this commit
 # time newfs_hammer -L TEST /dev/da4
 Volume 0 DEVICE /dev/da4        size   4.55TB
 initialize freemap volume 0
 initializing the undo map (1024 MB)
 ---------------------------------------------
 HAMMER version 6
 1 volume total size   4.55TB
 root-volume:         /dev/da4
 boot-area-size:       32.00KB
 memory-log-size:     256.00KB
 undo-buffer-size:      1.00GB
 total-pre-allocated:   1.02GB
 <snip>
 newfs_hammer -L TEST /dev/da4  3.05s user 1.16s system 41% cpu 10.098 total

-- Using this commit
 # time newfs_hammer -L TEST /dev/da4
 Volume 0 DEVICE /dev/da4        size   4.55TB
 initialize freemap volume 0
 initializing the undo map (1024 MB)
 ---------------------------------------------
 HAMMER version 6
 1 volume total size   4.55TB
 root-volume:         /dev/da4
 boot-area-size:       32.00KB
 memory-log-size:     256.00KB
 undo-buffer-size:      1.00GB
 total-pre-allocated:   1.02GB
 <snip>
 newfs_hammer -L TEST /dev/da4  2.72s user 0.04s system 73% cpu 3.755 total
sbin/hammer/ondisk.c