From owner-svn-src-head@freebsd.org Sun Dec 29 15:47:38 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A6C941E2326; Sun, 29 Dec 2019 15:47:38 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47m4hB3zSfz3F5N; Sun, 29 Dec 2019 15:47:38 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 83C451BB6E; Sun, 29 Dec 2019 15:47:38 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBTFlcnl009974; Sun, 29 Dec 2019 15:47:38 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBTFlcM4009972; Sun, 29 Dec 2019 15:47:38 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201912291547.xBTFlcM4009972@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sun, 29 Dec 2019 15:47:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356176 - in head: lib/geom/nop sys/geom/nop X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: in head: lib/geom/nop sys/geom/nop X-SVN-Commit-Revision: 356176 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Dec 2019 15:47:38 -0000 Author: oshogbo Date: Sun Dec 29 15:47:37 2019 New Revision: 356176 URL: https://svnweb.freebsd.org/changeset/base/356176 Log: gnop: change the "count until fail" option Change the "count_until_fail" option of gnop, now it enables the failing rating instead of setting them to 100%. The original patch introduced the new flag, which sets the fail/rate to 100% after N requests. In some cases, we don't want to have 100% of failure probabilities. We want to start failing at some point. For example, on the early stage, we may like to allow some read/writes requests before having some requests delayed - when we try to mount the partition, or when we are trying to import the pool. Another case may be to check how scrub in ZFS will behave on different stages. This allows us to cover more cases. The previous behavior still may be configured. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22632 Modified: head/lib/geom/nop/gnop.8 head/sys/geom/nop/g_nop.c Modified: head/lib/geom/nop/gnop.8 ============================================================================== --- head/lib/geom/nop/gnop.8 Sun Dec 29 15:46:59 2019 (r356175) +++ head/lib/geom/nop/gnop.8 Sun Dec 29 15:47:37 2019 (r356176) @@ -123,8 +123,8 @@ See Additional options: .Bl -tag -width "-c count_until_fail" .It Fl c Ar count_until_fail -Specifies the number of I/O requests to allow before setting the read and write -failure probabilities to 100%. +Specifies the number of I/O requests to allow before setting the read, write and +delay failure probabilities. .It Fl d Ar delaymsec Specifies the delay of the requests in milliseconds. Note that requests will be delayed before they are sent to the backing device. Modified: head/sys/geom/nop/g_nop.c ============================================================================== --- head/sys/geom/nop/g_nop.c Sun Dec 29 15:46:59 2019 (r356175) +++ head/sys/geom/nop/g_nop.c Sun Dec 29 15:47:37 2019 (r356176) @@ -204,31 +204,35 @@ g_nop_start(struct bio *bp) struct bio *cbp; u_int failprob, delayprob, delaytime; - failprob = delayprob = 0; + failprob = delayprob = delaytime = 0; gp = bp->bio_to->geom; sc = gp->softc; G_NOP_LOGREQ(bp, "Request received."); mtx_lock(&sc->sc_lock); - if (sc->sc_count_until_fail != 0 && --sc->sc_count_until_fail == 0) { - sc->sc_rfailprob = 100; - sc->sc_wfailprob = 100; - } switch (bp->bio_cmd) { case BIO_READ: sc->sc_reads++; sc->sc_readbytes += bp->bio_length; - failprob = sc->sc_rfailprob; - delayprob = sc->sc_rdelayprob; - delaytime = sc->sc_delaymsec; + if (sc->sc_count_until_fail != 0) { + sc->sc_count_until_fail -= 1; + } else { + failprob = sc->sc_rfailprob; + delayprob = sc->sc_rdelayprob; + delaytime = sc->sc_delaymsec; + } break; case BIO_WRITE: sc->sc_writes++; sc->sc_wrotebytes += bp->bio_length; - failprob = sc->sc_wfailprob; - delayprob = sc->sc_wdelayprob; - delaytime = sc->sc_delaymsec; + if (sc->sc_count_until_fail != 0) { + sc->sc_count_until_fail -= 1; + } else { + failprob = sc->sc_wfailprob; + delayprob = sc->sc_wdelayprob; + delaytime = sc->sc_delaymsec; + } break; case BIO_DELETE: sc->sc_deletes++; @@ -262,6 +266,7 @@ g_nop_start(struct bio *bp) break; } mtx_unlock(&sc->sc_lock); + if (failprob > 0) { u_int rval;