linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: align max append sectors to physical block size
@ 2020-07-16 10:09 Johannes Thumshirn
  2020-07-16 14:34 ` Christoph Hellwig
  0 siblings, 1 reply; 13+ messages in thread
From: Johannes Thumshirn @ 2020-07-16 10:09 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Johannes Thumshirn

Max append sectors needs to be aligned to physical block size, otherwise
we can end up in a situation where it's off by 1-3 sectors which would
cause short writes with asynchronous zone append submissions from an FS.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 block/blk-settings.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 9a2c23cd9700..d75c4cc34a7a 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -231,6 +231,7 @@ EXPORT_SYMBOL(blk_queue_max_write_zeroes_sectors);
 void blk_queue_max_zone_append_sectors(struct request_queue *q,
 		unsigned int max_zone_append_sectors)
 {
+	unsigned int phys = queue_physical_block_size(q);
 	unsigned int max_sectors;
 
 	if (WARN_ON(!blk_queue_is_zoned(q)))
@@ -246,6 +247,13 @@ void blk_queue_max_zone_append_sectors(struct request_queue *q,
 	 */
 	WARN_ON(!max_sectors);
 
+	/*
+	 * Max append sectors needs to be aligned to physical block size,
+	 * otherwise we can end up in a situation where it's off by 1-3 sectors
+	 * which would cause short writes with asynchronous zone append
+	 * submissions from an FS.
+	 */
+	max_sectors = ALIGN_DOWN(max_sectors << 9, phys) >> 9;
 	q->limits.max_zone_append_sectors = max_sectors;
 }
 EXPORT_SYMBOL_GPL(blk_queue_max_zone_append_sectors);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-07-20 12:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-16 10:09 [PATCH] block: align max append sectors to physical block size Johannes Thumshirn
2020-07-16 14:34 ` Christoph Hellwig
2020-07-17  2:45   ` Damien Le Moal
2020-07-17  7:50     ` Ming Lei
2020-07-17  8:22       ` Damien Le Moal
2020-07-17  9:11         ` Ming Lei
2020-07-17  9:19           ` Damien Le Moal
2020-07-17 10:02             ` Ming Lei
2020-07-17 10:55               ` Damien Le Moal
2020-07-20 11:08                 ` hch
2020-07-20 12:32                   ` Damien Le Moal
2020-07-20 12:34                     ` hch
2020-07-20 12:35                       ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).