All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Damien Le Moal <Damien.LeMoal@wdc.com>
Cc: "hch@infradead.org" <hch@infradead.org>,
	Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
	Jens Axboe <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH] block: align max append sectors to physical block size
Date: Fri, 17 Jul 2020 17:11:24 +0800	[thread overview]
Message-ID: <20200717091124.GC670561@T590> (raw)
In-Reply-To: <CY4PR04MB3751DAD907DFFB3A00B73039E77C0@CY4PR04MB3751.namprd04.prod.outlook.com>

On Fri, Jul 17, 2020 at 08:22:45AM +0000, Damien Le Moal wrote:
> On 2020/07/17 16:50, Ming Lei wrote:
> > On Fri, Jul 17, 2020 at 02:45:25AM +0000, Damien Le Moal wrote:
> >> On 2020/07/16 23:35, Christoph Hellwig wrote:
> >>> On Thu, Jul 16, 2020 at 07:09:33PM +0900, Johannes Thumshirn wrote:
> >>>> 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.
> >>>
> >>> Huh? The physical block size is purely a hint.
> >>
> >> For ZBC/ZAC SMR drives, all writes must be aligned to the physical sector size.
> > 
> > Then the physical block size should be same with logical block size.
> > The real workable limit for io request is aligned with logical block size.
> 
> Yes, I know. This T10/T13 design is not the brightest thing they did... on 512e
> SMR drives, addressing is LBA=512B unit, but all writes in sequential zones must
> be 4K aligned (8 LBAs).

Then the issue isn't related with zone append command only. Just wondering how this
special write block size alignment is enhanced in sequential zones. So far, write
from FS or raw block size is only logical block size aligned.

> 
> > 
> >> However, sd/sd_zbc does not change max_hw_sectors_kb to ensure alignment to 4K
> >> on 512e disks. There is also nullblk which uses the default max_hw_sectors_kb to
> >> 255 x 512B sectors, which is not 4K aligned if the nullb device is created with
> >> 4K block size.
> > 
> > Actually the real limit is from max_sectors_kb which is <= max_hw_sectors_kb, and
> > both should be aligned with logical block size, IMO.
> 
> Yes, agreed, but for nullblk device created with block size = 4K it is not. So

That is because the default magic number of BLK_SAFE_MAX_SECTORS.

> one driver to patch for sure. However, I though having some forced alignment in
> blk_queue_max_hw_sectors() for limit->max_hw_sectors and limit->max_sectors
> would avoid tripping on weird values for weird drives...

Maybe we can update it once the logical block size is available, such
as:

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 9a2c23cd9700..f9cbaadaa267 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -311,6 +311,14 @@ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
 }
 EXPORT_SYMBOL(blk_queue_max_segment_size);
 
+static unsigned blk_queue_round_sectors(struct request_queue *q,
+		unsigned sectors)
+{
+	u64 bytes = sectors << 9;
+
+	return (unsigned)round_down(bytes, queue_logical_block_size(q));
+}
+
 /**
  * blk_queue_logical_block_size - set logical block size for the queue
  * @q:  the request queue for the device
@@ -330,6 +338,9 @@ void blk_queue_logical_block_size(struct request_queue *q, unsigned int size)
 
 	if (q->limits.io_min < q->limits.physical_block_size)
 		q->limits.io_min = q->limits.physical_block_size;
+
+	q->limits.max_sectors = blk_queue_round_sectors(q,
+			q->limits.max_sectors)
 }
 EXPORT_SYMBOL(blk_queue_logical_block_size);
 


Thanks,
Ming


  reply	other threads:[~2020-07-17  9:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200717091124.GC670561@T590 \
    --to=ming.lei@redhat.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.