]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - block/blk-lib.c
block: cope with WRITE ZEROES failing in blkdev_issue_zeroout()
authorIlya Dryomov <idryomov@gmail.com>
Tue, 21 Nov 2017 17:05:28 +0000 (17:05 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 14 Mar 2018 10:40:26 +0000 (11:40 +0100)
commitc37bc414e04e9e99d267bb774f4073ba304cf763
tree049a5b3a518c5b7daf00744c50bf028dacb1b430
parent9c99c9896aae4d9e97d3f2ea8bce60fb2e534341
block: cope with WRITE ZEROES failing in blkdev_issue_zeroout()

BugLink: https://bugs.launchpad.net/bugs/1726818
sd_config_write_same() ignores ->max_ws_blocks == 0 and resets it to
permit trying WRITE SAME on older SCSI devices, unless ->no_write_same
is set.  Because REQ_OP_WRITE_ZEROES is implemented in terms of WRITE
SAME, blkdev_issue_zeroout() may fail with -EREMOTEIO:

  $ fallocate -zn -l 1k /dev/sdg
  fallocate: fallocate failed: Remote I/O error
  $ fallocate -zn -l 1k /dev/sdg  # OK
  $ fallocate -zn -l 1k /dev/sdg  # OK

The following calls succeed because sd_done() sets ->no_write_same in
response to a sense that would become BLK_STS_TARGET/-EREMOTEIO, causing
__blkdev_issue_zeroout() to fall back to generating ZERO_PAGE bios.

This means blkdev_issue_zeroout() must cope with WRITE ZEROES failing
and fall back to manually zeroing, unless BLKDEV_ZERO_NOFALLBACK is
specified.  For BLKDEV_ZERO_NOFALLBACK case, return -EOPNOTSUPP if
sd_done() has just set ->no_write_same thus indicating lack of offload
support.

Fixes: c20cfc27a473 ("block: stop using blkdev_issue_write_same for zeroing")
Cc: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
block/blk-lib.c