diff --git a/Makefile b/Makefile index b4e91ede9..db82951e5 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ install: uninstall: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi - @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi +# @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi @if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi @if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi @if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi @@ -107,7 +107,7 @@ clean: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_INI_DIR) ]; then cd $(QLA_INI_DIR) && $(MAKE) $@; fi @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi - @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi +# @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi @if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi @if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi @if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi @@ -116,7 +116,7 @@ extraclean: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_INI_DIR) ]; then cd $(QLA_INI_DIR) && $(MAKE) $@; fi @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi - @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi +# @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi @if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi @if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi @if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi diff --git a/iscsi-scst/include/iscsi_scst.h b/iscsi-scst/include/iscsi_scst.h index 242ad07b8..04d03ce1b 100644 --- a/iscsi-scst/include/iscsi_scst.h +++ b/iscsi-scst/include/iscsi_scst.h @@ -119,15 +119,18 @@ struct iscsi_event { u32 state; }; +struct iscsi_register_info { + aligned_u64 version; + u32 max_data_seg_len; +}; + #define DEFAULT_NR_QUEUED_CMNDS 32 #define MIN_NR_QUEUED_CMNDS 1 #define MAX_NR_QUEUED_CMNDS 256 -#define MAX_DATA_SEG_LEN (4096/sizeof(struct iovec)*4096) - #define NETLINK_ISCSI_SCST 25 -#define REGISTER_USERD _IOW('s', 0, const char*) +#define REGISTER_USERD _IOW('s', 0, struct iscsi_register_info) #define ADD_TARGET _IOW('s', 1, struct target_info) #define DEL_TARGET _IOW('s', 2, struct target_info) #define ADD_SESSION _IOW('s', 3, struct session_info) diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index 63a32adba..255c8d894 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -371,10 +371,18 @@ static int add_target(unsigned long ptr) static int iscsi_check_version(unsigned long arg) { + struct iscsi_register_info reg; char ver[sizeof(ISCSI_SCST_INTERFACE_VERSION)+1]; - int res; + int res, max_data_seg_len; - res = copy_from_user(ver, (void *)arg, sizeof(ver)); + res = copy_from_user(®, (void *)arg, sizeof(reg)); + if (res < 0) { + PRINT_ERROR("%s", "Unable to get register info"); + goto out; + } + + res = copy_from_user(ver, (void *)(unsigned long)reg.version, + sizeof(ver)); if (res < 0) { PRINT_ERROR("%s", "Unable to get version string"); goto out; @@ -382,12 +390,20 @@ static int iscsi_check_version(unsigned long arg) ver[sizeof(ver)-1] = '\0'; if (strcmp(ver, ISCSI_SCST_INTERFACE_VERSION) != 0) { - PRINT_ERROR("Incorrect version of user space %s (needed %s)", + PRINT_ERROR("Incorrect version of user space %s (expected %s)", ver, ISCSI_SCST_INTERFACE_VERSION); res = -EINVAL; goto out; } + max_data_seg_len = ISCSI_CONN_IOV_MAX << PAGE_SHIFT; + if (reg.max_data_seg_len != max_data_seg_len) { + PRINT_ERROR("Incorrect max_data_seg_len %d (expected %d)", + reg.max_data_seg_len, max_data_seg_len); + res = -EINVAL; + goto out; + } + out: return res; } diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 14c6fb600..f64a409f8 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -2907,8 +2907,6 @@ static int __init iscsi_init(void) "degraded mode. Refer README file for details"); #endif - BUILD_BUG_ON(MAX_DATA_SEG_LEN != (ISCSI_CONN_IOV_MAX<ctldev_open()) < 0) + max_data_seg_len = init_max_data_seg_len(); + + if ((ctrl_fd = ki->ctldev_open(max_data_seg_len)) < 0) exit(-1); if ((ipc_fd = iscsi_adm_request_listen()) < 0) { diff --git a/iscsi-scst/usr/iscsid.h b/iscsi-scst/usr/iscsid.h index 3774f0a25..aa6993b62 100644 --- a/iscsi-scst/usr/iscsid.h +++ b/iscsi-scst/usr/iscsid.h @@ -210,7 +210,7 @@ extern int iscsi_adm_request_handle(int accept_fd); /* ctldev.c */ struct iscsi_kernel_interface { - int (*ctldev_open) (void); + int (*ctldev_open) (int); int (*param_get) (u32, u64, int, struct iscsi_param *, int); int (*param_set) (u32, u64, int, u32, struct iscsi_param *, int); int (*target_create) (u32 *, char *); diff --git a/iscsi-scst/usr/param.c b/iscsi-scst/usr/param.c index 3fe20e5f0..c53ee6925 100644 --- a/iscsi-scst/usr/param.c +++ b/iscsi-scst/usr/param.c @@ -293,10 +293,10 @@ struct iscsi_key session_keys[] = { {"InitialR2T", 1, 0, 0, 1, &or_ops}, {"ImmediateData", 1, 1, 0, 1, &and_ops}, {"MaxConnections", 1, 1, 1, 1, &minimum_ops}, - {"MaxRecvDataSegmentLength", 8192, MAX_DATA_SEG_LEN, 512, MAX_DATA_SEG_LEN, &minimum_ops}, - {"MaxXmitDataSegmentLength", 8192, MAX_DATA_SEG_LEN, 512, MAX_DATA_SEG_LEN, &minimum_ops}, - {"MaxBurstLength", 262144, MAX_DATA_SEG_LEN, 512, MAX_DATA_SEG_LEN, &minimum_ops}, - {"FirstBurstLength", 65536, MAX_DATA_SEG_LEN, 512, MAX_DATA_SEG_LEN, &minimum_ops}, + {"MaxRecvDataSegmentLength", 8192, -1, 512, -1, &minimum_ops}, + {"MaxXmitDataSegmentLength", 8192, -1, 512, -1, &minimum_ops}, + {"MaxBurstLength", 262144, -1, 512, -1, &minimum_ops}, + {"FirstBurstLength", 65536, -1, 512, -1, &minimum_ops}, {"DefaultTime2Wait", 2, 2, 0, 3600, &maximum_ops}, {"DefaultTime2Retain", 20, 20, 0, 3600, &minimum_ops}, {"MaxOutstandingR2T", 1, 20, 1, 65535, &minimum_ops},