Skip to content

Commit bd19737

Browse files
PaulZ-98tonyhutter
authored andcommitted
Do not hash unlinked inodes
In zfs_znode_alloc we always hash inodes. If the znode is unlinked, we do not need to hash it. This fixes the problem where zfs_suspend_fs is doing zrele (iput) in an async fashion, and zfs_resume_fs unlinked drain processing will try to hash an inode that could still be hashed, resulting in a panic. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alan Somers <[email protected]> Signed-off-by: Paul Zuchowski <[email protected]> Closes #9741 Closes #11223 Closes #11648 Closes #12210
1 parent cd2bb9c commit bd19737

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

module/os/linux/zfs/zfs_znode.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,17 +610,24 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
610610
* number is already hashed for this super block. This can never
611611
* happen because the inode numbers map 1:1 with the object numbers.
612612
*
613-
* The one exception is rolling back a mounted file system, but in
614-
* this case all the active inode are unhashed during the rollback.
613+
* Exceptions include rolling back a mounted file system, either
614+
* from the zfs rollback or zfs recv command.
615+
*
616+
* Active inodes are unhashed during the rollback, but since zrele
617+
* can happen asynchronously, we can't guarantee they've been
618+
* unhashed. This can cause hash collisions in unlinked drain
619+
* processing so do not hash unlinked znodes.
615620
*/
616-
VERIFY3S(insert_inode_locked(ip), ==, 0);
621+
if (links > 0)
622+
VERIFY3S(insert_inode_locked(ip), ==, 0);
617623

618624
mutex_enter(&zfsvfs->z_znodes_lock);
619625
list_insert_tail(&zfsvfs->z_all_znodes, zp);
620626
zfsvfs->z_nr_znodes++;
621627
mutex_exit(&zfsvfs->z_znodes_lock);
622628

623-
unlock_new_inode(ip);
629+
if (links > 0)
630+
unlock_new_inode(ip);
624631
return (zp);
625632

626633
error:

0 commit comments

Comments
 (0)