Commit a6b1e2c5 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

lib/bdev: remove deprecated spdk_bdev_open()



spdk_bdev_open() was deprecated in SPDK 19.10.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I12f51a237ddc43219d35b5c647dc60d10461d429
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6626


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 47afb928
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
For `bdev_ocssd_create` RPC, the optional parameter `range` was removed.
Only one OCSSD bdev can be created for one OCSSD namespace.

Removed the `spdk_bdev_open` from bdev library API.

### blobstore

Removed the `spdk_bdev_create_bs_dev_from_desc` and `spdk_bdev_create_bs_dev` API.
+2 −19
Original line number Diff line number Diff line
@@ -332,23 +332,6 @@ struct spdk_bdev *spdk_bdev_first_leaf(void);
 */
struct spdk_bdev *spdk_bdev_next_leaf(struct spdk_bdev *prev);

/**
 * Open a block device for I/O operations (deprecated, please use spdk_bdev_open_ext).
 *
 * \param bdev Block device to open.
 * \param write true is read/write access requested, false if read-only
 * \param remove_cb notification callback to be called when the bdev gets
 * hotremoved. This will always be called on the same thread that
 * spdk_bdev_open() was called on. It can be NULL, in which case the upper
 * layer won't be notified about the bdev hotremoval. The descriptor will
 * have to be manually closed to make the bdev unregister proceed.
 * \param remove_ctx param for remove_cb.
 * \param desc output parameter for the descriptor when operation is successful
 * \return 0 if operation is successful, suitable errno value otherwise
 */
int spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t remove_cb,
		   void *remove_ctx, struct spdk_bdev_desc **desc);

/**
 * Open a block device for I/O operations.
 *
@@ -356,7 +339,7 @@ int spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t rem
 * \param write true is read/write access requested, false if read-only
 * \param event_cb notification callback to be called when the bdev triggers
 * asynchronous event such as bdev removal. This will always be called on the
 * same thread that spdk_bdev_open() was called on. In case of removal event
 * same thread that spdk_bdev_open_ext() was called on. In case of removal event
 * the descriptor will have to be manually closed to make the bdev unregister
 * proceed.
 * \param event_ctx param for event_cb.
@@ -369,7 +352,7 @@ int spdk_bdev_open_ext(const char *bdev_name, bool write, spdk_bdev_event_cb_t e
/**
 * Close a previously opened block device.
 *
 * Must be called on the same thread that the spdk_bdev_open()
 * Must be called on the same thread that the spdk_bdev_open_ext()
 * was performed on.
 *
 * \param desc Block device descriptor to close.
+3 −58
Original line number Diff line number Diff line
@@ -304,11 +304,7 @@ struct spdk_bdev_desc {
	struct spdk_bdev		*bdev;
	struct spdk_thread		*thread;
	struct {
		bool open_with_ext;
		union {
			spdk_bdev_remove_cb_t remove_fn;
		spdk_bdev_event_cb_t event_fn;
		};
		void *ctx;
	}				callback;
	bool				closed;
@@ -3463,7 +3459,7 @@ spdk_bdev_notify_blockcnt_change(struct spdk_bdev *bdev, uint64_t size)
		bdev->blockcnt = size;
		TAILQ_FOREACH(desc, &bdev->internal.open_descs, link) {
			pthread_mutex_lock(&desc->mutex);
			if (desc->callback.open_with_ext && !desc->closed) {
			if (!desc->closed) {
				desc->refs++;
				spdk_thread_send_msg(desc->thread, _resize_notify, desc);
			}
@@ -5566,11 +5562,7 @@ _remove_notify(void *arg)

	if (!desc->closed) {
		pthread_mutex_unlock(&desc->mutex);
		if (desc->callback.open_with_ext) {
		desc->callback.event_fn(SPDK_BDEV_EVENT_REMOVE, desc->bdev, desc->callback.ctx);
		} else {
			desc->callback.remove_fn(desc->callback.ctx);
		}
		return;
	} else if (0 == desc->refs) {
		/* This descriptor was closed after this remove_notify message was sent.
@@ -5659,12 +5651,6 @@ spdk_bdev_unregister(struct spdk_bdev *bdev, spdk_bdev_unregister_cb cb_fn, void
	}
}

static void
bdev_dummy_event_cb(void *remove_ctx)
{
	SPDK_DEBUGLOG(bdev, "Bdev remove event received with no remove callback specified");
}

static int
bdev_start_qos(struct spdk_bdev *bdev)
{
@@ -5732,46 +5718,6 @@ bdev_open(struct spdk_bdev *bdev, bool write, struct spdk_bdev_desc *desc)
	return 0;
}

int
spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t remove_cb,
	       void *remove_ctx, struct spdk_bdev_desc **_desc)
{
	struct spdk_bdev_desc *desc;
	int rc;

	desc = calloc(1, sizeof(*desc));
	if (desc == NULL) {
		SPDK_ERRLOG("Failed to allocate memory for bdev descriptor\n");
		return -ENOMEM;
	}

	if (remove_cb == NULL) {
		remove_cb = bdev_dummy_event_cb;
	}

	TAILQ_INIT(&desc->pending_media_events);
	TAILQ_INIT(&desc->free_media_events);

	desc->callback.open_with_ext = false;
	desc->callback.remove_fn = remove_cb;
	desc->callback.ctx = remove_ctx;
	pthread_mutex_init(&desc->mutex, NULL);

	pthread_mutex_lock(&g_bdev_mgr.mutex);

	rc = bdev_open(bdev, write, desc);
	if (rc != 0) {
		bdev_desc_free(desc);
		desc = NULL;
	}

	*_desc = desc;

	pthread_mutex_unlock(&g_bdev_mgr.mutex);

	return rc;
}

int
spdk_bdev_open_ext(const char *bdev_name, bool write, spdk_bdev_event_cb_t event_cb,
		   void *event_ctx, struct spdk_bdev_desc **_desc)
@@ -5806,7 +5752,6 @@ spdk_bdev_open_ext(const char *bdev_name, bool write, spdk_bdev_event_cb_t event
	TAILQ_INIT(&desc->pending_media_events);
	TAILQ_INIT(&desc->free_media_events);

	desc->callback.open_with_ext = true;
	desc->callback.event_fn = event_cb;
	desc->callback.ctx = event_ctx;
	pthread_mutex_init(&desc->mutex, NULL);