Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Oct 2011 20:57:04 +1100
From:      Lawrence Stewart <lstewart@freebsd.org>
To:        lev@freebsd.org
Cc:        fs@freebsd.org
Subject:   Re: code in GEOM thread could not use vnode API (Was: alq_open_flags() panics in _mtx_lock_flags())
Message-ID:  <4E8986F0.3050007@freebsd.org>
In-Reply-To: <349860851.20111003113417@serebryakov.spb.ru>
References:  <1258376930.20111002193223@serebryakov.spb.ru> <228926402.20111002231459@serebryakov.spb.ru> <349860851.20111003113417@serebryakov.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
[trimming current@ and geom@]

On 10/03/11 18:34, Lev Serebryakov wrote:
> Hello, Current.
> You wrote 2 октября 2011 г., 23:14:59:
>
>>    It seems, that error only occurs when I call alq API from geom
>> threads (from g_events, for example). Module, which is not GEOM
>> class, could use this API without any problem!
>
>>    Is it normal, that GEOM could not use vnode API? Is it normal, that
>> this leads to panic, and not some diagnostic messages, even with
>> WITNESS and other diagnostic options turned on?
>
>    not holding (explicitly release before call) topology lock doesn't
>   help.

I know nothing about VFS, but wonder if it's something to do with the 
credentials you pass in?

Alternatively, the way we do the VFS related calls in alq_open_flags() 
could be at fault... does anyone see anything wrong with the following 
(from sys/kern/kern_alq.c):

##########
int
alq_open_flags(struct alq **alqp, const char *file, struct ucred *cred, 
int cmode,
     int size, int flags)
{
         struct thread *td;
         struct nameidata nd;
         struct alq *alq;
         int oflags;
         int error;
         int vfslocked;

         KASSERT((size > 0), ("%s: size <= 0", __func__));

         *alqp = NULL;
         td = curthread;

         NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, file, td);
         oflags = FWRITE | O_NOFOLLOW | O_CREAT;

         error = vn_open_cred(&nd, &oflags, cmode, 0, cred, NULL);
         if (error)
                 return (error);

         vfslocked = NDHASGIANT(&nd);
         NDFREE(&nd, NDF_ONLY_PNBUF);
         /* We just unlock so we hold a reference */
         VOP_UNLOCK(nd.ni_vp, 0);
         VFS_UNLOCK_GIANT(vfslocked);

        <more code after this>
##########

Lev, are you able to share your code with us?

Cheers,
Lawrence



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