]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
target: Fix WRITE_SAME/DISCARD conversion to linux 512b sectors
authorMike Christie <mchristi@redhat.com>
Mon, 18 Jan 2016 20:09:27 +0000 (14:09 -0600)
committerTim Gardner <tim.gardner@canonical.com>
Wed, 6 Apr 2016 09:26:28 +0000 (10:26 +0100)
commit4952b2e9eb499f8cf43ad4c0280d7de5d3ac7172
tree60b14d76ca8965955b65dfb1f593568eb7aba6b9
parent6c889c25e1795fca75a50ac40d412a4e999e1635
target: Fix WRITE_SAME/DISCARD conversion to linux 512b sectors

BugLink: http://bugs.launchpad.net/bugs/1555640
commit 8a9ebe717a133ba7bc90b06047f43cc6b8bcb8b3 upstream.

In a couple places we are not converting to/from the Linux
block layer 512 bytes sectors.

1.

The request queue values and what we do are a mismatch of
things:

max_discard_sectors - This is in linux block layer 512 byte
sectors. We are just copying this to max_unmap_lba_count.

discard_granularity - This is in bytes. We are converting it
to Linux block layer 512 byte sectors.

discard_alignment - This is in bytes. We are just copying
this over.

The problem is that the core LIO code exports these values in
spc_emulate_evpd_b0 and we use them to test request arguments
in sbc_execute_unmap, but we never convert to the block size
we export to the initiator. If we are not using 512 byte sectors
then we are exporting the wrong values or are checks are off.
And, for the discard_alignment/bytes case we are just plain messed
up.

2.

blkdev_issue_discard's start and number of sector arguments
are supposed to be in linux block layer 512 byte sectors. We are
currently passing in the values we get from the initiator which
might be based on some other sector size.

There is a similar problem in iblock_execute_write_same where
the bio functions want values in 512 byte sectors but we are
passing in what we got from the initiator.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
[ kamal: backport to 4.4-stable: no unmap_zeroes_data ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/target/target_core_device.c
drivers/target/target_core_file.c
drivers/target/target_core_iblock.c
include/target/target_core_backend.h