linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@meta.com>,
	linux-block@vger.kernel.org, axboe@kernel.dk,
	martin.petersen@oracle.com
Subject: Re: [PATCH] block: save user max_sectors limit
Date: Tue, 27 Dec 2022 09:49:15 -0700	[thread overview]
Message-ID: <Y6siCw6JFqTpsObx@kbusch-mbp> (raw)
In-Reply-To: <20221223060009.GA3088@lst.de>

On Fri, Dec 23, 2022 at 07:00:09AM +0100, Christoph Hellwig wrote:
> On Thu, Dec 22, 2022 at 09:52:04AM -0800, Keith Busch wrote:
> > +		max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS);
> 
> And please make BLK_DEF_MAX_SECTORS an unsigned constant as it should be
> and drop the min_t here.  Instead of working around type mismatches
> just avoid them from the beginning..

Let me just make sure I understand: you don't want BLK_DEF_MAX_SECTORS
defined in an enum, and instead want it a 'const unsigned int'? Or
#define?
 
> > +	} else if (max_sectors_kb > max_hw_sectors_kb ||
> > +		   max_sectors_kb < page_kb)  {
> >  		return -EINVAL;
> 
> And this check should probably move above the old one to keep the
> sanity checks first.
> 
> > +	} else {
> > +		q->limits.max_user_sectors = max_sectors_kb << 1;
> > +	}
> 
> i.e.
> 
> 	if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
> 		return -EINVAL;
> 
> 	q->limits.max_user_sectors = max_sectors_kb << 1;
> 
> 	/* reset to default when the user clears max_sectors_kb: */
> 	if (max_sectors_kb == 0) {

We'll never reach here since 0 is < page_kb. But I think I can clean
this up a little bit for the next version.

> 		max_sectors_kb =
> 			min(max_hw_sectors_kb, BLK_DEF_MAX_SECTORS >> 1);
> 	}

  reply	other threads:[~2022-12-27 16:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-22 17:52 [PATCH] block: save user max_sectors limit Keith Busch
2022-12-23  6:00 ` Christoph Hellwig
2022-12-27 16:49   ` Keith Busch [this message]
2022-12-27 16:53     ` Christoph Hellwig
2022-12-27  2:13 ` Damien Le Moal
  -- strict thread matches above, loose matches on Subject: below --
2022-12-21 16:27 Keith Busch
     [not found] ` <202212221657.yQawgPsu-lkp@intel.com>
2022-12-22  8:40   ` Christoph Hellwig
2022-12-22 15:40     ` Keith Busch
2022-12-22 16:07       ` Martin K. Petersen

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=Y6siCw6JFqTpsObx@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@meta.com \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.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 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).