From: Greg Kroah-Hartman Date: Tue, 1 Nov 2022 19:35:22 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.9.332~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ae657c1690ab23445922624ec8d2cd88f710d40;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: scsi-sd-revert-scsi-sd-remove-a-local-variable.patch --- diff --git a/queue-4.14/scsi-sd-revert-scsi-sd-remove-a-local-variable.patch b/queue-4.14/scsi-sd-revert-scsi-sd-remove-a-local-variable.patch new file mode 100644 index 00000000000..0199e13e7da --- /dev/null +++ b/queue-4.14/scsi-sd-revert-scsi-sd-remove-a-local-variable.patch @@ -0,0 +1,66 @@ +From yukuai1@huaweicloud.com Tue Nov 1 20:34:27 2022 +From: Yu Kuai +Date: Tue, 1 Nov 2022 09:31:24 +0800 +Subject: scsi: sd: Revert "scsi: sd: Remove a local variable" +To: gregkh@linuxfoundation.org, stable@vger.kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com, hare@suse.com, bvanassche@acm.org +Cc: linux-scsi@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com +Message-ID: <20221101013124.2615274-1-yukuai1@huaweicloud.com> + +From: Yu Kuai + +This reverts commit 84f7a9de0602704bbec774a6c7f7c8c4994bee9c. + +Because it introduces a problem that rq->__data_len is set to the wrong +value. + +before the patch: +1) nr_bytes = rq->__data_len +2) rq->__data_len = sdp->sector_size +3) scsi_init_io() +4) rq->__data_len = nr_bytes + +after the patch: +1) rq->__data_len = sdp->sector_size +2) scsi_init_io() +3) rq->__data_len = rq->__data_len -> __data_len is wrong + +It will cause that io can only complete one segment each time, and the io +will requeue in scsi_io_completion_action(), which will cause severe +performance degradation. + +Scsi write same is removed in commit e383e16e84e9 ("scsi: sd: Remove +WRITE_SAME support") from mainline, hence this patch is only needed for +stable kernels. + +Fixes: 84f7a9de0602 ("scsi: sd: Remove a local variable") +Signed-off-by: Yu Kuai +Reviewed-by: Bart Van Assche +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/sd.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c +index de6640ad1943..1e887c11e83d 100644 +--- a/drivers/scsi/sd.c ++++ b/drivers/scsi/sd.c +@@ -1072,6 +1072,7 @@ static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) + struct bio *bio = rq->bio; + u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq)); + u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq)); ++ unsigned int nr_bytes = blk_rq_bytes(rq); + blk_status_t ret; + + if (sdkp->device->no_write_same) +@@ -1108,7 +1109,7 @@ static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) + */ + rq->__data_len = sdp->sector_size; + ret = scsi_alloc_sgtables(cmd); +- rq->__data_len = blk_rq_bytes(rq); ++ rq->__data_len = nr_bytes; + + return ret; + } +-- +2.31.1 + diff --git a/queue-4.14/series b/queue-4.14/series index 5b347c09528..e47f8379c8b 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -57,3 +57,4 @@ alsa-aoa-i2sbus-fix-possible-memory-leak-in-i2sbus_a.patch alsa-aoa-fix-i2s-device-accounting.patch openvswitch-switch-from-warn-to-pr_warn.patch net-ehea-fix-possible-memory-leak-in-ehea_register_p.patch +scsi-sd-revert-scsi-sd-remove-a-local-variable.patch