diff options
author | Adam D. Moss <[email protected]> | 2021-03-16 16:33:34 -0700 |
---|---|---|
committer | Tony Hutter <[email protected]> | 2021-06-23 13:22:15 -0700 |
commit | ac6f3321545a0b82b6b84e7fec6cf62e619d824b (patch) | |
tree | 92eea47471cefa76c87a36a226f363bf75b90244 /include/os/linux | |
parent | f14b6f23024aaa78fe2c8582f982b88fdcaf8232 (diff) |
Linux: always check or verify return of igrab()
zhold() wraps igrab() on Linux, and igrab() may fail when the inode
is in the process of being deleted. This means zhold() must only be
called when a reference exists and therefore it cannot be deleted.
This is the case for all existing consumers so add a VERIFY and a
comment explaining this requirement.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Adam Moss <[email protected]>
Closes #11704
Diffstat (limited to 'include/os/linux')
-rw-r--r-- | include/os/linux/zfs/sys/zfs_znode_impl.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/os/linux/zfs/sys/zfs_znode_impl.h b/include/os/linux/zfs/sys/zfs_znode_impl.h index f17b8eb67..79049df69 100644 --- a/include/os/linux/zfs/sys/zfs_znode_impl.h +++ b/include/os/linux/zfs/sys/zfs_znode_impl.h @@ -73,7 +73,13 @@ extern "C" { #define zn_has_cached_data(zp) ((zp)->z_is_mapped) #define zn_rlimit_fsize(zp, uio, td) (0) -#define zhold(zp) igrab(ZTOI((zp))) +/* + * zhold() wraps igrab() on Linux, and igrab() may fail when the + * inode is in the process of being deleted. As zhold() must only be + * called when a ref already exists - so the inode cannot be + * mid-deletion - we VERIFY() this. + */ +#define zhold(zp) VERIFY3P(igrab(ZTOI((zp))), !=, NULL) #define zrele(zp) iput(ZTOI((zp))) /* Called on entry to each ZFS inode and vfs operation. */ |