>From 975c1f8be719bb297de4bbf704cc5a58edee62b6 Mon Sep 17 00:00:00 2001 From: Petr Vandrovec Date: Fri, 10 Oct 2014 23:10:25 -0700 Subject: [PATCH] Do not silently discard WRITE_SAME requests When device does not support WRITE_SAME, after first failure block layer starts throwing away WRITE_SAME requests without warning anybody, leading to the data corruption. Let's do something about it - do not use EOPNOTSUPP error, as that error code is special, reserved for DISCARD, and return EREMOTEIO, AKA target failure, like when request hits hardware.. It also reverts 4089b71cc820a426d601283c92fcd4ffeb5139c2, as there is nothing wrong with VMware's WRITE_SAME emulation. Only problem was that block layer did not issue WRITE_SAME request at all, but reported success, and it affected all disks that do not support WRITE_SAME. Signed-off-by: Petr Vandrovec Cc: Arvind Kumar Cc: Chris J Arges Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: stable@vger.kernel.org --- block/blk-core.c | 2 +- drivers/message/fusion/mptspi.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 9c888bd..b070782 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1822,7 +1822,7 @@ generic_make_request_checks(struct bio *bio) } if (bio->bi_rw & REQ_WRITE_SAME && !bdev_write_same(bio->bi_bdev)) { - err = -EOPNOTSUPP; + err = -EREMOTEIO; goto end_io; } diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 613231c..787933d 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -1419,11 +1419,6 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out_mptspi_probe; } - /* VMWare emulation doesn't properly implement WRITE_SAME - */ - if (pdev->subsystem_vendor == 0x15AD) - sh->no_write_same = 1; - spin_lock_irqsave(&ioc->FreeQlock, flags); /* Attach the SCSI Host to the IOC structure -- 2.1.1