diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index 00ddfd2fb..ec37c8578 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -221,6 +221,18 @@ extraclean: clean kernel/isert-scst/*.orig kernel/isert-scst/*.rej rm -rf conftest/*/*.rej conftest/*/*.orig +conftest/bad_wr_mod/result-$(KVER).txt: \ + conftest/bad_wr_mod/bad_wr_mod.c \ + conftest/bad_wr_mod/Makefile + echo "$(call run_conftest,bad_wr_mod, \ + -DBAD_WR_MODIFIER=const,-DBAD_WR_MODIFIER=)" >"$@" + +conftest/cm_event_mod/result-$(KVER).txt: \ + conftest/cm_event_mod/cm_event_mod.c \ + conftest/cm_event_mod/Makefile + echo "$(call run_conftest,cm_event_mod, \ + -DCM_HANDLER_EVENT_MODIFIER=const,-DCM_HANDLER_EVENT_MODIFIER=)" >"$@" + conftest/cm_listen/result-$(KVER).txt: \ conftest/cm_listen/cm_listen.c \ conftest/cm_listen/Makefile diff --git a/iscsi-scst/conftest/bad_wr_mod/Makefile b/iscsi-scst/conftest/bad_wr_mod/Makefile new file mode 100644 index 000000000..aaa933974 --- /dev/null +++ b/iscsi-scst/conftest/bad_wr_mod/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += bad_wr_mod.o diff --git a/iscsi-scst/conftest/bad_wr_mod/bad_wr_mod.c b/iscsi-scst/conftest/bad_wr_mod/bad_wr_mod.c new file mode 100644 index 000000000..cfd76d393 --- /dev/null +++ b/iscsi-scst/conftest/bad_wr_mod/bad_wr_mod.c @@ -0,0 +1,13 @@ +#include +#include + +static int modinit(void) +{ + struct ib_qp *qp = NULL; + const struct ib_recv_wr *recv_wr = NULL; + const struct ib_recv_wr **bad_recv_wr = NULL; + + return ib_post_recv(qp, recv_wr, bad_recv_wr); +} + +module_init(modinit); diff --git a/iscsi-scst/conftest/cm_event_mod/Makefile b/iscsi-scst/conftest/cm_event_mod/Makefile new file mode 100644 index 000000000..7df493105 --- /dev/null +++ b/iscsi-scst/conftest/cm_event_mod/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += cm_event_mod.o diff --git a/iscsi-scst/conftest/cm_event_mod/cm_event_mod.c b/iscsi-scst/conftest/cm_event_mod/cm_event_mod.c new file mode 100644 index 000000000..23ec6a4fb --- /dev/null +++ b/iscsi-scst/conftest/cm_event_mod/cm_event_mod.c @@ -0,0 +1,14 @@ +#include +#include + +static int h(struct ib_cm_id *cm_id, const struct ib_cm_event *event) +{ + return 0; +} + +static int modinit(void) +{ + return ib_create_cm_id(NULL, h, NULL) != NULL; +} + +module_init(modinit); diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index c97924d01..3fb80102f 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -55,7 +55,7 @@ static DEFINE_MUTEX(dev_list_mutex); static void isert_portal_free(struct isert_portal *portal); static int isert_num_recv_posted_on_err(struct ib_recv_wr *first_ib_wr, - struct ib_recv_wr *bad_wr) + BAD_WR_MODIFIER struct ib_recv_wr *bad_wr) { struct ib_recv_wr *wr; int num_posted = 0; @@ -71,7 +71,7 @@ int isert_post_recv(struct isert_connection *isert_conn, int num_wr) { struct ib_recv_wr *first_ib_wr = &first_wr->recv_wr; - struct ib_recv_wr *bad_wr; + BAD_WR_MODIFIER struct ib_recv_wr *bad_wr; int num_posted; int err; @@ -98,7 +98,7 @@ int isert_post_recv(struct isert_connection *isert_conn, } static int isert_num_send_posted_on_err(struct ib_send_wr *first_ib_wr, - struct ib_send_wr *bad_wr) + BAD_WR_MODIFIER struct ib_send_wr *bad_wr) { struct ib_send_wr *wr; int num_posted = 0; @@ -118,7 +118,7 @@ int isert_post_send(struct isert_connection *isert_conn, #else struct ib_send_wr *first_ib_wr = &first_wr->send_wr.wr; #endif - struct ib_send_wr *bad_wr; + BAD_WR_MODIFIER struct ib_send_wr *bad_wr; int num_posted; int err; @@ -146,7 +146,7 @@ int isert_post_send(struct isert_connection *isert_conn, static void isert_post_drain_sq(struct isert_connection *isert_conn) { - struct ib_send_wr *bad_wr; + BAD_WR_MODIFIER struct ib_send_wr *bad_wr; struct isert_wr *drain_wr_sq = &isert_conn->drain_wr_sq; int err; @@ -177,7 +177,7 @@ static void isert_post_drain_sq(struct isert_connection *isert_conn) static void isert_post_drain_rq(struct isert_connection *isert_conn) { - struct ib_recv_wr *bad_wr; + BAD_WR_MODIFIER struct ib_recv_wr *bad_wr; struct isert_wr *drain_wr_rq = &isert_conn->drain_wr_rq; int err; @@ -1292,7 +1292,11 @@ static struct isert_connection *isert_conn_create(struct rdma_cm_id *cm_id, * In mem-free devices, RC QPs can be created with a maximum of * (max_sge - 3) entries only. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) isert_conn->max_sge = isert_dev->device_attr.max_sge - 3; +#else + isert_conn->max_sge = isert_dev->device_attr.max_recv_sge - 3; +#endif WARN_ON(isert_conn->max_sge < 1); diff --git a/scst/include/scst.h b/scst/include/scst.h index 998a6de5b..b08cfbb03 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5724,10 +5724,38 @@ ssize_t scst_readv(struct file *file, const struct iovec *vec, ssize_t scst_writev(struct file *file, const struct iovec *vec, unsigned long vlen, loff_t *pos); void scst_write_same(struct scst_cmd *cmd, struct scst_data_descriptor *where); -int scst_scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, - int data_direction, void *buffer, unsigned int bufflen, - unsigned char *sense, int timeout, int retries, - u64 flags); +/** + * scsi_execute - insert a SCSI request and wait for the result + * @sdev: scsi device + * @cmd: scsi command + * @data_direction: data direction + * @buffer: data buffer + * @bufflen: length of buffer - DMA_TO_DEVICE, DMA_FROM_DEVICE or DMA_NONE + * @sense: optional sense buffer + * @timeout: request timeout in seconds + * @retries: number of times to retry request + * @flags: flags for ->cmd_flags, e.g. REQ_FAILFAST_DEV + * + * Returns the scsi_cmnd result field if a command was executed, or a negative + * Linux error code if we didn't get that far. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) \ + scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + NULL /* sshdr */, timeout, retries, flags, \ + 0 /* rq_flags */, NULL /* resid */) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) +#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) \ + scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags, NULL /* resid */) +#else +#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) \ + scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ + timeout, retries, flags) +#endif __be64 scst_pack_lun(const uint64_t lun, enum scst_lun_addr_method addr_method); uint64_t scst_unpack_lun(const uint8_t *lun, int len); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index a79d6c94f..16d93833c 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6965,40 +6965,6 @@ out: return res; } -/** - * scsi_execute - insert a SCSI request and wait for the result - * @sdev: scsi device - * @cmd: scsi command - * @data_direction: data direction - * @buffer: data buffer - * @bufflen: length of buffer - DMA_TO_DEVICE, DMA_FROM_DEVICE or DMA_NONE - * @sense: optional sense buffer - * @timeout: request timeout in seconds - * @retries: number of times to retry request - * @flags: flags for ->cmd_flags, e.g. REQ_FAILFAST_DEV - * - * Returns the scsi_cmnd result field if a command was executed, or a negative - * Linux error code if we didn't get that far. - */ -int scst_scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, - int data_direction, void *buffer, unsigned int bufflen, - unsigned char *sense, int timeout, int retries, u64 flags) -{ - return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) - NULL, /* sshdr */ -#endif - timeout, retries, flags -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) - , 0 /* rq_flags */ -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL /* resid */ -#endif - ); -} -EXPORT_SYMBOL(scst_scsi_execute); - static void scst_send_release(struct scst_device *dev) { struct scsi_device *scsi_dev; diff --git a/srpt/Makefile b/srpt/Makefile index 449189401..7ece698b7 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -160,6 +160,18 @@ clean: extraclean: clean rm -f *.orig *.rej +conftest/bad_wr_mod/result-$(KVER).txt: \ + conftest/bad_wr_mod/bad_wr_mod.c \ + conftest/bad_wr_mod/Makefile + echo "$(call run_conftest,bad_wr_mod, \ + -DBAD_WR_MODIFIER=const,-DBAD_WR_MODIFIER=)" >"$@" + +conftest/cm_event_mod/result-$(KVER).txt: \ + conftest/cm_event_mod/cm_event_mod.c \ + conftest/cm_event_mod/Makefile + echo "$(call run_conftest,cm_event_mod, \ + -DCM_HANDLER_EVENT_MODIFIER=const,-DCM_HANDLER_EVENT_MODIFIER=)" >"$@" + conftest/cm_listen/result-$(KVER).txt: \ conftest/cm_listen/cm_listen.c \ conftest/cm_listen/Makefile diff --git a/srpt/conftest/bad_wr_mod/Makefile b/srpt/conftest/bad_wr_mod/Makefile new file mode 100644 index 000000000..aaa933974 --- /dev/null +++ b/srpt/conftest/bad_wr_mod/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += bad_wr_mod.o diff --git a/srpt/conftest/bad_wr_mod/bad_wr_mod.c b/srpt/conftest/bad_wr_mod/bad_wr_mod.c new file mode 100644 index 000000000..cfd76d393 --- /dev/null +++ b/srpt/conftest/bad_wr_mod/bad_wr_mod.c @@ -0,0 +1,13 @@ +#include +#include + +static int modinit(void) +{ + struct ib_qp *qp = NULL; + const struct ib_recv_wr *recv_wr = NULL; + const struct ib_recv_wr **bad_recv_wr = NULL; + + return ib_post_recv(qp, recv_wr, bad_recv_wr); +} + +module_init(modinit); diff --git a/srpt/conftest/cm_event_mod/Makefile b/srpt/conftest/cm_event_mod/Makefile new file mode 100644 index 000000000..7df493105 --- /dev/null +++ b/srpt/conftest/cm_event_mod/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += cm_event_mod.o diff --git a/srpt/conftest/cm_event_mod/cm_event_mod.c b/srpt/conftest/cm_event_mod/cm_event_mod.c new file mode 100644 index 000000000..23ec6a4fb --- /dev/null +++ b/srpt/conftest/cm_event_mod/cm_event_mod.c @@ -0,0 +1,14 @@ +#include +#include + +static int h(struct ib_cm_id *cm_id, const struct ib_cm_event *event) +{ + return 0; +} + +static int modinit(void) +{ + return ib_create_cm_id(NULL, h, NULL) != NULL; +} + +module_init(modinit); diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 47529915b..a4b6585f5 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -945,7 +945,7 @@ static int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch, { struct ib_sge list; struct ib_recv_wr wr; - struct ib_recv_wr *bad_wr; + BAD_WR_MODIFIER struct ib_recv_wr *bad_wr; BUG_ON(!sdev); wr.wr_id = encode_wr_id(SRPT_RECV, ioctx->ioctx.index); @@ -979,7 +979,7 @@ static int srpt_post_send(struct srpt_rdma_ch *ch, { struct ib_sge list; struct ib_send_wr wr; - struct ib_send_wr *bad_wr; + BAD_WR_MODIFIER struct ib_send_wr *bad_wr; struct srpt_device *sdev = ch->sport->sdev; int ret; @@ -1023,7 +1023,7 @@ out: static int srpt_zerolength_write(struct srpt_rdma_ch *ch) { struct ib_send_wr wr; - struct ib_send_wr *bad_wr; + BAD_WR_MODIFIER struct ib_send_wr *bad_wr; memset(&wr, 0, sizeof(wr)); wr.opcode = IB_WR_RDMA_WRITE; @@ -2851,7 +2851,7 @@ out: } static int srpt_ib_cm_req_recv(struct ib_cm_id *cm_id, - struct ib_cm_req_event_param *param, + const struct ib_cm_req_event_param *param, void *private_data) { char sgid[40]; @@ -2882,7 +2882,7 @@ static const char *inet_ntop(const void *sa, char *dst, unsigned int size) } static int srpt_rdma_cm_req_recv(struct rdma_cm_id *cm_id, - struct rdma_cm_event *event) + const struct rdma_cm_event *event) { struct srpt_device *sdev; struct srp_login_req req; @@ -3006,7 +3006,8 @@ static void srpt_cm_rtu_recv(struct srpt_rdma_ch *ch) * a non-zero value in any other case will trigger a race with the * ib_destroy_cm_id() call in srpt_compl_thread(). */ -static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) +static int srpt_cm_handler(struct ib_cm_id *cm_id, + CM_HANDLER_EVENT_MODIFIER struct ib_cm_event *event) { struct srpt_rdma_ch *ch = cm_id->context; int ret; @@ -3340,7 +3341,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, #else struct ib_rdma_wr wr; #endif - struct ib_send_wr *bad_wr; + BAD_WR_MODIFIER struct ib_send_wr *bad_wr; struct rdma_iu *riu; int i; int ret = -ENOMEM;