bdev: enforce documented lock requirements

Replace comments saying that particular locks must be held with
assertions that enforce that those locks are held. Remove the comments
so that there is no chance of comments and code getting out of sync in
the future.

This also fixes a caller of bdev_close() that did not hold a required
lock.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I3a540f1ad9b9826f925c523986334aa8fcd302f2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15440
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Mike Gerdts 2022-11-14 16:58:28 -06:00 committed by Jim Harris
parent 0dc6aac101
commit 6e140e3544

View File

@ -3205,13 +3205,14 @@ bdev_channel_destroy_resource(struct spdk_bdev_channel *ch)
}
}
/* Caller must hold bdev->internal.spinlock. */
static void
bdev_enable_qos(struct spdk_bdev *bdev, struct spdk_bdev_channel *ch)
{
struct spdk_bdev_qos *qos = bdev->internal.qos;
int i;
assert(spdk_spin_held(&bdev->internal.spinlock));
/* Rate limiting on this bdev enabled */
if (qos) {
if (qos->ch == NULL) {
@ -6545,8 +6546,7 @@ _remove_notify(void *arg)
spdk_spin_unlock(&desc->spinlock);
}
/* Must be called while holding g_bdev_mgr.spinlock and bdev->internal.spinlock.
* returns: 0 - bdev removed and ready to be destructed.
/* returns: 0 - bdev removed and ready to be destructed.
* -EBUSY - bdev can't be destructed yet. */
static int
bdev_unregister_unsafe(struct spdk_bdev *bdev)
@ -6555,6 +6555,9 @@ bdev_unregister_unsafe(struct spdk_bdev *bdev)
int rc = 0;
char uuid[SPDK_UUID_STRING_LEN];
assert(spdk_spin_held(&g_bdev_mgr.spinlock));
assert(spdk_spin_held(&bdev->internal.spinlock));
/* Notify each descriptor about hotremoval */
TAILQ_FOREACH_SAFE(desc, &bdev->internal.open_descs, link, tmp) {
rc = -EBUSY;
@ -6915,7 +6918,11 @@ bdev_register_finished(void *arg)
spdk_notify_send("bdev_register", spdk_bdev_get_name(bdev));
spdk_spin_lock(&g_bdev_mgr.spinlock);
bdev_close(bdev, desc);
spdk_spin_unlock(&g_bdev_mgr.spinlock);
}
int