diff options
author | Chunwei Chen <[email protected]> | 2015-04-02 02:18:05 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-04-24 14:57:54 -0700 |
commit | 07012da668c2fa50ff469137e71262d45e0cd16e (patch) | |
tree | 88ec584d55294ca7e8e397697b832afc5ce54693 | |
parent | 59199d90832a7e99ff73f8e75e33d74e12ddcf93 (diff) |
Fix kernel panic due to tsd_exit in ZFS_EXIT(zsb)
The following panic would occur under certain heavy load:
[ 4692.202686] Kernel panic - not syncing: thread ffff8800c4f5dd60 terminating with rrw lock ffff8800da1b9c40 held
[ 4692.228053] CPU: 1 PID: 6250 Comm: mmap_deadlock Tainted: P OE 3.18.10 #7
The culprit is that ZFS_EXIT(zsb) would call tsd_exit() every time, which
would purge all tsd data for the thread. However, ZFS_ENTER is designed to be
reentrant, so we cannot allow ZFS_EXIT to blindly purge tsd data.
Instead, we rely on the new behavior of tsd_set. When NULL is passed as the
new value to tsd_set, it will automatically remove the tsd entry specified the
the key for the current thread.
rrw_tsd_key and zfs_allow_log_key already calls tsd_set(key, NULL) when
they're done. The zfs_fsyncer_key relied on ZFS_EXIT(zsb) to call tsd_exit() to
do clean up. Now we explicitly call tsd_set(key, NULL) on them.
Signed-off-by: Chunwei Chen <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3247
-rw-r--r-- | include/sys/zfs_znode.h | 1 | ||||
-rw-r--r-- | module/zfs/zfs_vnops.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h index 4bb8a7761..a6b82d574 100644 --- a/include/sys/zfs_znode.h +++ b/include/sys/zfs_znode.h @@ -263,7 +263,6 @@ typedef struct znode { #define ZFS_EXIT(zsb) \ { \ rrw_exit(&(zsb)->z_teardown_lock, FTAG); \ - tsd_exit(); \ } /* Verifies the znode is valid */ diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 723d6210f..5ce8a1e98 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -2156,6 +2156,8 @@ zfs_fsync(struct inode *ip, int syncflag, cred_t *cr) zil_commit(zsb->z_log, zp->z_id); ZFS_EXIT(zsb); } + tsd_set(zfs_fsyncer_key, NULL); + return (0); } EXPORT_SYMBOL(zfs_fsync); |