file-posix: Use max transfer length/segment count only for SCSI passthrough
authorMaxim Levitsky <mlevitsk@redhat.com>
Thu, 4 Jul 2019 12:43:42 +0000 (15:43 +0300)
committerKevin Wolf <kwolf@redhat.com>
Fri, 12 Jul 2019 13:42:23 +0000 (15:42 +0200)
commit867eccfed84f96b54f4a432c510a02c2ce03b430
tree76a60f9909d15237449b8e7ef98e7e21d94f8c5d
parent20ff903d527b6de4220d5124f083a05e512c3581
file-posix: Use max transfer length/segment count only for SCSI passthrough

Regular kernel block devices (/dev/sda*, /dev/nvme*, etc) don't have
max segment size/max segment count hardware requirements exposed
to the userspace, but rather the kernel block layer
takes care to split the incoming requests that
violate these requirements.

Allowing the kernel to do the splitting allows qemu to avoid
various overheads that arise otherwise from this.

This is especially visible in nbd server,
exposing as a raw file, a mostly empty qcow2 image over the net.
In this case most of the reads by the remote user
won't even hit the underlying kernel block device,
and therefore most of the  overhead will be in the
nbd traffic which increases significantly with lower max transfer size.

In addition to that even for local block device
access the peformance improves a bit due to less
traffic between qemu and the kernel when large
transfer sizes are used (e.g for image conversion)

More info can be found at:
https://bugzilla.redhat.com/show_bug.cgi?id=1647104

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Pankaj Gupta <pagupta@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/file-posix.c