IB/uverbs: Fix to consider event queue closing also upon non-blocking mode
authorYishai Hadas <yishaih@nvidia.com>
Mon, 5 Jun 2023 10:33:25 +0000 (13:33 +0300)
committerLeon Romanovsky <leon@kernel.org>
Sun, 11 Jun 2023 08:27:12 +0000 (11:27 +0300)
commit62fab312fa1683e812e605db20d4f22de3e3fb2f
tree9b2e17db3a45b1230ad446eab0cf8af677957cfc
parent0cadb4db79e1d9eea66711c4031e435c2191907e
IB/uverbs: Fix to consider event queue closing also upon non-blocking mode

Fix ib_uverbs_event_read() to consider event queue closing also upon
non-blocking mode.

Once the queue is closed (e.g. hot-plug flow) all the existing events
are cleaned-up as part of ib_uverbs_free_event_queue().

An application that uses the non-blocking FD mode should get -EIO in
that case to let it knows that the device was removed already.

Otherwise, it can loose the indication that the device was removed and
won't recover.

As part of that, refactor the code to have a single flow with regards to
'is_closed' for both blocking and non-blocking modes.

Fixes: 14e23bd6d221 ("RDMA/core: Fix locking in ib_uverbs_event_read")
Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/97b00116a1e1e13f8dc4ec38a5ea81cf8c030210.1685960567.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/core/uverbs_main.c