FreeBSD: Parameterize ZFS_ENTER/ZFS_VERIFY_VP with an error code
For legacy reasons, a couple of VOPs have to return error numbers that don't come from the usual errno namespace. To handle the cases where ZFS_ENTER or ZFS_VERIFY_ZP fail, we need to be able to override the default error return value of EIO. Extend the macros to permit this. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Mark Johnston <markj@FreeBSD.org> Closes #13311
This commit is contained in:
parent
35d81a75a8
commit
e9084d0712
|
@ -121,25 +121,29 @@ typedef struct zfs_soft_state {
|
||||||
#define zn_rlimit_fsize(zp, uio) \
|
#define zn_rlimit_fsize(zp, uio) \
|
||||||
vn_rlimit_fsize(ZTOV(zp), GET_UIO_STRUCT(uio), zfs_uio_td(uio))
|
vn_rlimit_fsize(ZTOV(zp), GET_UIO_STRUCT(uio), zfs_uio_td(uio))
|
||||||
|
|
||||||
|
#define ZFS_ENTER_ERROR(zfsvfs, error) do { \
|
||||||
|
ZFS_TEARDOWN_ENTER_READ((zfsvfs), FTAG); \
|
||||||
|
if (__predict_false((zfsvfs)->z_unmounted)) { \
|
||||||
|
ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \
|
||||||
|
return (error); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* Called on entry to each ZFS vnode and vfs operation */
|
/* Called on entry to each ZFS vnode and vfs operation */
|
||||||
#define ZFS_ENTER(zfsvfs) \
|
#define ZFS_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, EIO)
|
||||||
{ \
|
|
||||||
ZFS_TEARDOWN_ENTER_READ((zfsvfs), FTAG); \
|
|
||||||
if (__predict_false((zfsvfs)->z_unmounted)) { \
|
|
||||||
ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \
|
|
||||||
return (EIO); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Must be called before exiting the vop */
|
/* Must be called before exiting the vop */
|
||||||
#define ZFS_EXIT(zfsvfs) ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG)
|
#define ZFS_EXIT(zfsvfs) ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG)
|
||||||
|
|
||||||
|
#define ZFS_VERIFY_ZP_ERROR(zp, error) do { \
|
||||||
|
if (__predict_false((zp)->z_sa_hdl == NULL)) { \
|
||||||
|
ZFS_EXIT((zp)->z_zfsvfs); \
|
||||||
|
return (error); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* Verifies the znode is valid */
|
/* Verifies the znode is valid */
|
||||||
#define ZFS_VERIFY_ZP(zp) \
|
#define ZFS_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, EIO)
|
||||||
if (__predict_false((zp)->z_sa_hdl == NULL)) { \
|
|
||||||
ZFS_EXIT((zp)->z_zfsvfs); \
|
|
||||||
return (EIO); \
|
|
||||||
} \
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros for dealing with dmu_buf_hold
|
* Macros for dealing with dmu_buf_hold
|
||||||
|
|
|
@ -5451,7 +5451,7 @@ zfs_getextattr(struct vop_getextattr_args *ap)
|
||||||
|
|
||||||
error = ENOENT;
|
error = ENOENT;
|
||||||
ZFS_ENTER(zfsvfs);
|
ZFS_ENTER(zfsvfs);
|
||||||
ZFS_VERIFY_ZP(zp)
|
ZFS_VERIFY_ZP(zp);
|
||||||
rw_enter(&zp->z_xattr_lock, RW_READER);
|
rw_enter(&zp->z_xattr_lock, RW_READER);
|
||||||
|
|
||||||
error = zfs_getextattr_impl(ap, zfs_xattr_compat);
|
error = zfs_getextattr_impl(ap, zfs_xattr_compat);
|
||||||
|
|
Loading…
Reference in New Issue