Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Sep 2005 17:29:24 +0200
From:      Sebastien <sebastien.bourdeauducq@gmail.com>
To:        freebsd-fs@freebsd.org
Subject:   Filesystem access from a KLD causes "vrele: negative ref cnt" panic
Message-ID:  <200509101729.24912.sebastien.bourdeauducq@gmail.com>

next in thread | raw e-mail | index | archive | help
Hello,
When the following kernel code has been run :

------------------------
  struct thread *td = curthread;
  struct nameidata nd;
  int flags, resid;
  struct vattr vat;

  /* Some threads don't have a current working directory, set this to avoid a 
page fault on vn_open() call */
  if(td->td_proc->p_fd->fd_rdir == NULL) td->td_proc->p_fd->fd_rdir = 
rootvnode;
  if(td->td_proc->p_fd->fd_cdir == NULL) td->td_proc->p_fd->fd_cdir = 
rootvnode;
  NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, &filename[0], td);
  flags = FREAD;
  vn_open(&nd, &flags, 0, -1);
  NDFREE(&nd, NDF_ONLY_PNBUF);
  /* Get the file size. */
  VOP_GETATTR(nd.ni_vp, &vat, td->td_ucred, td);
  VOP_UNLOCK(nd.ni_vp, 0, td);
  vn_rdwr(UIO_READ, nd.ni_vp, buf, vat.va_size, 0, UIO_SYSSPACE, 
IO_NODELOCKED, td->td_ucred, NOCRED, &resid, td);
  vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
------------------------

I have a random panic "vrele: negative ref cnt" when I shutdown the system. Am 
I double-freeing something in my code ? The fact that the panic is caused 
randomly suggests there is a synchronization problem - but the above code is 
always running under the protection of the Giant mutex.
Regards,
Sebastien



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509101729.24912.sebastien.bourdeauducq>