I'd been trying to track down a behavioural difference between
non-crc and crc enabled filesystems that was resulting non-crc
filesystem executing prefetch almost 3x faster than CRC filesystems.
After amny ratholes, I finally stumbled on the fact that btree
format directories are not being prefetched due to a missing magic
number check, and it's rejecting all XFS_BMAP_CRC_MAGIC format BMBT
buffers. This makes prefetch on CRC enabled filesystems behave the
same as for non-CRC filesystems.
The difference a single line of code can make on a 50 million inode
filesystem with a single threaded prefetch enabled run is pretty
amazing. It goes from 3,000 iops @ 50MB/s to 2,000 IOPS @ 800MB/s
and the cache hit rate goes from 3% to 49%. The runtime difference:
Unpatched:
Phase Start End Duration
Phase 1: 02/21 18:34:12 02/21 18:34:12
Phase 2: 02/21 18:34:12 02/21 18:34:15 3 seconds
Phase 3: 02/21 18:34:15 02/21 18:40:09 5 minutes, 54 seconds
Phase 4: 02/21 18:40:09 02/21 18:46:36 6 minutes, 27 seconds
Phase 5: 02/21 18:46:36 02/21 18:46:37 1 second
Phase 6: 02/21 18:46:37 02/21 18:52:51 6 minutes, 14 seconds
Phase 7: 02/21 18:52:51 02/21 18:52:52 1 second
Total run time: 18 minutes, 40 seconds
Patched:
Phase Start End Duration
Phase 1: 02/21 19:58:23 02/21 19:58:23
Phase 2: 02/21 19:58:23 02/21 19:58:27 4 seconds
Phase 3: 02/21 19:58:27 02/21 19:59:20 53 seconds
Phase 4: 02/21 19:59:20 02/21 20:00:07 47 seconds
Phase 5: 02/21 20:00:07 02/21 20:00:08 1 second
Phase 6: 02/21 20:00:08 02/21 20:00:50 42 seconds
Phase 7: 02/21 20:00:50 02/21 20:00:50
Total run time: 2 minutes, 27 seconds
Is no less impressive. Shame it's just a regression fix. ;)
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
/*
* do some validation on the block contents
*/
- if ((be32_to_cpu(block->bb_magic) != XFS_BMAP_MAGIC) ||
+ if ((block->bb_magic != cpu_to_be32(XFS_BMAP_MAGIC) &&
+ block->bb_magic != cpu_to_be32(XFS_BMAP_CRC_MAGIC)) ||
(be16_to_cpu(block->bb_level) != level))
return 0;