From owner-svn-src-stable@freebsd.org Mon Dec 11 20:30:59 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD4ADE9D9BF; Mon, 11 Dec 2017 20:30:59 +0000 (UTC) (envelope-from asomers@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 mx1.freebsd.org (Postfix) with ESMTPS id 96DE9779CD; Mon, 11 Dec 2017 20:30:59 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBBKUwOn035573; Mon, 11 Dec 2017 20:30:58 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBBKUwP3035572; Mon, 11 Dec 2017 20:30:58 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201712112030.vBBKUwP3035572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 11 Dec 2017 20:30:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r326779 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/sys/cam/scsi X-SVN-Commit-Revision: 326779 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2017 20:30:59 -0000 Author: asomers Date: Mon Dec 11 20:30:58 2017 New Revision: 326779 URL: https://svnweb.freebsd.org/changeset/base/326779 Log: MFC r326036: da(4): Short-circuit unnecessary BIO_FLUSH commands sys/cam/scsi/scsi_da.c Complete BIO_FLUSH commands immediately if the da(4) device hasn't been written to since the last flush. If we haven't written to the device, there is no reason to send a flush. Submitted by: gibbs Reviewed by: imp Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D13106 Modified: stable/11/sys/cam/scsi/scsi_da.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_da.c Mon Dec 11 20:24:29 2017 (r326778) +++ stable/11/sys/cam/scsi/scsi_da.c Mon Dec 11 20:30:58 2017 (r326779) @@ -2994,6 +2994,18 @@ more: } case BIO_FLUSH: /* + * If we don't support sync cache, or the disk + * isn't dirty, FLUSH is a no-op. Use the + * allocated * CCB for the next bio if one is + * available. + */ + if ((softc->quirks & DA_Q_NO_SYNC_CACHE) != 0 || + (softc->flags & DA_FLAG_DIRTY) == 0) { + biodone(bp); + goto skipstate; + } + + /* * BIO_FLUSH doesn't currently communicate * range data, so we synchronize the cache * over the whole disk. We also force @@ -3008,6 +3020,15 @@ more: /*lb_count*/0, SSD_FULL_SIZE, da_default_timeout*1000); + /* + * Clear the dirty flag before sending the command. + * Either this sync cache will be successful, or it + * will fail after a retry. If it fails, it is + * unlikely to be successful if retried later, so + * we'll save ourselves time by just marking the + * device clean. + */ + softc->flags &= ~DA_FLAG_DIRTY; break; case BIO_ZONE: { int error, queue_ccb;