From owner-svn-src-head@freebsd.org Fri Dec 21 21:17:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C06D13574D2; Fri, 21 Dec 2018 21:17:46 +0000 (UTC) (envelope-from bde@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 C5FAD846E2; Fri, 21 Dec 2018 21:17:45 +0000 (UTC) (envelope-from bde@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 9D5EF1B0DC; Fri, 21 Dec 2018 21:17:45 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBLLHj1F035126; Fri, 21 Dec 2018 21:17:45 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBLLHjXK035125; Fri, 21 Dec 2018 21:17:45 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201812212117.wBLLHjXK035125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Fri, 21 Dec 2018 21:17:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342357 - head/sys/fs/msdosfs X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/sys/fs/msdosfs X-SVN-Commit-Revision: 342357 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C5FAD846E2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.955,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] 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: Fri, 21 Dec 2018 21:17:46 -0000 Author: bde Date: Fri Dec 21 21:17:45 2018 New Revision: 342357 URL: https://svnweb.freebsd.org/changeset/base/342357 Log: Fix clobbering of the fatchain cache for clustered i/o's when full clustering is not done. The bug caused extreme slowness for large files in some cases. There is no way to tell VOP_BMAP() how many blocks are wanted, so for all file systems it has to waste time in some cases by searching for more contiguous blocks than will be accessed. For msdosfs, it also clobbered the fatchain cache in these cases by advancing the cache to point to the chain entry for block that won't be read. This makes the cache useless for the next sequential i/o (or VOP_BMAP()), so the fat chain is searched from the beginning. The cache only has 1 relevant entry, so it is similarly useless for random i/o. Fix this by only advancing the cache to point to the chain entry for the first block that will be read. Clustering uses results from VOP_BMAP(), so when more than 1 block is read by clustering, the cache is not advanced as optimally as before, but it is at most 1 cluster size behind and searching the chain through the blocks for this cluster doesn't take too long. Modified: head/sys/fs/msdosfs/msdosfs_vnops.c Modified: head/sys/fs/msdosfs/msdosfs_vnops.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_vnops.c Fri Dec 21 20:46:45 2018 (r342356) +++ head/sys/fs/msdosfs/msdosfs_vnops.c Fri Dec 21 21:17:45 2018 (r342357) @@ -1740,6 +1740,7 @@ out: static int msdosfs_bmap(struct vop_bmap_args *ap) { + struct fatcache savefc; struct denode *dep; struct mount *mp; struct msdosfsmount *pmp; @@ -1766,6 +1767,20 @@ msdosfs_bmap(struct vop_bmap_args *ap) if (error != 0 || (ap->a_runp == NULL && ap->a_runb == NULL)) return (error); + /* + * Prepare to back out updates of the fatchain cache after the one + * for the first block done by pcbmap() above. Without the backout, + * then whenever the caller doesn't do i/o to all of the blocks that + * we find, the single useful cache entry would be too far in advance + * of the actual i/o to work for the next sequential i/o. Then the + * FAT would be searched from the beginning. With the backout, the + * FAT is searched starting at most a few blocks early. This wastes + * much less time. Time is also wasted finding more blocks than the + * caller will do i/o to. This is necessary because the runlength + * parameters are output-only. + */ + savefc = dep->de_fc[FC_LASTMAP]; + mp = vp->v_mount; maxio = mp->mnt_iosize_max / mp->mnt_stat.f_iosize; bnpercn = de_cn2bn(pmp, 1); @@ -1787,6 +1802,7 @@ msdosfs_bmap(struct vop_bmap_args *ap) } *ap->a_runb = run - 1; } + dep->de_fc[FC_LASTMAP] = savefc; return (0); }