Skip to content
Snippets Groups Projects
Commit 08290fd5 authored by Raphael S. Carvalho's avatar Raphael S. Carvalho Committed by Pekka Enberg
Browse files

zfs: Fix zfs_inactive on unlinked znode cases


This patch addresses a corner-case in our zfs_inactive which can potentially
leak a znode object.

*** Some background on znode/zfs_inactive ***
- Used to deallocate fs-specific data.

- Before destroying the znode, a DMU transaction is created to sync the znode
to the backing store *if* its z_atime_dirty is set (Not relevant to this
patch though).

- When removing a link, zfs_remove sets the field zp->z_unlinked of the
underlying znode if the number of links reached 0 (Simply put, not present in
the fs anymore).

*** The problem ***
The actual problem shows up when zfs_inactive is used on znodes with the
unlinked field set.

The code wrapped around by this patch was previously added to speed up the call
to vrecycle, whose name partially explains itself. Its first functionality is
to eliminate all activity associated to the vnode, then put the vnode back into
a list of free vnodes.

OSv VFS layer doesn't support vrecycle, but our zfs_inactive is acting as if it
were supported. Another thing is that vrecycle call was also removed.

*** Solution ***
Let's fix this problem by simply wrapping around the test which prevented
zfs_inactive from working properly on unlinked znodes, thus leaking references
to the underlying mount point afterwards.

The commentary added into zfs_inactive also explains why these changes are
needed. It would also make things easier when people look at it in the future,
and try to understand why things are the way they are.

Reviewed-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
Signed-off-by: default avatarRaphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 76c0caa7
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment