From: Hongbo Li <lihongbo22@huawei.com> hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/release-management/issues/ID5W1P ------------------ The mfs destroys all events during device release. However, when numerous events are linked in the xarray, destroying them can be time-consuming. This operation is guarded by a spinlock that disables preemption. Therefore, it is preferable to allow scheduling while destroying all events. Fixes: 3236f3b541d1 ("mfs: Add communication devie and event acquisition operations") Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- fs/mfs/cache.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/fs/mfs/cache.c b/fs/mfs/cache.c index 994638065f85..2675fe58b781 100644 --- a/fs/mfs/cache.c +++ b/fs/mfs/cache.c @@ -399,28 +399,33 @@ void mfs_cancel_all_events(struct mfs_sb_info *sbi) struct mfs_event *event; unsigned long index; - xa_lock(xa); - xa_for_each(xa, index, event) { - __xa_erase(xa, index); - syncer = event->syncer; - /* - * Here should keep syncer (a stack variable), so we should - * wakeup the syncer list in the protect of xa lock. - */ - if (syncer) { - spin_lock(&syncer->list_lock); - list_del(&event->link); - spin_unlock(&syncer->list_lock); - if (atomic_dec_return(&syncer->notback) == 0) { - atomic_cmpxchg(&syncer->res, 0, -EIO); - complete(&syncer->done); + while (!xa_empty(xa)) { + xa_lock(xa); + xa_for_each(xa, index, event) { + __xa_erase(xa, index); + syncer = event->syncer; + /* + * Here should keep syncer (a stack variable), so we should + * wakeup the syncer list in the protect of xa lock. + */ + if (syncer) { + spin_lock(&syncer->list_lock); + list_del(&event->link); + spin_unlock(&syncer->list_lock); + if (atomic_dec_return(&syncer->notback) == 0) { + atomic_cmpxchg(&syncer->res, 0, -EIO); + complete(&syncer->done); + } } + put_mfs_event(event); + if (need_resched()) + break; } - put_mfs_event(event); + xa_unlock(xa); + cond_resched(); } caches->next_ev = 0; caches->next_msg = 0; - xa_unlock(xa); } int try_hook_fd(struct mfs_event *event) -- 2.25.1