aboutsummaryrefslogtreecommitdiffstats
path: root/module/os/linux/zfs/zfs_ctldir.c
diff options
context:
space:
mode:
authorAdam D. Moss <[email protected]>2021-03-16 16:33:34 -0700
committerGitHub <[email protected]>2021-03-16 16:33:34 -0700
commit1daad98176d18a785d116d9666dadc866f631f98 (patch)
treead4a4bb806f02a98f3ceb3f6f7ada1639620689e /module/os/linux/zfs/zfs_ctldir.c
parent5f9d61d06b5a2df87d8d5733429cf4eba66f0acb (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 'module/os/linux/zfs/zfs_ctldir.c')
-rw-r--r--module/os/linux/zfs/zfs_ctldir.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/module/os/linux/zfs/zfs_ctldir.c b/module/os/linux/zfs/zfs_ctldir.c
index a1668e46e..d33188f38 100644
--- a/module/os/linux/zfs/zfs_ctldir.c
+++ b/module/os/linux/zfs/zfs_ctldir.c
@@ -590,7 +590,8 @@ struct inode *
zfsctl_root(znode_t *zp)
{
ASSERT(zfs_has_ctldir(zp));
- igrab(ZTOZSB(zp)->z_ctldir);
+ /* Must have an existing ref, so igrab() cannot return NULL */
+ VERIFY3P(igrab(ZTOZSB(zp)->z_ctldir), !=, NULL);
return (ZTOZSB(zp)->z_ctldir);
}