scsi: remove lun_db
Change-Id: Icc40b66cd0c6f63242bc3d3f26b34f323450c570 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/393501 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
c60422dd96
commit
a862d1cdd6
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -1,95 +0,0 @@
|
||||
/*-
|
||||
* 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;
|
||||
}
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -82,12 +82,6 @@ def jsonrpc_call(method, params={}):
|
||||
|
||||
return response['result']
|
||||
|
||||
def get_luns(args):
|
||||
print_dict(jsonrpc_call('get_luns'))
|
||||
|
||||
p = subparsers.add_parser('get_luns', help='Display active LUNs')
|
||||
p.set_defaults(func=get_luns)
|
||||
|
||||
|
||||
def get_portal_groups(args):
|
||||
print_dict(jsonrpc_call('get_portal_groups'))
|
||||
|
@ -161,21 +161,13 @@ def verify_scsi_devices_rpc_methods(rpc_py):
|
||||
print "verify_scsi_devices_rpc_methods passed"
|
||||
|
||||
|
||||
def verify_luns_rpc_methods(rpc_py, rpc_param):
|
||||
def create_malloc_bdevs_rpc_methods(rpc_py, rpc_param):
|
||||
rpc = spdk_rpc(rpc_py)
|
||||
output = rpc.get_luns()
|
||||
jsonvalue = json.loads(output)
|
||||
verify(not jsonvalue, 1,
|
||||
"get_luns returned {}, expected empty".format(jsonvalue))
|
||||
|
||||
for i in range(1, rpc_param['lun_total'] + 1):
|
||||
rpc.construct_malloc_bdev(rpc_param['malloc_bdev_size'], rpc_param['malloc_block_size'])
|
||||
output = rpc.get_luns()
|
||||
jsonvalue = json.loads(output)
|
||||
verify(not jsonvalue, 1,
|
||||
"get_luns returned {}, expected empty".format(jsonvalue))
|
||||
|
||||
print "verify_luns_rpc_methods passed"
|
||||
print "create_malloc_bdevs_rpc_methods passed"
|
||||
|
||||
|
||||
def verify_portal_groups_rpc_methods(rpc_py, rpc_param):
|
||||
@ -421,7 +413,7 @@ if __name__ == "__main__":
|
||||
verify_trace_flag_rpc_methods(rpc_py, rpc_param)
|
||||
verify_get_interfaces(rpc_py)
|
||||
verify_add_delete_ip_address(rpc_py)
|
||||
verify_luns_rpc_methods(rpc_py, rpc_param)
|
||||
create_malloc_bdevs_rpc_methods(rpc_py, rpc_param)
|
||||
verify_portal_groups_rpc_methods(rpc_py, rpc_param)
|
||||
verify_initiator_groups_rpc_methods(rpc_py, rpc_param)
|
||||
verify_target_nodes_rpc_methods(rpc_py, rpc_param)
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
#include "task.c"
|
||||
#include "lun.c"
|
||||
#include "lun_db.c"
|
||||
|
||||
#include "spdk_internal/mock.h"
|
||||
|
||||
@ -610,27 +609,6 @@ lun_construct_success(void)
|
||||
CU_ASSERT_EQUAL(g_task_count, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
lun_construct_same_same_twice(void)
|
||||
{
|
||||
struct spdk_scsi_lun *lun, *lun2;
|
||||
struct spdk_bdev bdev, bdev2;
|
||||
|
||||
lun = spdk_scsi_lun_construct("lun0", &bdev, NULL, NULL);
|
||||
|
||||
/* Successfully constructs and returns lun */
|
||||
SPDK_CU_ASSERT_FATAL(lun != NULL);
|
||||
|
||||
lun2 = spdk_scsi_lun_construct("lun0", &bdev2, NULL, NULL);
|
||||
|
||||
/* Fails to construct the same lun on another bdev and returns NULL */
|
||||
CU_ASSERT(lun2 == NULL);
|
||||
|
||||
lun_destruct(lun);
|
||||
|
||||
CU_ASSERT_EQUAL(g_task_count, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
lun_delete(void)
|
||||
{
|
||||
@ -690,7 +668,6 @@ main(int argc, char **argv)
|
||||
|| CU_add_test(suite, "destruct task - success", lun_destruct_success) == NULL
|
||||
|| CU_add_test(suite, "construct - null ctx", lun_construct_null_ctx) == NULL
|
||||
|| CU_add_test(suite, "construct - success", lun_construct_success) == NULL
|
||||
|| CU_add_test(suite, "construct - same lun twice", lun_construct_same_same_twice) == NULL
|
||||
|| CU_add_test(suite, "lun_delete", lun_delete) == NULL
|
||||
) {
|
||||
CU_cleanup_registry();
|
||||
|
@ -216,7 +216,6 @@ for (( i=0; i<$vm_count; i++)); do
|
||||
done
|
||||
|
||||
$rpc_py get_vhost_controllers
|
||||
$rpc_py get_luns
|
||||
|
||||
# Run VMs
|
||||
vm_run $used_vms
|
||||
@ -275,7 +274,6 @@ clean_lvol_cfg
|
||||
$rpc_py get_lvol_stores
|
||||
$rpc_py get_bdevs
|
||||
$rpc_py get_vhost_controllers
|
||||
$rpc_py get_luns
|
||||
|
||||
notice "Shutting down SPDK vhost app..."
|
||||
spdk_vhost_kill
|
||||
|
Loading…
x
Reference in New Issue
Block a user