mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: Adam Moss <c@yotes.com> Closes #11704
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1734,7 +1734,11 @@ zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp)
|
||||
VERIFY(zfsctl_root_lookup(*ipp, "snapshot", ipp,
|
||||
0, kcred, NULL, NULL) == 0);
|
||||
} else {
|
||||
igrab(*ipp);
|
||||
/*
|
||||
* Must have an existing ref, so igrab()
|
||||
* cannot return NULL
|
||||
*/
|
||||
VERIFY3P(igrab(*ipp), !=, NULL);
|
||||
}
|
||||
ZFS_EXIT(zfsvfs);
|
||||
return (0);
|
||||
|
||||
@@ -593,7 +593,8 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
|
||||
|
||||
crhold(cr);
|
||||
ip->i_ctime = current_time(ip);
|
||||
igrab(ip); /* Use ihold() if available */
|
||||
/* Must have an existing ref, so igrab() cannot return NULL */
|
||||
VERIFY3P(igrab(ip), !=, NULL);
|
||||
|
||||
cookie = spl_fstrans_mark();
|
||||
error = -zfs_link(ITOZ(dir), ITOZ(ip), dname(dentry), cr, 0);
|
||||
|
||||
Reference in New Issue
Block a user