From owner-svn-src-head@freebsd.org Fri Jun 9 16:19:25 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 5F158BF87DC; Fri, 9 Jun 2017 16:19:25 +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 3A7CC731B7; Fri, 9 Jun 2017 16:19:25 +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 v59GJOHd062573; Fri, 9 Jun 2017 16:19:24 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v59GJOct062571; Fri, 9 Jun 2017 16:19:24 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201706091619.v59GJOct062571@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Fri, 9 Jun 2017 16:19:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319755 - in head/sys: kern sys 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: Fri, 09 Jun 2017 16:19:25 -0000 Author: alc Date: Fri Jun 9 16:19:24 2017 New Revision: 319755 URL: https://svnweb.freebsd.org/changeset/base/319755 Log: blist_fill()'s return type is too narrow. blist_fill() accepts a 64-bit quantity as the size of the range to fill, but returns a 32-bit quantity as the number of blocks that were allocated to fill that range. This revision corrects that mismatch. Currently, swaponsomething() limits the size of a swap area to prevent arithmetic arithmetic overflow in other parts of the blist allocator. That limit has also prevented this type mismatch from causing problems. Reviewed by: kib, markj MFC after: 6 weeks Differential Revision: https://reviews.freebsd.org/D11096 Modified: head/sys/kern/subr_blist.c head/sys/sys/blist.h Modified: head/sys/kern/subr_blist.c ============================================================================== --- head/sys/kern/subr_blist.c Fri Jun 9 15:54:48 2017 (r319754) +++ head/sys/kern/subr_blist.c Fri Jun 9 16:19:24 2017 (r319755) @@ -127,8 +127,8 @@ static void blst_meta_free(blmeta_t *scan, daddr_t fre daddr_t radix, int skip, daddr_t blk); static void blst_copy(blmeta_t *scan, daddr_t blk, daddr_t radix, daddr_t skip, blist_t dest, daddr_t count); -static int blst_leaf_fill(blmeta_t *scan, daddr_t blk, int count); -static int blst_meta_fill(blmeta_t *scan, daddr_t allocBlk, daddr_t count, +static daddr_t blst_leaf_fill(blmeta_t *scan, daddr_t blk, int count); +static daddr_t blst_meta_fill(blmeta_t *scan, daddr_t allocBlk, daddr_t count, daddr_t radix, int skip, daddr_t blk); static daddr_t blst_radix_init(blmeta_t *scan, daddr_t radix, int skip, daddr_t count); @@ -248,10 +248,10 @@ blist_free(blist_t bl, daddr_t blkno, daddr_t count) * actually filled that were free before the call. */ -int +daddr_t blist_fill(blist_t bl, daddr_t blkno, daddr_t count) { - int filled; + daddr_t filled; if (bl) { if (bl->bl_radix == BLIST_BMAP_RADIX) @@ -726,11 +726,11 @@ static void blst_copy( * the number of blocks allocated by the call. */ -static int +static daddr_t blst_leaf_fill(blmeta_t *scan, daddr_t blk, int count) { int n = blk & (BLIST_BMAP_RADIX - 1); - int nblks; + daddr_t nblks; u_daddr_t mask, bitmap; mask = ((u_daddr_t)-1 << n) & @@ -753,7 +753,7 @@ blst_leaf_fill(blmeta_t *scan, daddr_t blk, int count) * range must be within the extent of this node. Returns the * number of blocks allocated by the call. */ -static int +static daddr_t blst_meta_fill( blmeta_t *scan, daddr_t allocBlk, @@ -764,7 +764,7 @@ blst_meta_fill( ) { int i; int next_skip = ((u_int)skip / BLIST_META_RADIX); - int nblks = 0; + daddr_t nblks = 0; if (count > radix) panic("blist_meta_fill: allocation too large"); @@ -1047,8 +1047,8 @@ main(int ac, char **av) break; case 'l': if (sscanf(buf + 1, "%llx %lld", &da, &count) == 2) { - printf(" n=%d\n", - blist_fill(bl, da, count)); + printf(" n=%jd\n", + (intmax_t)blist_fill(bl, da, count)); } else { printf("?\n"); } Modified: head/sys/sys/blist.h ============================================================================== --- head/sys/sys/blist.h Fri Jun 9 15:54:48 2017 (r319754) +++ head/sys/sys/blist.h Fri Jun 9 16:19:24 2017 (r319755) @@ -96,7 +96,7 @@ extern blist_t blist_create(daddr_t blocks, int flags) extern void blist_destroy(blist_t blist); extern daddr_t blist_alloc(blist_t blist, daddr_t count); extern void blist_free(blist_t blist, daddr_t blkno, daddr_t count); -extern int blist_fill(blist_t bl, daddr_t blkno, daddr_t count); +extern daddr_t blist_fill(blist_t bl, daddr_t blkno, daddr_t count); extern void blist_print(blist_t blist); extern void blist_resize(blist_t *pblist, daddr_t count, int freenew, int flags);