aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Guzik <[email protected]>2020-10-15 05:45:28 +0000
committerBrian Behlendorf <[email protected]>2021-03-12 15:51:03 -0800
commit446400346d2dcec222abebf0db1b0ad61f013548 (patch)
tree02fba6495920a81679cf07a5af13dd4a1fe94caf
parent0936981d8698f0f05db69bb8efeb67fe5f810d2f (diff)
Add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros
They are expected to fail only in corner cases. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matt Macy <[email protected]> Signed-off-by: Mateusz Guzik <[email protected]> Closes #11153
-rw-r--r--include/os/freebsd/zfs/sys/zfs_znode_impl.h4
-rw-r--r--include/os/linux/zfs/sys/zfs_znode_impl.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/include/os/freebsd/zfs/sys/zfs_znode_impl.h
index 186afa9b2..7a60eb58b 100644
--- a/include/os/freebsd/zfs/sys/zfs_znode_impl.h
+++ b/include/os/freebsd/zfs/sys/zfs_znode_impl.h
@@ -125,7 +125,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); \
} \
@@ -136,7 +136,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/include/os/linux/zfs/sys/zfs_znode_impl.h b/include/os/linux/zfs/sys/zfs_znode_impl.h
index b1a91f666..bcd721435 100644
--- a/include/os/linux/zfs/sys/zfs_znode_impl.h
+++ b/include/os/linux/zfs/sys/zfs_znode_impl.h
@@ -80,7 +80,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); \
} \
@@ -103,7 +103,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); \
} \