From owner-svn-src-head@freebsd.org Tue Jun 6 03:32:19 2017 Return-Path: Delivered-To: svn-src-head@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 2F992BEF48A; Tue, 6 Jun 2017 03:32:19 +0000 (UTC) (envelope-from alc@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 F27AC7B153; Tue, 6 Jun 2017 03:32:18 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v563WIvx068564; Tue, 6 Jun 2017 03:32:18 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v563WHax068562; Tue, 6 Jun 2017 03:32:17 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201706060332.v563WHax068562@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Tue, 6 Jun 2017 03:32:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319612 - in head/sys: kern vm X-SVN-Group: head 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.23 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: Tue, 06 Jun 2017 03:32:19 -0000 Author: alc Date: Tue Jun 6 03:32:17 2017 New Revision: 319612 URL: https://svnweb.freebsd.org/changeset/base/319612 Log: When the function blist_fill() was added to the kernel in r107913, the swap pager used a different scheme for striping the allocation of swap space across multiple devices. And, although blist_fill() was intended to support fill operations with large counts, the old striping scheme never performed a fill larger than the stripe size. Consequently, the misplacement of a sanity check in blst_meta_fill() went undetected. Now, moving forward in time to r118390, a new scheme for striping was introduced that maintained a blist allocator per device, but as noted in r318995, swapoff_one() was not fully and correctly converted to the new scheme. This change completes what was started in r318995 by fixing the underlying bug in blst_meta_fill() that stops swapoff_one() from simply performing a single blist_fill() operation. Reviewed by: kib MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D11043 Modified: head/sys/kern/subr_blist.c head/sys/vm/swap_pager.c Modified: head/sys/kern/subr_blist.c ============================================================================== --- head/sys/kern/subr_blist.c Tue Jun 6 02:15:00 2017 (r319611) +++ head/sys/kern/subr_blist.c Tue Jun 6 03:32:17 2017 (r319612) @@ -769,6 +769,8 @@ blst_meta_fill( int next_skip = ((u_int)skip / BLIST_META_RADIX); int nblks = 0; + if (count > radix) + panic("blist_meta_fill: allocation too large"); if (count == radix || scan->u.bmu_avail == 0) { /* * ALL-ALLOCATED special case @@ -799,9 +801,6 @@ blst_meta_fill( } else { radix /= BLIST_META_RADIX; } - - if (count > radix) - panic("blist_meta_fill: allocation too large"); i = (allocBlk - blk) / radix; blk += i * radix; Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Tue Jun 6 02:15:00 2017 (r319611) +++ head/sys/vm/swap_pager.c Tue Jun 6 03:32:17 2017 (r319612) @@ -2271,7 +2271,7 @@ done: static int swapoff_one(struct swdevt *sp, struct ucred *cred) { - u_long nblks, dvbase; + u_long nblks; #ifdef MAC int error; #endif @@ -2300,14 +2300,7 @@ swapoff_one(struct swdevt *sp, struct ucred *cred) */ mtx_lock(&sw_dev_mtx); sp->sw_flags |= SW_CLOSING; - for (dvbase = 0; dvbase < nblks; dvbase += BLIST_BMAP_RADIX) { - /* - * blist_fill() cannot allocate more than BLIST_BMAP_RADIX - * blocks per call. - */ - swap_pager_avail -= blist_fill(sp->sw_blist, - dvbase, ulmin(nblks - dvbase, BLIST_BMAP_RADIX)); - } + swap_pager_avail -= blist_fill(sp->sw_blist, 0, nblks); swap_total -= (vm_ooffset_t)nblks * PAGE_SIZE; mtx_unlock(&sw_dev_mtx);