Avoid scheduling removal of the same bdev descriptor multiple times.
Deferred descriptor removal invocation under bdev_unregister() does not account for the possibility of bdev_unregister being entered multiple times for the same bdev (which is possible thanks to multiple paths to unregistration - consider bdev hotremove callback and _spdk_bdev_finish_unregister_bdevs_iter iterator - being present). Therefore, currently nothing prevents _remove_notify for the same bdev descriptor from being scheduled multiple times. This commit adds boolean remove_scheduled field to struct spdk_bdev_desc. The value is set when remove_notify for the descriptor is being scheduled for the first time, and checked on subsequent attempts. Change-Id: If2c5a365c05c4123c50edf5a2db164be9dd26f8e Signed-off-by: Andrey Kuzmin <andrey.v.kuzmin@gmail.com> Reviewed-on: https://review.gerrithub.io/415319 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
980ebc9790
commit
9abd8becc5
@ -240,6 +240,7 @@ struct spdk_bdev_desc {
|
||||
struct spdk_bdev *bdev;
|
||||
spdk_bdev_remove_cb_t remove_cb;
|
||||
void *remove_ctx;
|
||||
bool remove_scheduled;
|
||||
bool write;
|
||||
TAILQ_ENTRY(spdk_bdev_desc) link;
|
||||
};
|
||||
@ -2912,7 +2913,11 @@ spdk_bdev_unregister(struct spdk_bdev *bdev, spdk_bdev_unregister_cb cb_fn, void
|
||||
* we don't recursively unregister this bdev again if the remove_cb
|
||||
* immediately closes its descriptor.
|
||||
*/
|
||||
spdk_thread_send_msg(thread, _remove_notify, desc);
|
||||
if (!desc->remove_scheduled) {
|
||||
/* Avoid scheduling removal of the same descriptor multiple times. */
|
||||
desc->remove_scheduled = true;
|
||||
spdk_thread_send_msg(thread, _remove_notify, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user