All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	Rui Salvaterra <rsalvaterra@gmail.com>,
	stable@vger.kernel.org, Mike Snitzer <snitzer@redhat.com>,
	Xiao Ni <xni@redhat.com>,
	Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Subject: Re: [PATCH 1/3] block: make sure discard bio is aligned with logical block size
Date: Mon, 29 Oct 2018 10:42:40 +0800	[thread overview]
Message-ID: <20181029024239.GB32606@ming.t460p> (raw)
In-Reply-To: <20181028154947.GB3061@lst.de>

On Sun, Oct 28, 2018 at 04:49:47PM +0100, Christoph Hellwig wrote:
> On Sun, Oct 28, 2018 at 08:51:31AM +0800, Ming Lei wrote:
> > On Fri, Oct 26, 2018 at 09:44:15AM +0200, Christoph Hellwig wrote:
> > > >  		if (req_sects > UINT_MAX >> 9)
> > > > -			req_sects = UINT_MAX >> 9;
> > > > +			req_sects = (UINT_MAX >> 9) & ~bs_mask;
> > > 
> > > Given that we have this same thing duplicated in write zeroes
> > > what about a documented helper?
> > 
> > IMO, using UINT_MAX & bs_mask is better because it is self-explanatory
> > in the context.
> 
> I don't think it is in any way.  I understand it because I know the
> code, but there is nothing that documents why we do that.

Then how about introducing this helper?

 /*
+ * The max sectors one bio can handle is 'UINT_MAX >> 9' becasue
+ * bvec_iter.bi_size is defined as 'unsigned int', also it has to aligned
+ * to with logical block size which is minimum accepted unit by hardware.
+ */
+static inline unsigned int blk_max_allowed_max_secotrs(struct request_queue *q)
+{
+       return round_down(UINT_MAX, queue_logical_block_size(q)) >> 9;
+}
+
+/*

Thanks,
Ming

  reply	other threads:[~2018-10-29  2:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26  6:24 [PATCH 0/3] block: make sure discard/writesame bio is aligned with logical block size Ming Lei
2018-10-26  6:24 ` [PATCH 1/3] block: make sure discard " Ming Lei
2018-10-26  7:44   ` Christoph Hellwig
2018-10-28  0:51     ` Ming Lei
2018-10-28 15:49       ` Christoph Hellwig
2018-10-29  2:42         ` Ming Lei [this message]
2018-10-26  6:24 ` [PATCH 2/3] block: cleanup __blkdev_issue_discard() Ming Lei
2018-10-26  7:45   ` Christoph Hellwig
2018-10-26  6:24 ` [PATCH 3/3] block: make sure writesame bio is aligned with logical block size Ming Lei

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=20181029024239.GB32606@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=mariusz.dabrowski@intel.com \
    --cc=rsalvaterra@gmail.com \
    --cc=snitzer@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=xni@redhat.com \
    /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.