diff options
author | Chunwei Chen <[email protected]> | 2022-09-16 13:36:47 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-16 13:36:47 -0700 |
commit | 768eacedef54922962562e601ca2c3366c4bcc4b (patch) | |
tree | ce625415ee93fd7c03c35526e048daf7c9ddefbc /include/sys | |
parent | b24d1c77f7fc53d26ee915b5203a139f13fd9791 (diff) |
zfs_enter rework
Replace ZFS_ENTER and ZFS_VERIFY_ZP, which have hidden returns, with
functions that return error code. The reason we want to do this is
because hidden returns are not obvious and had caused some missing fail
path unwinding.
This patch changes the common, linux, and freebsd parts. Also fixes
fail path unwinding in zfs_fsync, zpl_fsync, zpl_xattr_{list,get,set}, and
zfs_lookup().
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes #13831
Diffstat (limited to 'include/sys')
-rw-r--r-- | include/sys/zfs_znode.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h index b223c4b3b..7c906050b 100644 --- a/include/sys/zfs_znode.h +++ b/include/sys/zfs_znode.h @@ -218,6 +218,29 @@ typedef struct znode { ZNODE_OS_FIELDS; } znode_t; +/* Verifies the znode is valid. */ +static inline int +zfs_verify_zp(znode_t *zp) +{ + if (unlikely(zp->z_sa_hdl == NULL)) + return (SET_ERROR(EIO)); + return (0); +} + +/* zfs_enter and zfs_verify_zp together */ +static inline int +zfs_enter_verify_zp(zfsvfs_t *zfsvfs, znode_t *zp, const char *tag) +{ + int error; + if ((error = zfs_enter(zfsvfs, tag)) != 0) + return (error); + if ((error = zfs_verify_zp(zp)) != 0) { + zfs_exit(zfsvfs, tag); + return (error); + } + return (0); +} + typedef struct znode_hold { uint64_t zh_obj; /* object id */ kmutex_t zh_lock; /* lock serializing object access */ |