scst_local: Require that data buffers are page aligned

When using SG_IO it is easy to submit data buffers that do not match the
alignment requirements of vdisk_blockio. Make the submitter copy buffers
that are not aligned. See also the blk_rq_map_user() call in the Linux
kernel source file drivers/scsi/sg.c.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8953 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2020-05-23 17:01:40 +00:00
parent 2239719d8e
commit fa22b6d134

View File

@@ -1175,15 +1175,24 @@ static int scst_local_change_queue_depth(struct scsi_device *sdev, int qdepth)
static int scst_local_slave_alloc(struct scsi_device *sdev)
{
struct request_queue *q = sdev->request_queue;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) && \
!defined(CONFIG_SUSE_KERNEL)
#if !defined(RHEL_MAJOR) || RHEL_MAJOR -0 >= 6
queue_flag_set_unlocked(QUEUE_FLAG_BIDI, sdev->request_queue);
queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q);
#endif
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
blk_queue_flag_set(QUEUE_FLAG_BIDI, sdev->request_queue);
blk_queue_flag_set(QUEUE_FLAG_BIDI, q);
#endif
/*
* vdisk_blockio requires that data buffers have block_size alignment
* and supports block sizes from 512 up to 4096. See also
* https://github.com/sahlberg/libiscsi/issues/302.
*/
blk_queue_dma_alignment(q, 4095);
return 0;
}