net/smc: replace mutex rmbs_lock and sndbufs_lock with rw_semaphore
authorD. Wythe <alibuda@linux.alibaba.com>
Thu, 2 Feb 2023 08:26:42 +0000 (16:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Aug 2023 15:52:18 +0000 (17:52 +0200)
commit206381cee964c26547173be36280991bebd9ebcc
tree25575504262fd1a853ec9a71655b2bba032dd159
parent0fc3c55a3a4b0ef635e2cc6f32417649de49b0d2
net/smc: replace mutex rmbs_lock and sndbufs_lock with rw_semaphore

[ Upstream commit aff7bfed9097435ea38de919befbe2d7771a3e87 ]

It's clear that rmbs_lock and sndbufs_lock are aims to protect the
rmbs list or the sndbufs list.

During connection establieshment, smc_buf_get_slot() will always
be invoked, and it only performs read semantics in rmbs list and
sndbufs list.

Based on the above considerations, we replace mutex with rw_semaphore.
Only smc_buf_get_slot() use down_read() to allow smc_buf_get_slot()
run concurrently, other part use down_write() to keep exclusive
semantics.

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 833bac7ec392 ("net/smc: Fix setsockopt and sysctl to specify same buffer size again")
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/smc/smc_core.c
net/smc/smc_core.h
net/smc/smc_llc.c