code in GEOM thread could not use vnode API (Was: alq_open_flags() panics in _mtx_lock_flags())

Lawrence Stewart lstewart at freebsd.org
Mon Oct 3 10:13:35 UTC 2011


[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


More information about the freebsd-fs mailing list