Skip to content

Commit

Permalink
block: Quiesce zeroout wrapper
Browse files Browse the repository at this point in the history
blkdev_issue_zeroout() printed a warning if a device failed a discard or
write same request despite advertising support for these. That's fine
for SCSI since we'll disable these commands if we get an error back from
the disk saying that they are not supported. And consequently the
warning only gets printed once.

There are other types of block devices that support discard, however,
and these may return -EOPNOTSUPP for each command but leave discard
enabled in the queue limits. This will cause a warning message for every
blkdev_issue_zeroout() invocation.

Remove the offending warning messages.

Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
martinkpetersen authored and axboe committed Feb 5, 2015
1 parent 9124d3f commit 9f9ee1f
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions block/blk-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
* @discard: whether to discard the block range
*
* Description:
* Zero-fill a block range. If the discard flag is set and the block
* device guarantees that subsequent READ operations to the block range
* in question will return zeroes, the blocks will be discarded. Should
Expand All @@ -303,26 +302,15 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
sector_t nr_sects, gfp_t gfp_mask, bool discard)
{
struct request_queue *q = bdev_get_queue(bdev);
unsigned char bdn[BDEVNAME_SIZE];

if (discard && blk_queue_discard(q) && q->limits.discard_zeroes_data) {

if (!blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, 0))
return 0;

bdevname(bdev, bdn);
pr_warn("%s: DISCARD failed. Manually zeroing.\n", bdn);
}
if (discard && blk_queue_discard(q) && q->limits.discard_zeroes_data &&
blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, 0) == 0)
return 0;

if (bdev_write_same(bdev)) {

if (!blkdev_issue_write_same(bdev, sector, nr_sects, gfp_mask,
ZERO_PAGE(0)))
return 0;

bdevname(bdev, bdn);
pr_warn("%s: WRITE SAME failed. Manually zeroing.\n", bdn);
}
if (bdev_write_same(bdev) &&
blkdev_issue_write_same(bdev, sector, nr_sects, gfp_mask,
ZERO_PAGE(0)) == 0)
return 0;

return __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask);
}
Expand Down

0 comments on commit 9f9ee1f

Please sign in to comment.