mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Dmitry Monakhov <dmonakhov@openvz.org>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	martin.petersen@oracle.com
Subject: Re: [PATCH 7/7] Guard bvec iteration logic v2
Date: Mon, 3 Apr 2017 08:34:28 -0600	[thread overview]
Message-ID: <c5328f91-79ec-f4f8-a9d1-bdf467e8c5f4@kernel.dk> (raw)
In-Reply-To: <1491204212-9952-8-git-send-email-dmonakhov@openvz.org>

On 04/03/2017 01:23 AM, Dmitry Monakhov wrote:
> @@ -66,12 +67,15 @@ struct bvec_iter {
>  	.bv_offset	= bvec_iter_offset((bvec), (iter)),	\
>  })
>  
> -static inline void bvec_iter_advance(const struct bio_vec *bv,
> +static inline int bvec_iter_advance(const struct bio_vec *bv,
>  				     struct bvec_iter *iter,
>  				     unsigned bytes)
>  {
> -	WARN_ONCE(bytes > iter->bi_size,
> -		  "Attempted to advance past end of bvec iter\n");
> +	if(unlikely(bytes > iter->bi_size)) {
> +		WARN(1, "Attempted to advance past end of bvec iter\n");
> +		iter->bi_size = 0;
> +		return -EINVAL;
> +	}

	if (WARN_ONCE(bytes > iter->bi_size,
			"Attempted to advance past end of bvec iter\n")) {
		...

would be cleaner.

-- 
Jens Axboe

  reply	other threads:[~2017-04-03 14:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-03  7:23 [PATCH 0/7] block: T10/DIF Fixes and cleanups v2 Dmitry Monakhov
2017-04-03  7:23 ` [PATCH 1/7] bio-integrity: Do not allocate integrity context for bio w/o data Dmitry Monakhov
2017-04-04  7:00   ` Christoph Hellwig
2017-04-03  7:23 ` [PATCH 2/7] bio-integrity: save original iterator for verify stage Dmitry Monakhov
2017-04-04  7:01   ` Christoph Hellwig
2017-04-04 12:15     ` Dmitry Monakhov
2017-04-03  7:23 ` [PATCH 3/7] bio-integrity: bio_trim should truncate integrity vector accordingly Dmitry Monakhov
2017-04-04  7:01   ` Christoph Hellwig
2017-04-03  7:23 ` [PATCH 4/7] bio-integrity: fix interface for bio_integrity_trim Dmitry Monakhov
2017-04-04  7:03   ` Christoph Hellwig
2017-04-03  7:23 ` [PATCH 5/7] bio-integrity: add bio_integrity_setup helper Dmitry Monakhov
2017-04-04  7:06   ` Christoph Hellwig
2017-04-03  7:23 ` [PATCH 6/7] T10: Move opencoded contants to common header Dmitry Monakhov
2017-04-04  7:09   ` Christoph Hellwig
2017-04-03  7:23 ` [PATCH 7/7] Guard bvec iteration logic v2 Dmitry Monakhov
2017-04-03 14:34   ` Jens Axboe [this message]
2017-04-04 15:03   ` Ming Lei
2017-04-04 15:19     ` Dmitry Monakhov
2017-04-04 15:56       ` Ming Lei
2017-04-03 21:12 ` [PATCH 0/7] block: T10/DIF Fixes and cleanups v2 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=c5328f91-79ec-f4f8-a9d1-bdf467e8c5f4@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=dmonakhov@openvz.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®