From owner-svn-src-projects@FreeBSD.ORG Fri Aug 13 03:03:37 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74DCD106566C; Fri, 13 Aug 2010 03:03:37 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49FE98FC1D; Fri, 13 Aug 2010 03:03:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7D33b4K074047; Fri, 13 Aug 2010 03:03:37 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7D33bYt074046; Fri, 13 Aug 2010 03:03:37 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201008130303.o7D33bYt074046@svn.freebsd.org> From: Jeff Roberson Date: Fri, 13 Aug 2010 03:03:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211253 - projects/ofed/head/sys/ofed/include/linux X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2010 03:03:37 -0000 Author: jeff Date: Fri Aug 13 03:03:36 2010 New Revision: 211253 URL: http://svn.freebsd.org/changeset/base/211253 Log: - Correct the sense of the bitmap in idr_remove() - Add initialization via sysinit for statically defined irs. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/ofed/include/linux/idr.h projects/ofed/head/sys/ofed/include/linux/linux_idr.c Modified: projects/ofed/head/sys/ofed/include/linux/idr.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/idr.h Fri Aug 13 00:45:30 2010 (r211252) +++ projects/ofed/head/sys/ofed/include/linux/idr.h Fri Aug 13 03:03:36 2010 (r211253) @@ -29,6 +29,8 @@ #ifndef _LINUX_IDR_H_ #define _LINUX_IDR_H_ +#include + #define IDR_BITS 5 #define IDR_SIZE (1 << IDR_BITS) #define IDR_MASK (IDR_SIZE - 1) @@ -44,13 +46,16 @@ struct idr_layer { }; struct idr { + struct mtx lock; struct idr_layer *top; struct idr_layer *free; int layers; - struct mtx lock; }; -#define DEFINE_IDR(name) struct idr name +#define DEFINE_IDR(name) \ + struct idr name; \ + SYSINIT(name##_idr_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST, \ + idr_init, &(name)); void *idr_find(struct idr *idp, int id); int idr_pre_get(struct idr *idp, gfp_t gfp_mask); Modified: projects/ofed/head/sys/ofed/include/linux/linux_idr.c ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/linux_idr.c Fri Aug 13 00:45:30 2010 (r211252) +++ projects/ofed/head/sys/ofed/include/linux/linux_idr.c Fri Aug 13 03:03:36 2010 (r211253) @@ -142,7 +142,7 @@ idr_remove(struct idr *idr, int id) * We could make this non-fatal and unwind but linux dumps a stack * and a warning so I don't think it's necessary. */ - if (il == NULL || (il->bitmap & (1 << idx)) == 0) + if (il == NULL || (il->bitmap & (1 << idx)) != 0) panic("idr_remove: Item %d not allocated (%p, %p)\n", id, idr, il); il->ary[idx] = NULL; @@ -173,7 +173,7 @@ idr_replace(struct idr *idr, void *ptr, /* * Replace still returns an error if the item was not allocated. */ - if (il != NULL && (il->bitmap & (1 << idx)) == 0) { + if (il != NULL && (il->bitmap & (1 << idx)) != 0) { res = il->ary[idx]; il->ary[idx] = ptr; }