linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Brown <neilb@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-raid@vger.kernel.org, dm-devel@redhat.com,
	linux-btrfs@vger.kernel.org
Subject: Re: [dm-devel] [PATCH] block: add a bi_error field to struct bio
Date: Wed, 10 Jun 2015 12:50:54 +1000	[thread overview]
Message-ID: <20150610125054.3da2abcc@home.neil.brown.name> (raw)
In-Reply-To: <1433338959-24808-2-git-send-email-hch@lst.de>

On Wed,  3 Jun 2015 15:42:39 +0200
Christoph Hellwig <hch@lst.de> wrote:

> Currently we have two different ways to signal an I/O error on a BIO:
> 
>  (1) by clearing the BIO_UPTODATE flag
>  (2) by returning a Linux errno value to the bi_end_io callback
> 
> The first one has the drawback of only communicating a single possible
> error (-EIO), and the second one has the drawback of not beeing persistent
> when bios are queued up, and are not passed along from child to parent
> bio in the ever more popular chaining scenario.  Having both mechanisms
> available has the additional drawback of utterly confusing driver authors
> and introducing bugs where various I/O submitters only deal with one of
> them, and the others have to add boilerplate code to deal with both kinds
> of error returns.
> 
> So add a new bi_error field to store an errno value directly in struct
> bio and remove the existing mechanisms to clean all this up.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

I really like this clean up.
It is unfortunate that the patch is so big, but I guess it has to be.

It mostly looks good, but review is hard and testing is harder :-(

I found:

> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index f80f1af..1bad16f 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
....
> @@ -1800,7 +1799,7 @@ static void end_sync_write(struct bio *bio, int error)
>  			reschedule_retry(r1_bio);
>  		else {
>  			put_buf(r1_bio);
> -			md_done_sync(mddev, s, uptodate);
> +			md_done_sync(mddev, s, !bio->bi_error);
>  		}
>  	}
>  }

This introduces a use-after-free.  put_buf(r1_bio) can  result in bio_put on
'bio'.
It is safe to move the put_buf call after the md_done_sync(), but it is
probably best to leave the 'update' variable as it.  i.e. Just change:

-	int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
+	int uptodate = !bio->bi_error;


I can't see any other problems with the md changes.

Reviewed-by: NeilBrown <neilb@suse.de> (md/raid parts)

Thanks,
NeilBrown

  parent reply	other threads:[~2015-06-10  2:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03 13:42 [RFC] add a bi_error field Christoph Hellwig
     [not found] ` <1433338959-24808-2-git-send-email-hch@lst.de>
2015-06-04  9:53   ` [dm-devel] [PATCH] block: add a bi_error field to struct bio Martin K. Petersen
2015-06-04 15:31   ` Mike Snitzer
2015-06-10  8:11     ` Christoph Hellwig
2015-06-10 15:26       ` Mike Snitzer
2015-06-10 16:01         ` Mike Snitzer
2015-06-10 16:04           ` Christoph Hellwig
2015-06-10 16:50             ` Mike Snitzer
2015-06-10 18:29               ` anup modak
2015-06-11  7:53         ` Christoph Hellwig
2015-06-11  7:59           ` Christoph Hellwig
2015-06-10  2:50   ` Neil Brown [this message]
2015-06-10  8:45     ` [dm-devel] [PATCH] " Christoph Hellwig
2015-06-11  7:59 ` [RFC] add a bi_error field Liu Bo
2015-06-11  8:05   ` Liu Bo
2015-06-11  8:08     ` Christoph Hellwig
2015-06-11  9:42       ` Liu Bo
  -- strict thread matches above, loose matches on Subject: below --
2015-07-20 13:29 add a bi_error field to struct bio V3 Christoph Hellwig
     [not found] ` <1437398977-8492-2-git-send-email-hch@lst.de>
2015-07-21  8:19   ` [dm-devel] [PATCH] block: add a bi_error field to struct bio Hannes Reinecke

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=20150610125054.3da2abcc@home.neil.brown.name \
    --to=neilb@suse.de \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-raid@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 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).