From 4a0b7fd50256e1866763ba6fcca00dcbfa211004 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 4 Nov 2020 21:18:51 +0000 Subject: [PATCH] zfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros They are expected to fail only in corner cases. --- .../openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h | 4 ++-- sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h index b1fe4aa86816..b50b18f8964c 100644 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h +++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h @@ -119,7 +119,7 @@ extern minor_t zfsdev_minor_alloc(void); #define ZFS_ENTER(zfsvfs) \ { \ rrm_enter_read(&(zfsvfs)->z_teardown_lock, FTAG); \ - if ((zfsvfs)->z_unmounted) { \ + if (__predict_false((zfsvfs)->z_unmounted)) { \ ZFS_EXIT(zfsvfs); \ return (EIO); \ } \ @@ -130,7 +130,7 @@ extern minor_t zfsdev_minor_alloc(void); /* Verifies the znode is valid */ #define ZFS_VERIFY_ZP(zp) \ - if ((zp)->z_sa_hdl == NULL) { \ + if (__predict_false((zp)->z_sa_hdl == NULL)) { \ ZFS_EXIT((zp)->z_zfsvfs); \ return (EIO); \ } \ diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h index 39bbd135ac06..a641210a8334 100644 --- a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h +++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h @@ -76,7 +76,7 @@ extern "C" { #define ZFS_ENTER_ERROR(zfsvfs, error) \ do { \ rrm_enter_read(&(zfsvfs)->z_teardown_lock, FTAG); \ - if ((zfsvfs)->z_unmounted) { \ + if (unlikely((zfsvfs)->z_unmounted)) { \ ZFS_EXIT(zfsvfs); \ return (error); \ } \ @@ -95,7 +95,7 @@ do { \ /* Verifies the znode is valid. */ #define ZFS_VERIFY_ZP_ERROR(zp, error) \ do { \ - if ((zp)->z_sa_hdl == NULL) { \ + if (unlikely((zp)->z_sa_hdl == NULL)) { \ ZFS_EXIT(ZTOZSB(zp)); \ return (error); \ } \