Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Dec 2018 21:53:33 -0500
From:      Yoshihiro Ota <ota@j.email.ne.jp>
To:        Bruce Evans <bde@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r342375 - head/sys/dev/md
Message-ID:  <20181223215333.5b0065776ba8cc162f0f7799@j.email.ne.jp>
In-Reply-To: <201812222259.wBMMxB1c053909@repo.freebsd.org>
References:  <201812222259.wBMMxB1c053909@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks.

I noticed when this was broken upon a new release long time ago but couldn't get any clue nor when this was broken (since I hadn't started following trunk/stable back then.)

Was that 7.0-RELEASE or 8.0-RELEASE....?

Anyway, good news and I will try to bring this to local 12.0-RELEASE.

Regards,
Hiro

On Sat, 22 Dec 2018 22:59:11 +0000 (UTC)
Bruce Evans <bde@FreeBSD.org> wrote:

> Author: bde
> Date: Sat Dec 22 22:59:11 2018
> New Revision: 342375
> URL: https://svnweb.freebsd.org/changeset/base/342375
> 
> Log:
>   Fix devstat on md devices, second attempt.  r341765 depends on
>   g_io_deliver() finishing initialization of the bio, but g_io_deliver()
>   actually destroys the bio.  INVARIANTS makes the bug obvious by
>   overwriting the bio with garbage.
>   
>   Restore the old order for calling devstat (except don't restore not calling
>   it for the error case), and translate to the devstat KPI so that this order
>   works.
>   
>   Reviewed by:	kib
> 
> Modified:
>   head/sys/dev/md/md.c
> 
> Modified: head/sys/dev/md/md.c
> ==============================================================================
> --- head/sys/dev/md/md.c	Sat Dec 22 21:49:25 2018	(r342374)
> +++ head/sys/dev/md/md.c	Sat Dec 22 22:59:11 2018	(r342375)
> @@ -1241,12 +1241,22 @@ md_kthread(void *arg)
>  			error = sc->start(sc, bp);
>  		}
>  
> +		if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) {
> +			/*
> +			 * Devstat uses (bio_bcount, bio_resid) for
> +			 * determining the length of the completed part of
> +			 * the i/o.  g_io_deliver() will translate from
> +			 * bio_completed to that, but it also destroys the
> +			 * bio so we must do our own translation.
> +			 */
> +			bp->bio_bcount = bp->bio_length;
> +			bp->bio_resid = (error == -1 ? bp->bio_bcount : 0);
> +			devstat_end_transaction_bio(sc->devstat, bp);
> +		}
>  		if (error != -1) {
>  			bp->bio_completed = bp->bio_length;
>  			g_io_deliver(bp, error);
>  		}
> -		if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE)
> -			devstat_end_transaction_bio(sc->devstat, bp);
>  	}
>  }
>  
> _______________________________________________
> svn-src-all@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20181223215333.5b0065776ba8cc162f0f7799>