bdev: remove bdev_opened_for_write restriction

This restriction causes bdevs examination/discovery to fail
when there are asynchronous operations. We should remove this
limitation for now. Future plan is to implement approach
similar to the one that is present in kernel.

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: Ibe5572297672022412d25a4a835dc9527ce97f3e
Reviewed-on: https://review.gerrithub.io/378758
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Maciej Szwed 2017-09-18 14:15:34 +02:00 committed by Jim Harris
parent 564524a7dd
commit c783caabc7
4 changed files with 5 additions and 23 deletions

View File

@ -224,8 +224,6 @@ struct spdk_bdev {
bool bdev_opened;
bool bdev_opened_for_write;
/**
* Pointer to the module that has claimed this bdev for purposes of creating virtual
* bdevs on top of it. Set to NULL if the bdev has not been claimed.

View File

@ -1481,7 +1481,6 @@ _spdk_bdev_register(struct spdk_bdev *bdev)
TAILQ_INIT(&bdev->open_descs);
bdev->bdev_opened = false;
bdev->bdev_opened_for_write = false;
TAILQ_INIT(&bdev->vbdevs);
TAILQ_INIT(&bdev->base_bdevs);
@ -1605,8 +1604,8 @@ spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t remove_
pthread_mutex_lock(&bdev->mutex);
if (write && (bdev->bdev_opened_for_write || bdev->claim_module)) {
SPDK_ERRLOG("failed, %s already opened for write or claimed\n", bdev->name);
if (write && bdev->claim_module) {
SPDK_ERRLOG("failed, %s already claimed\n", bdev->name);
free(desc);
pthread_mutex_unlock(&bdev->mutex);
return -EPERM;
@ -1614,10 +1613,6 @@ spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t remove_
TAILQ_INSERT_TAIL(&bdev->open_descs, desc, link);
if (write) {
bdev->bdev_opened_for_write = true;
}
bdev->bdev_opened = true;
desc->bdev = bdev;
@ -1639,11 +1634,6 @@ spdk_bdev_close(struct spdk_bdev_desc *desc)
pthread_mutex_lock(&bdev->mutex);
if (desc->write) {
assert(bdev->bdev_opened_for_write);
bdev->bdev_opened_for_write = false;
}
bdev->bdev_opened = false;
TAILQ_REMOVE(&bdev->open_descs, desc, link);
@ -1669,13 +1659,7 @@ spdk_bdev_module_claim_bdev(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
return -EPERM;
}
if ((!desc || !desc->write) && bdev->bdev_opened_for_write) {
SPDK_ERRLOG("bdev %s already opened with write access\n", bdev->name);
return -EPERM;
}
if (desc && !desc->write) {
bdev->bdev_opened_for_write = true;
desc->write = true;
}

View File

@ -54,8 +54,8 @@ spdk_rpc_dump_bdev_info(struct spdk_json_write_ctx *w,
spdk_json_write_name(w, "num_blocks");
spdk_json_write_uint64(w, spdk_bdev_get_num_blocks(bdev));
spdk_json_write_name(w, "bdev_opened_for_write");
spdk_json_write_bool(w, bdev->bdev_opened_for_write);
spdk_json_write_name(w, "claimed");
spdk_json_write_bool(w, (bdev->claim_module != NULL));
spdk_json_write_name(w, "supported_io_types");
spdk_json_write_object_begin(w);

View File

@ -38,7 +38,7 @@ fi
timing_exit nbd
timing_enter bdev_svc
bdevs=$(discover_bdevs $rootdir $testdir/bdev.conf | jq -r '.[] | select(.bdev_opened_for_write == false)')
bdevs=$(discover_bdevs $rootdir $testdir/bdev.conf | jq -r '.[] | select(.claimed == false)')
timing_exit bdev_svc
if [ -d /usr/src/fio ] && [ $SPDK_RUN_ASAN -eq 0 ]; then