Whamcloud - gitweb
LU-12374 lustre: push rcu_barrier() before destroying slab 97/35097/2
authorWang Shilong <wshilong@ddn.com>
Sat, 1 Jun 2019 11:22:11 +0000 (19:22 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Jun 2019 03:56:17 +0000 (03:56 +0000)
commit8c67c977444885abf863b656fb66721ac4515f49
tree969ce5717b5a1d442dce739eb26e4e704cb31876
parent020f774e0b0ff0f96173655744d976beb5af4a83
LU-12374 lustre: push rcu_barrier() before destroying slab

From rcubarrier.txt:

"
We could try placing a synchronize_rcu() in the module-exit code path,
but this is not sufficient. Although synchronize_rcu() does wait for a
grace period to elapse, it does not wait for the callbacks to complete.

One might be tempted to try several back-to-back synchronize_rcu()
calls, but this is still not guaranteed to work. If there is a very
heavy RCU-callback load, then some of the callbacks might be deferred
in order to allow other processing to proceed. Such deferral is required
in realtime kernels in order to avoid excessive scheduling latencies.

We instead need the rcu_barrier() primitive. This primitive is similar
to synchronize_rcu(), but instead of waiting solely for a grace
period to elapse, it also waits for all outstanding RCU callbacks to
complete. Pseudo-code using rcu_barrier() is as follows:

   1. Prevent any new RCU callbacks from being posted.
   2. Execute rcu_barrier().
   3. Allow the module to be unloaded.
"

So use synchronize_rcu() in ldlm_exit() is not safe enough, and we might
still hit use-after-free problem, also we missed rcu_barrier() when destory
inode cache, this is simiar idea what current local filesystem does.

Lustre-change: https://review.whamcloud.com/35030
Lustre-commit: 1f7613968c800f99ed074f17cd7ba1086847d2db

Change-Id: I76c7dfe7b6472d377fe1b60b0891c61ac8a0fbfc
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-on: https://review.whamcloud.com/35097
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
lustre/ldlm/ldlm_lockd.c
lustre/llite/super25.c