Commit a862d1cd authored by Pawel Wodkowski's avatar Pawel Wodkowski Committed by Jim Harris
Browse files

scsi: remove lun_db

parent c60422dd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

C_SRCS = dev.c lun.c lun_db.c port.c scsi.c scsi_bdev.c scsi_rpc.c task.c
C_SRCS = dev.c lun.c port.c scsi.c scsi_bdev.c scsi_rpc.c task.c
LIBNAME = scsi

include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
+0 −15
Original line number Diff line number Diff line
@@ -284,12 +284,6 @@ spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev,
		return NULL;
	}

	lun = spdk_lun_db_get_lun(name);
	if (lun) {
		SPDK_ERRLOG("LUN %s already created\n", lun->name);
		return NULL;
	}

	lun = calloc(1, sizeof(*lun));
	if (lun == NULL) {
		SPDK_ERRLOG("could not allocate lun\n");
@@ -313,14 +307,6 @@ spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev,
	lun->hotremove_cb = hotremove_cb;
	lun->hotremove_ctx = hotremove_ctx;

	rc = spdk_scsi_lun_db_add(lun);
	if (rc < 0) {
		SPDK_ERRLOG("Unable to add LUN %s to DB\n", lun->name);
		spdk_bdev_close(lun->bdev_desc);
		free(lun);
		return NULL;
	}

	return lun;
}

@@ -329,7 +315,6 @@ spdk_scsi_lun_destruct(struct spdk_scsi_lun *lun)
{
	spdk_bdev_close(lun->bdev_desc);
	spdk_poller_unregister(&lun->hotplug_poller);
	spdk_scsi_lun_db_delete(lun);

	free(lun);

lib/scsi/lun_db.c

deleted100644 → 0
+0 −95
Original line number Diff line number Diff line
/*-
 *   BSD LICENSE
 *
 *   Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>.
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *     * Neither the name of Intel Corporation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "scsi_internal.h"

struct spdk_lun_db_entry *spdk_scsi_lun_list_head = NULL;

int
spdk_scsi_lun_db_add(struct spdk_scsi_lun *lun)
{
	struct spdk_lun_db_entry *new_entry = calloc(1, sizeof(struct spdk_lun_db_entry));

	if (!new_entry) {
		SPDK_ERRLOG("Failed to allocate DB entry\n");
		return -ENOMEM;
	}

	new_entry->lun = lun;
	new_entry->next = spdk_scsi_lun_list_head;
	spdk_scsi_lun_list_head = new_entry;

	return 0;
}

int
spdk_scsi_lun_db_delete(struct spdk_scsi_lun *lun)
{
	struct spdk_lun_db_entry *prev = NULL;
	struct spdk_lun_db_entry *node = spdk_scsi_lun_list_head;

	while (node != NULL) {
		if (node->lun == lun) {
			if (prev != NULL) {
				prev->next = node->next;
			} else {
				spdk_scsi_lun_list_head = node->next;
			}
			free(node);
			break;
		}
		prev = node;
		node = node->next;
	}

	return 0;
}

struct spdk_scsi_lun *
spdk_lun_db_get_lun(const char *lun_name)
{
	struct spdk_lun_db_entry *current = spdk_scsi_lun_list_head;

	while (current != NULL) {
		struct spdk_scsi_lun *lun = current->lun;

		if (strncmp(lun_name, lun->name, sizeof(lun->name)) == 0) {
			return lun;
		}

		current = current->next;
	}

	return NULL;
}
+0 −5
Original line number Diff line number Diff line
@@ -141,11 +141,6 @@ int spdk_scsi_lun_allocate_io_channel(struct spdk_scsi_lun *lun);
void spdk_scsi_lun_free_io_channel(struct spdk_scsi_lun *lun);
bool spdk_scsi_lun_has_pending_tasks(const struct spdk_scsi_lun *lun);

int spdk_scsi_lun_db_add(struct spdk_scsi_lun *lun);
int spdk_scsi_lun_db_delete(struct spdk_scsi_lun *lun);

struct spdk_scsi_lun *spdk_lun_db_get_lun(const char *lun_name);

struct spdk_scsi_dev *spdk_scsi_dev_get_list(void);

int spdk_scsi_port_construct(struct spdk_scsi_port *port, uint64_t id,
+0 −38
Original line number Diff line number Diff line
@@ -37,44 +37,6 @@
#include "spdk/rpc.h"
#include "spdk/util.h"

static void
spdk_rpc_get_luns(struct spdk_jsonrpc_request *request,
		  const struct spdk_json_val *params)
{
	struct spdk_json_write_ctx *w;
	struct spdk_lun_db_entry *current;

	if (params != NULL) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "get_luns requires no parameters");
		return;
	}

	w = spdk_jsonrpc_begin_result(request);
	if (w == NULL) {
		return;
	}

	spdk_json_write_array_begin(w);

	current = spdk_scsi_lun_list_head;
	while (current != NULL) {
		struct spdk_scsi_lun *lun = current->lun;

		spdk_json_write_object_begin(w);
		spdk_json_write_name(w, "name");
		spdk_json_write_string(w, lun->name);
		spdk_json_write_object_end(w);

		current = current->next;
	}

	spdk_json_write_array_end(w);

	spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("get_luns", spdk_rpc_get_luns)

static void
spdk_rpc_get_scsi_devices(struct spdk_jsonrpc_request *request,
			  const struct spdk_json_val *params)
Loading