block: fix detection of unsupported WRITE SAME in blkdev_issue_write_zeroes
Subsystems (2)
PATCH 1/1 block: fix detection of unsupported WRITE SAME in blkdev_issue_write_zeroes
From: Darrick J. Wong <[email protected]>
On error, blkdev_issue_write_zeroes used to recheck the block device's WRITE SAME queue limits after submitting WRITE SAME bios. As stated in the comment, the purpose of this was to collapse all IO errors to EOPNOTSUPP if the effect of issuing bios was that WRITE SAME got turned off in the queue limits. Therefore, it does not make sense to reuse the zeroes limit that was read earlier in the function because we only care about the queue limit *now*, not what it was at the start of the function.
Found by running generic/351 from fstests.
--- block/blk-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-lib.c +1 -1
@@ -174,7 +174,7 @@ static int blkdev_issue_write_zeroes(struct block_device *bdev, sector_t sector,* on an I/O error, in which case we'll turn any error into * "not supported" here. */ -if (ret && !limit) +if (ret && !bdev_write_zeroes_sectors (bdev))return -EOPNOTSUPP ;return ret; }
Quoted 10 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
On error,
blkdev_issue_write_zeroesused to recheck the block device's WRITE SAME queue limits after submitting WRITE SAME bios. As stated in the comment, the purpose of this was to collapse all IO errors to EOPNOTSUPP if the effect of issuing bios was that WRITE SAME got turned off in the queue limits. Therefore, it does not make sense to reuse the zeroes limit that was read earlier in the function because we only care about the queue limit *now*, not what it was at the start of the function.
Yes, that was a bit overeager..
Looks good:
Quoted 11 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
On error,
blkdev_issue_write_zeroesused to recheck the block device's WRITE SAME queue limits after submitting WRITE SAME bios. As stated in the comment, the purpose of this was to collapse all IO errors to EOPNOTSUPP if the effect of issuing bios was that WRITE SAME got turned off in the queue limits. Therefore, it does not make sense to reuse the zeroes limit that was read earlier in the function because we only care about the queue limit *now*, not what it was at the start of the function.
Quoted 1 line
Found by running generic/351 from fstests.
thanks for the fix
Quoted 12 lines
Fixes 64b582ca88ca1 ("block: Read max write zeroes once for __blkdev_issue_write_zeroes()")Signed-off-by Darrick J. Wong <[email protected]>--- block/blk-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/blk-lib.c +0
-0
block/blk-lib.c static int blkdev_issue_write_zeroes(struct block_device *bdev, sector_t sector, · line 177
Quoted 4 lines
block/blk-lib.c +0
-1@@ -174,7 +174,7 @@ static int blkdev_issue_write_zeroes(struct block_device *bdev, sector_t sector,* on an I/O error, in which case we'll turn any error into * "not supported" here. */ -if (ret && !limit)
I don't think that we still require local variable @limit. Actually we can probably clean this up later, and Nitesh's suggestion on the original patch could have been considered more
Quoted 5 lines
block/blk-lib.c +1
-0+if (ret && !bdev_write_zeroes_sectors (bdev))return -EOPNOTSUPP ;return ret; }
Quoted 10 lines · Darrick J. Wong
On error,
blkdev_issue_write_zeroesused to recheck the block device's WRITE SAME queue limits after submitting WRITE SAME bios. As stated in the comment, the purpose of this was to collapse all IO errors to EOPNOTSUPP if the effect of issuing bios was that WRITE SAME got turned off in the queue limits. Therefore, it does not make sense to reuse the zeroes limit that was read earlier in the function because we only care about the queue limit *now*, not what it was at the start of the function.[...]
Applied, thanks!
[1/1] block: fix detection of unsupported WRITE SAME in blkdev_issue_write_zeroes
(no commit info)
Best regards,
Signature · 1 line
Jens Axboe