Skip to content

Commit

Permalink
Add cond_resched to zfs_zget to prevent infinite loop
Browse files Browse the repository at this point in the history
It's been reported that threads would loop infinitely inside zfs_zget. The
speculated cause for this is that if an inode is marked for evict, zfs_zget
would see that and loop. However, if the looping thread doesn't yield, the
inode may not have a chance to finish evict, thus causing a infinite loop.

This patch solve this issue by add cond_resched to zfs_zget, making the
looping thread to yield when needed.

Tested-by: jlavoy <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3349
  • Loading branch information
tuxoko authored and nedbass committed Jun 23, 2015
1 parent 3a25380 commit 71fa174
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/zfs/zfs_znode.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ zfs_zget(zfs_sb_t *zsb, uint64_t obj_num, znode_t **zpp)
mutex_exit(&zp->z_lock);
sa_buf_rele(db, NULL);
ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
/* inode might need this to finish evict */
cond_resched();
goto again;
}
*zpp = zp;
Expand Down

0 comments on commit 71fa174

Please sign in to comment.