Skip to content

Commit

Permalink
Fix a race condition in zfs_getattr_fast()
Browse files Browse the repository at this point in the history
zfs_getattr_fast() was missing a lock on the ZFS superblock which
could result in zfs_znode_dmu_fini() clearing the zp->z_sa_hdl member
while zfs_getattr_fast() was accessing the znode. The result of this
would usually be a panic.

Signed-off-by: Brian Behlendorf <[email protected]>
Fixes openzfs#431
  • Loading branch information
gunnarbeutner authored and behlendorf committed Nov 3, 2011
1 parent c475167 commit a7b125e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,9 @@ zfs_getattr_fast(struct inode *ip, struct kstat *sp)
znode_t *zp = ITOZ(ip);
zfs_sb_t *zsb = ITOZSB(ip);

ZFS_ENTER(zsb);
ZFS_VERIFY_ZP(zp);

mutex_enter(&zp->z_lock);

generic_fillattr(ip, sp);
Expand All @@ -2316,6 +2319,8 @@ zfs_getattr_fast(struct inode *ip, struct kstat *sp)

mutex_exit(&zp->z_lock);

ZFS_EXIT(zsb);

return (0);
}
EXPORT_SYMBOL(zfs_getattr_fast);
Expand Down

0 comments on commit a7b125e

Please sign in to comment.