From owner-svn-src-head@freebsd.org Sat Jun 10 16:11:40 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 E3C99BF0BE1; Sat, 10 Jun 2017 16:11:40 +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 BBF807DD7A; Sat, 10 Jun 2017 16:11:40 +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 v5AGBdaA054769; Sat, 10 Jun 2017 16:11:39 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5AGBdqg054767; Sat, 10 Jun 2017 16:11:39 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201706101611.v5AGBdqg054767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Sat, 10 Jun 2017 16:11:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319793 - 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: Sat, 10 Jun 2017 16:11:41 -0000 Author: alc Date: Sat Jun 10 16:11:39 2017 New Revision: 319793 URL: https://svnweb.freebsd.org/changeset/base/319793 Log: Remove an unnecessary field from struct blist. (The comment describing what this field represented was also inaccurate.) Suggested by: kib In r178792, blist_create() grew a malloc flag, allowing M_NOWAIT to be specified. However, blist_create() was not modified to handle the possibility that a malloc() call failed. Address this omission. Increase the width of the local variable "radix" to 64 bits. (This matches the width of the corresponding field in struct blist.) Reviewed by: kib MFC after: 6 weeks 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 Sat Jun 10 14:47:01 2017 (r319792) +++ head/sys/kern/subr_blist.c Sat Jun 10 16:11:39 2017 (r319793) @@ -156,7 +156,7 @@ blist_t blist_create(daddr_t blocks, int flags) { blist_t bl; - int radix; + daddr_t nodes, radix; int skip = 0; /* @@ -170,13 +170,19 @@ blist_create(daddr_t blocks, int flags) } bl = malloc(sizeof(struct blist), M_SWAP, flags | M_ZERO); + if (bl == NULL) + return (NULL); bl->bl_blocks = blocks; bl->bl_radix = radix; bl->bl_skip = skip; - bl->bl_rootblks = 1 + - blst_radix_init(NULL, bl->bl_radix, bl->bl_skip, blocks); - bl->bl_root = malloc(sizeof(blmeta_t) * bl->bl_rootblks, M_SWAP, flags); + nodes = 1 + blst_radix_init(NULL, radix, bl->bl_skip, blocks); + bl->bl_root = malloc(nodes * sizeof(blmeta_t), M_SWAP, flags); + if (bl->bl_root == NULL) { + free(bl, M_SWAP); + return (NULL); + } + blst_radix_init(bl->bl_root, radix, bl->bl_skip, blocks); #if defined(BLIST_DEBUG) printf( @@ -184,14 +190,13 @@ blist_create(daddr_t blocks, int flags) ", requiring %lldK of ram\n", (long long)bl->bl_blocks, (long long)bl->bl_blocks * 4 / 1024, - (long long)(bl->bl_rootblks * sizeof(blmeta_t) + 1023) / 1024 + (long long)(nodes * sizeof(blmeta_t) + 1023) / 1024 ); printf("BLIST raw radix tree contains %lld records\n", - (long long)bl->bl_rootblks); + (long long)nodes); #endif - blst_radix_init(bl->bl_root, bl->bl_radix, bl->bl_skip, blocks); - return(bl); + return (bl); } void Modified: head/sys/sys/blist.h ============================================================================== --- head/sys/sys/blist.h Sat Jun 10 14:47:01 2017 (r319792) +++ head/sys/sys/blist.h Sat Jun 10 16:11:39 2017 (r319793) @@ -84,7 +84,6 @@ typedef struct blist { daddr_t bl_skip; /* starting skip */ daddr_t bl_free; /* number of free blocks */ blmeta_t *bl_root; /* root of radix tree */ - daddr_t bl_rootblks; /* daddr_t blks allocated for tree */ } *blist_t; #define BLIST_META_RADIX 16