From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 19 15:48:27 2010 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2654E1065672; Sat, 19 Jun 2010 15:48:26 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from gw03.mail.saunalahti.fi (gw03.mail.saunalahti.fi [195.197.172.111]) by mx1.freebsd.org (Postfix) with ESMTP id A0B588FC16; Sat, 19 Jun 2010 15:48:26 +0000 (UTC) Received: from a91-153-117-195.elisa-laajakaista.fi (a91-153-117-195.elisa-laajakaista.fi [91.153.117.195]) by gw03.mail.saunalahti.fi (Postfix) with SMTP id D19C12164DD; Sat, 19 Jun 2010 18:48:22 +0300 (EEST) Date: Sat, 19 Jun 2010 18:48:22 +0300 From: Jaakko Heinonen To: freebsd-hackers@FreeBSD.org Message-ID: <20100619154822.GA1166@a91-153-117-195.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: phk@FreeBSD.org Subject: [patch] extending alloc_unr(9) to allocate specific unit numbers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jun 2010 15:48:27 -0000 Hi, I wrote a patch to extend the kernel unit number allocator for allocating specific unit numbers. The patch adds a new function alloc_unr_specific() which returns the requested unit number if it is free and -1 if the number is already allocated or out of the range. Unlike alloc_unr(), alloc_unr_specific() may allocate memory and thus sleep. The patch is here: http://people.freebsd.org/~jh/patches/alloc_unr_specific.diff I think that this functionality has been requested by some people. Reviews/comments? As an example here is md(4) converted to use alloc_unr() / alloc_unr_specific(): http://people.freebsd.org/~jh/patches/md-alloc_unr.diff -- Jaakko