SUNRPC: make rqst_should_sleep() idempotent()
authorNeilBrown <neilb@suse.de>
Mon, 31 Jul 2023 06:48:28 +0000 (16:48 +1000)
committerChuck Lever <chuck.lever@oracle.com>
Tue, 29 Aug 2023 21:45:22 +0000 (17:45 -0400)
commit6859d1f2902c600f6b1c587c91408a91e05cdc02
treee2930bdc74c22147444e9bcf843f3ac9e375398e
parentd2f0ef1cbf37e396ef9c57a30c004ebe65cdbca9
SUNRPC: make rqst_should_sleep() idempotent()

Based on its name you would think that rqst_should_sleep() would be
read-only, not changing anything.  But in fact it will clear
SP_TASK_PENDING if that was set.  This is surprising, and it blurs the
line between "check for work to do" and "dequeue work to do".

So change the "test_and_clear" to simple "test" and clear the bit once
the thread has decided to wake up and return to the caller.

With this, it makes sense to *always* set SP_TASK_PENDING when asked,
rather than to set it only if no thread could be woken up.

[ cel: Previously TASK_PENDING indicated there is work waiting but no
idle threads were found to pick up that work. After this patch, it acts
as an XPT_BUSY flag for wake-ups that have no associated xprt. ]

Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/svc_xprt.c