From: <vl...@us...> - 2008-05-26 11:00:24
|
Revision: 396 http://scst.svn.sourceforge.net/scst/?rev=396&view=rev Author: vlnb Date: 2008-05-26 04:00:19 -0700 (Mon, 26 May 2008) Log Message: ----------- - Fixed one more 32/64 bits user/kernel incompatibility - Minor fixes Modified Paths: -------------- trunk/iscsi-scst/include/iscsi_scst.h trunk/iscsi-scst/kernel/config.c trunk/iscsi-scst/usr/ctldev.c trunk/iscsi-scst/usr/iscsi_scstd.c trunk/iscsi-scst/usr/iscsid.h Modified: trunk/iscsi-scst/include/iscsi_scst.h =================================================================== --- trunk/iscsi-scst/include/iscsi_scst.h 2008-05-24 13:48:20 UTC (rev 395) +++ trunk/iscsi-scst/include/iscsi_scst.h 2008-05-26 11:00:19 UTC (rev 396) @@ -121,7 +121,6 @@ struct iscsi_register_info { aligned_u64 version; - u32 max_data_seg_len; }; #define DEFAULT_NR_QUEUED_CMNDS 32 @@ -130,7 +129,9 @@ #define NETLINK_ISCSI_SCST 25 +/* On success returns MAX_DATA_SEG_LEN */ #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) Modified: trunk/iscsi-scst/kernel/config.c =================================================================== --- trunk/iscsi-scst/kernel/config.c 2008-05-24 13:48:20 UTC (rev 395) +++ trunk/iscsi-scst/kernel/config.c 2008-05-26 11:00:19 UTC (rev 396) @@ -373,7 +373,7 @@ { struct iscsi_register_info reg; char ver[sizeof(ISCSI_SCST_INTERFACE_VERSION)+1]; - int res, max_data_seg_len; + int res; res = copy_from_user(®, (void *)arg, sizeof(reg)); if (res < 0) { @@ -396,13 +396,7 @@ 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; - } + res = ISCSI_CONN_IOV_MAX << PAGE_SHIFT; out: return res; Modified: trunk/iscsi-scst/usr/ctldev.c =================================================================== --- trunk/iscsi-scst/usr/ctldev.c 2008-05-24 13:48:20 UTC (rev 395) +++ trunk/iscsi-scst/usr/ctldev.c 2008-05-26 11:00:19 UTC (rev 396) @@ -34,7 +34,7 @@ int (*connection_op) (int fd, u32 tid, u64 sid, u32 cid, void *arg); }; -static int ctrdev_open(int max_data_seg_len) +static int ctrdev_open(int *max_data_seg_len) { FILE *f; char devname[256]; @@ -82,19 +82,24 @@ goto out; } - reg.version = ISCSI_SCST_INTERFACE_VERSION; - reg.max_data_seg_len = max_data_seg_len; + reg.version = (uintptr_t)ISCSI_SCST_INTERFACE_VERSION; err = ioctl(ctlfd, REGISTER_USERD, ®); if (err < 0) { log_error("Unable to register: %s. Incompatible version of the " "kernel module?\n", strerror(errno)); - close(ctlfd); - ctlfd = -1; - goto out; + goto out_close; + } else { + log_debug(0, "MAX_DATA_SEG_LEN %d", err); + *max_data_seg_len = err; } out: return ctlfd; + +out_close: + close(ctlfd); + ctlfd = -1; + goto out; } static int iscsi_target_create(u32 *tid, char *name) Modified: trunk/iscsi-scst/usr/iscsi_scstd.c =================================================================== --- trunk/iscsi-scst/usr/iscsi_scstd.c 2008-05-24 13:48:20 UTC (rev 395) +++ trunk/iscsi-scst/usr/iscsi_scstd.c 2008-05-26 11:00:19 UTC (rev 396) @@ -518,11 +518,8 @@ } } -int init_max_data_seg_len(void) +void init_max_data_seg_len(int max_data_seg_len) { - int page_size = getpagesize(); - int max_data_seg_len = page_size / sizeof(struct iovec) * page_size; - if ((session_keys[3].local_def != -1) || (session_keys[3].max != -1) || (session_keys[4].local_def != -1) || @@ -551,7 +548,7 @@ session_keys[6].local_def = max_data_seg_len; session_keys[6].max = max_data_seg_len; - return max_data_seg_len; + return; } int main(int argc, char **argv) @@ -562,7 +559,7 @@ gid_t gid = 0; char *isns = NULL; int isns_ac = 0; - int max_data_seg_len; + int max_data_seg_len = -1; if (pipe(init_report_pipe) == -1) { perror("pipe"); @@ -578,7 +575,7 @@ log_daemon = 0; break; case 'd': - log_level = atoi(optarg); + log_level = strtol(optarg, NULL, 0); break; case 'u': uid = strtoul(optarg, NULL, 10); @@ -610,11 +607,11 @@ exit(-1); }; - max_data_seg_len = init_max_data_seg_len(); - - if ((ctrl_fd = ki->ctldev_open(max_data_seg_len)) < 0) + if ((ctrl_fd = ki->ctldev_open(&max_data_seg_len)) < 0) exit(-1); + init_max_data_seg_len(max_data_seg_len); + if ((ipc_fd = iscsi_adm_request_listen()) < 0) { perror("ipc fd\n"); exit(-1); Modified: trunk/iscsi-scst/usr/iscsid.h =================================================================== --- trunk/iscsi-scst/usr/iscsid.h 2008-05-24 13:48:20 UTC (rev 395) +++ trunk/iscsi-scst/usr/iscsid.h 2008-05-26 11:00:19 UTC (rev 396) @@ -210,7 +210,7 @@ /* ctldev.c */ struct iscsi_kernel_interface { - int (*ctldev_open) (int); + 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 *); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |