Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jun 2017 16:19:24 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319755 - in head/sys: kern sys
Message-ID:  <201706091619.v59GJOct062571@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706091619.v59GJOct062571>