mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Improve zfs_blkptr_verify()
- Skip config lock enter/exit for embedded blocks. They have no DVAs, so there is nothing to check under the lock. - Skip CHECKSUM check and properly check PSIZE for embedded blocks. - Add static branch predictions for unlikely conditions. - Do not verify DVAs for blocks already in ARC. ARC hit already "verified" the first (often the only) DVA, and it does not worth to enter/exit config lock for nothing. Some profiles show me up to 3% of CPU saving from this change. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Allan Jude <allan@klarasystems.com> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #16387
This commit is contained in:
+26
-13
@@ -5576,19 +5576,6 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
|
||||
*/
|
||||
fstrans_cookie_t cookie = spl_fstrans_mark();
|
||||
top:
|
||||
/*
|
||||
* Verify the block pointer contents are reasonable. This should
|
||||
* always be the case since the blkptr is protected by a checksum.
|
||||
* However, if there is damage it's desirable to detect this early
|
||||
* and treat it as a checksum error. This allows an alternate blkptr
|
||||
* to be tried when one is available (e.g. ditto blocks).
|
||||
*/
|
||||
if (!zfs_blkptr_verify(spa, bp, (zio_flags & ZIO_FLAG_CONFIG_WRITER) ?
|
||||
BLK_CONFIG_HELD : BLK_CONFIG_NEEDED, BLK_VERIFY_LOG)) {
|
||||
rc = SET_ERROR(ECKSUM);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!embedded_bp) {
|
||||
/*
|
||||
* Embedded BP's have no DVA and require no I/O to "read".
|
||||
@@ -5608,6 +5595,18 @@ top:
|
||||
(hdr->b_l1hdr.b_pabd != NULL && !encrypted_read))) {
|
||||
boolean_t is_data = !HDR_ISTYPE_METADATA(hdr);
|
||||
|
||||
/*
|
||||
* Verify the block pointer contents are reasonable. This
|
||||
* should always be the case since the blkptr is protected by
|
||||
* a checksum.
|
||||
*/
|
||||
if (!zfs_blkptr_verify(spa, bp, BLK_CONFIG_SKIP,
|
||||
BLK_VERIFY_LOG)) {
|
||||
mutex_exit(hash_lock);
|
||||
rc = SET_ERROR(ECKSUM);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (HDR_IO_IN_PROGRESS(hdr)) {
|
||||
if (*arc_flags & ARC_FLAG_CACHED_ONLY) {
|
||||
mutex_exit(hash_lock);
|
||||
@@ -5761,6 +5760,20 @@ top:
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify the block pointer contents are reasonable. This
|
||||
* should always be the case since the blkptr is protected by
|
||||
* a checksum.
|
||||
*/
|
||||
if (!zfs_blkptr_verify(spa, bp,
|
||||
(zio_flags & ZIO_FLAG_CONFIG_WRITER) ?
|
||||
BLK_CONFIG_HELD : BLK_CONFIG_NEEDED, BLK_VERIFY_LOG)) {
|
||||
if (hash_lock != NULL)
|
||||
mutex_exit(hash_lock);
|
||||
rc = SET_ERROR(ECKSUM);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (hdr == NULL) {
|
||||
/*
|
||||
* This block is not in the cache or it has
|
||||
|
||||
Reference in New Issue
Block a user