sbin/hammer: Fix/refactor check_data_crc()
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 27 Mar 2016 11:56:14 +0000 (20:56 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 27 Mar 2016 16:03:09 +0000 (01:03 +0900)
commit3fd1e952cb2f26187833a14e7b4115f59505b33d
tree6ad665d8e05837daaa0fba3ce62fc5a743d3c457
parentaa933af86b5d1a8aa5d117dab1281f10fbe5039d
sbin/hammer: Fix/refactor check_data_crc()

Separate inode CRC from other CRC checks.
The only reason this function goes into while(data_len) loop is
because HAMMER userspace can only support upto 16KB buffer data
whereas inode is always 128 byte.

CRC check should look something similar to the kernel function
hammer_crc_test_leaf() in order to keep maintainability.

Also blockmap_lookup() doesn't need to be inside the while loop.
It only needs to verify zone offset once for each record data.

Also use return value of blockmap_lookup() which is zone2 offset
instead of using non-zone2 offset for get_buffer_data().
get_buffer() does extra blockmap lookup if offset is not zone-2.
sbin/hammer/cmd_show.c