diff --git a/.gitignore b/.gitignore index fc39ba618..b2b65ad73 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ .depend_f .directory .tmp_versions +built-in.a debian/*.debhelper.log debian/*.substvars debian/.debhelper/ diff --git a/qla2x00t-32gbit/include/trace/events/qla.h b/qla2x00t-32gbit/include/trace/events/qla.h index 737a667ab..e3b470023 100644 --- a/qla2x00t-32gbit/include/trace/events/qla.h +++ b/qla2x00t-32gbit/include/trace/events/qla.h @@ -9,8 +9,10 @@ #define QLA_MSG_MAX 256 +#if __GNUC__ * 256 + __GNUC_MINOR__ >= 4 * 256 + 6 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-attribute=format" +#endif DECLARE_EVENT_CLASS(qla_log_event, TP_PROTO(const char *buf, @@ -35,7 +37,9 @@ DEFINE_EVENT(qla_log_event, ql_dbg_log, TP_ARGS(buf, vaf) ); +#if __GNUC__ * 256 + __GNUC_MINOR__ >= 4 * 256 + 6 #pragma GCC diagnostic pop +#endif #endif /* _TRACE_QLA_H */ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 7c4e858bd..b24d3e69d 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -3294,6 +3294,18 @@ next: return; } +/** + * __scst_adjust_sg - reduce the length of a scatterlist + * @cmd: [in] SCST command that owns the scatterlist. + * @sg: [in/out] Scatterlist of which to reduce the length. + * @sg_cnt: [in/out] Number of elements of the scatterlist. + * @adjust_len: [in] New length of the scatterlist in bytes. + * @orig_sg: [out] Information needed to restore the original scatterlist. + * + * Return: + * True if @adjust_len was less than or equal to the length of @sg; false + * otherwise. + */ static bool __scst_adjust_sg(struct scst_cmd *cmd, struct scatterlist *sg, int *sg_cnt, int adjust_len, struct scst_orig_sg_data *orig_sg) { @@ -3305,13 +3317,8 @@ static bool __scst_adjust_sg(struct scst_cmd *cmd, struct scatterlist *sg, l = 0; for_each_sg(sg, sgi, *sg_cnt, i) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) - TRACE_DBG("i %d, sg_cnt %d, sg %p, page_link %lx, len %d", i, - *sg_cnt, sg, sgi->page_link, sgi->length); -#else - TRACE_DBG("i %d, sg_cnt %d, sg %p, page_link %lx", i, - *sg_cnt, sg, 0UL); -#endif + TRACE_DBG("sg[%d/%d]: addr %p, offset %d, len %d", i, *sg_cnt, + sgi, sgi->offset, sgi->length); l += sgi->length; if (l >= adjust_len) { int left = adjust_len - (l - sgi->length); @@ -3339,9 +3346,11 @@ static bool __scst_adjust_sg(struct scst_cmd *cmd, struct scatterlist *sg, return res; } -/* - * Makes cmd's SG shorter on adjust_len bytes. Reg_sg is true for cmd->sg - * and false for cmd->write_sg. +/** + * scst_adjust_sg - reduce the length of the scatterlist of a command + * @cmd: [in/out] SCST command that owns the scatterlist. + * @reg_sg: [in] True selects cmd->sg; false selects cmd->write_sg. + * @adjust_len: [in] New length of the scatterlist in bytes. */ static void scst_adjust_sg(struct scst_cmd *cmd, bool reg_sg, int adjust_len) @@ -3385,58 +3394,65 @@ static void scst_adjust_sg(struct scst_cmd *cmd, bool reg_sg, return; } +/** + * __scst_adjust_sg_get_tail - reduce a scatterlist to its tail + * @cmd: [in] SCST command that owns the scatterlist. + * @sg: [in/out] Scatterlist of which to reduce the length. + * @sg_cnt: [in/out] Number of elements of the scatterlist. + * @res_sg: [out] Pointer to first scatterlist element of the tail. + * @res_sg_cnt: [out] Number of scatterlist elements in the tail. + * @adjust_len: [in] New length of the scatterlist in bytes. + * @orig_sg: [out] Information needed to restore the original scatterlist. + * @must_left: [in] How many bytes must remain in @res_sg to consider the + * operation successful. + * + * Return: + * 0 upon sucess; a negative value upon error. + */ static int __scst_adjust_sg_get_tail(struct scst_cmd *cmd, struct scatterlist *sg, int *sg_cnt, struct scatterlist **res_sg, int *res_sg_cnt, int adjust_len, struct scst_orig_sg_data *orig_sg, int must_left) { - int res = -ENOENT, i, j, l; + struct scatterlist *sgi; + int res = -ENOENT, i, l; TRACE_ENTRY(); TRACE_DBG("cmd %p, sg_cnt %d, sg %p", cmd, *sg_cnt, sg); l = 0; - for (i = 0, j = 0; i < *sg_cnt; i++, j++) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) - TRACE_DBG("i %d, j %d, sg %p, page_link %lx, len %d", i, j, - sg, sg[j].page_link, sg->length); -#else - TRACE_DBG("i %d, j %d, sg %p", i, j, sg); -#endif - if (unlikely(sg_is_chain(&sg[j]))) { - sg = sg_chain_ptr(&sg[j]); - j = 0; - } - l += sg[j].length; + for_each_sg(sg, sgi, *sg_cnt, i) { + TRACE_DBG("i %d, sg %p, len %d", i, sgi, sgi->length); + l += sgi->length; if (l >= adjust_len) { - int offs = adjust_len - (l - sg[j].length); + int offs = adjust_len - (l - sgi->length); TRACE_DBG_FLAG(TRACE_SG_OP|TRACE_MEMORY|TRACE_DEBUG, - "cmd %p (tag %llu), sg %p, adjust_len %d, i %d, " - "j %d, sg[j].length %d, offs %d", + "cmd %p (tag %llu), sg %p, adjust_len %d, i %d, sg->length %d, offs %d", cmd, (unsigned long long)cmd->tag, - sg, adjust_len, i, j, sg[j].length, offs); + sg, adjust_len, i, sgi->length, offs); - if (offs == sg[j].length) { - j++; + if (offs == sgi->length) { + sgi = sg_next(sgi); + i++; offs = 0; } orig_sg->p_orig_sg_cnt = sg_cnt; orig_sg->orig_sg_cnt = *sg_cnt; - orig_sg->orig_sg_entry = &sg[j]; - orig_sg->orig_entry_offs = sg[j].offset; - orig_sg->orig_entry_len = sg[j].length; + orig_sg->orig_sg_entry = sgi; + orig_sg->orig_entry_offs = sgi->offset; + orig_sg->orig_entry_len = sgi->length; - sg[j].offset += offs; - sg[j].length -= offs; - *res_sg = &sg[j]; - *res_sg_cnt = *sg_cnt - j; + sgi->offset += offs; + sgi->length -= offs; + *res_sg = sgi; + *res_sg_cnt = *sg_cnt - i; - TRACE_DBG("j %d, sg %p, off %d, len %d, cnt %d " - "(offs %d)", j, &sg[j], sg[j].offset, - sg[j].length, *res_sg_cnt, offs); + TRACE_DBG("i %d, sg %p, off %d, len %d, cnt %d (offs %d)", + i, sgi, sgi->offset, sgi->length, *res_sg_cnt, + offs); res = 0; break; @@ -3448,15 +3464,17 @@ static int __scst_adjust_sg_get_tail(struct scst_cmd *cmd, #ifdef CONFIG_SCST_EXTRACHECKS l = 0; - sg = *res_sg; - for (i = 0; i < *res_sg_cnt; i++) - l += sg[i].length; + for_each_sg(*res_sg, sgi, *res_sg_cnt, i) + l += sgi->length; if (l != must_left) { PRINT_ERROR("Incorrect length %d of adjusted sg (cmd %p, " "expected %d)", l, cmd, must_left); res = -EINVAL; - scst_check_restore_sg_buff(cmd); + (*res_sg)->offset = orig_sg->orig_entry_offs; + (*res_sg)->length = orig_sg->orig_entry_len; + *res_sg = NULL; + *res_sg_cnt = 0; goto out; } #endif @@ -3466,18 +3484,24 @@ out: return res; } -/* - * Returns in res_sg the tail of cmd's adjusted on adjust_len, i.e. tail - * of it. In res_sg_cnt sg_cnt of res_sg returned. Cmd only used to store - * cmd->sg restore information. +/** + * scst_adjust_sg_get_tail - reduce a scatterlist of a command to its tail + * @cmd: [in] SCST command that owns the scatterlist. Information + * about how to restore the scatterlist will be stored + * in @cmd. + * @res_sg: [out] Pointer to first scatterlist element of the tail. + * @res_sg_cnt: [out] Number of scatterlist elements in the tail. + * @res_dif_sg: [out] Pointer to first scatterlist element of the DIF tail. + * @res_dif_sg_cnt: [out] Number of scatterlist elements in the DIF tail. + * @adjust_len: [in] New length of the scatterlist in bytes. + * @must_left: [in] How many bytes must remain in @res_sg to consider the + * operation successful. * - * Parameter must_left defines how many bytes must left in res_sg to consider - * operation successful. + * Return: + * 0 upon success; a negative value upon error. * - * Returns 0 on success or error code otherwise. - * - * NOTE! Before scst_restore_sg_buff() called cmd->sg is corrupted and - * can NOT be used! + * NOTE! Until scst_restore_sg_buff() is called, @cmd->sg is corrupted and + * must NOT be used! */ static int scst_adjust_sg_get_tail(struct scst_cmd *cmd, struct scatterlist **res_sg, int *res_sg_cnt, @@ -5742,7 +5766,18 @@ out: return acn; } - +/** + * __scst_create_prepare_internal_cmd() - Create an internal SCSI command + * @cdb: SCSI CDB. + * @cdb_len: Length in bytes of @cdb. + * @queue_type: One of the SCST_CMD_QUEUE_* constants. + * @tgt_dev: LUN to submit the command to. + * @gfp_mask: GFP mask to use during execution of this command. + * @fantom: If false, add the command to tgt_dev->sess->sess_cmd_list. + * If true, do not add the command to that command list. + * + * Return: pointer to the newly allocated command or NULL. + */ struct scst_cmd *__scst_create_prepare_internal_cmd(const uint8_t *cdb, unsigned int cdb_len, enum scst_cmd_queue_type queue_type, struct scst_tgt_dev *tgt_dev, gfp_t gfp_mask, bool fantom) diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm index 453a82e69..ca5c6537c 100644 --- a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm @@ -539,7 +539,7 @@ sub setScstAttribute { return TRUE if (!defined($attribute) || !defined($value)); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $path = make_path(SCST_ROOT_DIR(), $attribute); my $io = new IO::File $path, O_WRONLY; if ($io) { @@ -1053,7 +1053,7 @@ sub addDriverDynamicAttribute { } $cmd .= "add_attribute $attribute $value"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1096,7 +1096,7 @@ sub removeDriverDynamicAttribute { } $cmd .= "del_attribute $attribute $value"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1203,7 +1203,7 @@ sub addVirtualTarget { } $cmd .= "add_target $target $o_string"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1338,7 +1338,7 @@ sub addTargetDynamicAttribute { } $cmd .= "add_target_attribute $target $attribute $value"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1387,7 +1387,7 @@ sub removeTargetDynamicAttribute { } $cmd .= "del_target_attribute $target $attribute $value"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1464,7 +1464,7 @@ sub removeVirtualTarget { } $cmd .= "del_target $target"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1597,7 +1597,7 @@ sub addGroup { } $cmd .= "create $group"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1644,7 +1644,7 @@ sub removeGroup { } $cmd .= "del $group"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1686,7 +1686,7 @@ sub addDeviceGroup { } $cmd .= "create $group"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1718,7 +1718,7 @@ sub removeDeviceGroup { } $cmd .= "del $group"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1756,7 +1756,7 @@ sub addDeviceGroupDevice { } $cmd .= "add $device"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1812,7 +1812,7 @@ sub addTargetGroup { } $cmd .= "add $tgroup"; - my $bytes = -ENONENT; + my $bytes = - ENONENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1854,7 +1854,7 @@ sub addTargetGroupTarget { } $cmd .= "add $tgt"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1895,7 +1895,7 @@ sub removeDeviceGroupDevice { } $cmd .= "del $device"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1939,7 +1939,7 @@ sub removeTargetGroup { } $cmd .= "del $tgroup"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -1981,7 +1981,7 @@ sub removeTargetGroupTarget { } $cmd .= "del $tgt"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2032,7 +2032,7 @@ sub addInitiator { } $cmd .= "add $initiator"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2089,7 +2089,7 @@ sub removeInitiator { } $cmd .= "del $initiator"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2141,7 +2141,7 @@ sub moveInitiator { } $cmd .= "move $initiator $to"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2199,7 +2199,7 @@ sub clearInitiators { } $cmd .= "clear"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2274,7 +2274,7 @@ sub addLun { $cmd .= "add $device $lun $o_string"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2352,7 +2352,7 @@ sub removeLun { } $cmd .= "del $lun"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2464,7 +2464,7 @@ sub replaceLun { } $cmd .= "replace $device $lun $o_string"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2513,7 +2513,7 @@ sub clearLuns { } $cmd .= "clear"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2847,7 +2847,7 @@ sub setDriverAttribute { my $path = make_path(SCST_TARGETS_DIR(), $driver, $attribute); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -2995,7 +2995,7 @@ sub setTargetAttribute { $cmd = $value; } - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -3129,7 +3129,7 @@ sub setGroupAttribute { } $cmd .= $value; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -3289,7 +3289,7 @@ sub setLunAttribute { SCST_LUNS, $lun, $attribute); } - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -3432,7 +3432,7 @@ sub setInitiatorAttribute { my $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS, $group, SCST_LUNS, $initiator, $attribute); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -3719,7 +3719,7 @@ sub setAluaAttribute { return TRUE if (!defined($attribute) || !defined($value)); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $path = make_path(SCST_DEV_GROUP_DIR(), $attribute); my $io = new IO::File $path, O_WRONLY; if ($io) { @@ -3744,7 +3744,7 @@ sub setDeviceGroupAttribute { return TRUE if (!defined($attribute) || !defined($value)); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $path = make_path(SCST_DEV_GROUP_DIR(), $group, $attribute); my $io = new IO::File $path, O_WRONLY; if ($io) { @@ -3775,7 +3775,7 @@ sub setTargetGroupAttribute { return TRUE if (!defined($group) || !defined($tgroup) || !defined($attribute) || !defined($value)); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, $tgroup, $attribute); my $io = new IO::File $path, O_WRONLY; if ($io) { @@ -3812,7 +3812,7 @@ sub setTargetGroupTargetAttribute { !defined($tgt) || !defined($attribute) || !defined($value)); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, $tgroup, $tgt, $attribute); my $io = new IO::File $path, O_WRONLY; @@ -3892,7 +3892,7 @@ sub setHandlerAttribute { return TRUE if (!defined($attribute) || !defined($value)); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $path = make_path(SCST_HANDLERS_DIR(), $handler, $attribute); my $io = new IO::File $path, O_WRONLY; if ($io) { @@ -4192,7 +4192,7 @@ sub openDevice { } $cmd .= "add_device $device $o_string"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -4240,7 +4240,7 @@ sub closeDevice { } $cmd .= "del_device $device"; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -4283,7 +4283,7 @@ sub setDeviceAttribute { } $cmd .= $value; - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { if ($self->{'debug'}) { @@ -4809,7 +4809,7 @@ sub closeSession { my $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_SESSIONS, $session, 'force_close'); - my $bytes = -ENOENT; + my $bytes = - ENOENT; my $io = new IO::File $path, O_WRONLY; if ($io) { my $cmd = "1"; @@ -4922,12 +4922,12 @@ sub _syswrite { my $bytes = syswrite($io, $cmd, $length); $bytes = -$! if (!defined($bytes)); - if (defined($res_file) && $bytes == -EAGAIN) { + if (defined($res_file) && $bytes == - EAGAIN) { my $res_io = new IO::File $res_file, O_RDONLY; if (!$res_io) { cluck("FATAL: Failed opening $res_file: $!"); - return -ENOENT; + return - ENOENT; } my $res_val; diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 989ed72f4..165c1a432 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3007,6 +3007,11 @@ static int srpt_rdma_cm_req_recv(struct rdma_cm_id *cm_id, struct srpt_device *sdev; struct srp_login_req req; const struct srp_login_req_rdma *req_rdma; + /* + * See also commit c2f8fc4ec440 ("IB/SA: Rename ib_sa_path_rec to + * sa_path_rec") # v4.12. + */ + typeof(cm_id->route.path_rec) path_rec = cm_id->route.path_rec; char src_addr[40]; sdev = ib_get_client_data(cm_id->device, &srpt_client); @@ -3031,7 +3036,7 @@ static int srpt_rdma_cm_req_recv(struct rdma_cm_id *cm_id, inet_ntop(&cm_id->route.addr.src_addr, src_addr, sizeof(src_addr)); return srpt_cm_req_recv(sdev, NULL, cm_id, cm_id->port_num, - cm_id->route.path_rec->pkey, &req, src_addr); + path_rec ? path_rec->pkey : 0, &req, src_addr); } static void srpt_cm_rej_recv(struct srpt_rdma_ch *ch,