From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 3 00:58:33 2011 Return-Path: Delivered-To: hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 301E1106566B; Mon, 3 Oct 2011 00:58:33 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id EAF578FC14; Mon, 3 Oct 2011 00:58:32 +0000 (UTC) Received: from lstewart1.loshell.room52.net (ppp59-167-184-191.static.internode.on.net [59.167.184.191]) by lauren.room52.net (Postfix) with ESMTPSA id AD99C7E824; Mon, 3 Oct 2011 11:43:09 +1100 (EST) Message-ID: <4E89051D.30908@freebsd.org> Date: Mon, 03 Oct 2011 11:43:09 +1100 From: Lawrence Stewart User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0.2) Gecko/20110914 Thunderbird/6.0.2 MIME-Version: 1.0 To: lev@FreeBSD.org References: <1258376930.20111002193223@serebryakov.spb.ru> In-Reply-To: <1258376930.20111002193223@serebryakov.spb.ru> Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on lauren.room52.net Cc: hackers@FreeBSD.org Subject: Re: alq_open_flags() panics in _mtx_lock_flags() 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: Mon, 03 Oct 2011 00:58:33 -0000 [trimmed current@ from CC] Hi Lev, On 10/03/11 02:32, Lev Serebryakov wrote: > Hello, FreeBSD. > > I'm trying to create logging queue with alq kernel API. I call > alq_open_flags() like this in my module: > > error = alq_open_flags(&sc->sc_alq, sc->sc_vnode_name, > curthread->td_ucred, ALQ_DEFAULT_CMODE, > sizeof(struct g_log_entry), ALQ_ORDERED); > > and my system (10-CURRENT) panics with this stack trace (top frames > are DDB-related, so I omit them): > > #5 0xc06101c3 in kdb_trap (type=12, code=0, tf=0xc4e29990) > at /usr/home/lev/FreeBSD-head/sys/kern/subr_kdb.c:620 > #6 0xc08290af in trap_fatal (frame=0xc4e29990, eva=136) > at /usr/home/lev/FreeBSD-head/sys/i386/i386/trap.c:958 > #7 0xc08292c0 in trap_pfault (frame=0xc4e29990, usermode=0, eva=136) > at /usr/home/lev/FreeBSD-head/sys/i386/i386/trap.c:880 > #8 0xc0829f46 in trap (frame=0xc4e29990) > at /usr/home/lev/FreeBSD-head/sys/i386/i386/trap.c:555 > #9 0xc0812e7c in calltrap () > at /usr/home/lev/FreeBSD-head/sys/i386/i386/exception.s:168 > #10 0xc05cafc0 in _mtx_lock_flags (m=0x78, opts=0, > file=0xc088c140 "/usr/home/lev/FreeBSD-head/sys/kern/vfs_subr.c", > line=2169) at /usr/home/lev/FreeBSD-head/sys/kern/kern_mutex.c:194 > #11 0xc0672eb2 in vref (vp=0x0) > at /usr/home/lev/FreeBSD-head/sys/kern/vfs_subr.c:2169 > #12 0xc066932f in namei (ndp=0xc4e29b74) > at /usr/home/lev/FreeBSD-head/sys/kern/vfs_lookup.c:264 > #13 0xc0682900 in vn_open_cred (ndp=0xc4e29b74, flagp=0xc4e29be8, cmode=384, > vn_open_flags=0, cred=0xc50fee80, fp=0x0) > at /usr/home/lev/FreeBSD-head/sys/kern/vfs_vnops.c:137 > #14 0xc5c42609 in alq_open_flags (alqp=0xc550dc08, > file=0xc5108d40 "/usr/ada4.log", cred=0xc50fee80, cmode=384, size=28, > flags=16) > at /usr/home/lev/FreeBSD-head/sys/modules/alq/../../kern/kern_alq.c:451 > > It seems, that vref() get NULL instead of valid pointer to struct > vnode. But I have no idea -- why?! Yes, I have no such file created, > but man alq(9) says, that it will create file for me. And if I point > to existed file, it panic anyway. > > What do I do wrong?! > I don't see anything obviously wrong with your call to alq_open_flags(), other than that I think you want to set your buffer size to be a multiple of "sizeof(struct g_log_entry)". The small queue size wouldn't cause the panic you're seeing though. It's hard to draw any real conclusions without seeing your code. Are you able to share it? Cheers, Lawrence