tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: VOP_CREATE hanging
On Wed Aug 13 2008 at 04:16:03 -0700, Adam Burkepile wrote:
> >It is not legal to call VOP_CREATE() without calling namei (ultimately
> >VOP_LOOKUP()), since this call sets up a lot of state in the file
> >system
> >to prepare for the actual creation operation.
>
> Ok, I have made the changes you mentioned (I think), but I'm still
> having the hanging problem.
>
> printf("subfile not found, needs to be created\n");
> NDINIT(&sfnd, CREATE, FOLLOW | TRYEMULROOT,
> UIO_USERSPACE, SCARG(uap, sub_path));
>
> /* set namedata with namei */
> error = namei(&sfnd);
> printf("namei error = %d\n",error);
>
> sfnd.ni_cnd.cn_nameiop = CREATE;
> sfnd.ni_cnd.cn_flags |= LOCKPARENT | LOCKLEAF;
These locking flags affect only namei(), so setting them afterwards
makes no difference.
> if ((SCARG(uap, flags) & O_EXCL) == 0 &&
> ((SCARG(uap, flags) & O_NOFOLLOW) ==
> 0))
> sfnd.ni_cnd.cn_flags |= FOLLOW;
>
> //lock subfile directory
> vn_lock(sdvp, LK_EXCLUSIVE | LK_RETRY);
>
> /* set the attr of the new file */
> VATTR_NULL(&sfva);
> sfva.va_type = VREG;
> sfva.va_rdev = VNOVAL;
> sfva.va_mode = (bva.va_mode & ALLPERMS) &~ p->p_cwdi-
> >cwdi_cmask;
> if (SCARG(uap, flags) & O_EXCL)
> sfva.va_vaflags |= VA_EXCLUSIVE;
>
> error = VOP_LOOKUP(sdvp,&sfvp,&(sfnd.ni_cnd));
> printf("VOP_LOOKUP error = %d\n",error);
>
> error = VOP_CREATE(sdvp,&sfvp,&(sfnd.ni_cnd),&sfva);
> printf("VOP_CREATE error = %d\n",error);
>
> if (error == 0)
> vput(sfvp);
> goto out;
>
>
> If it helps, from what I've been able to tell this is the functions it
> goes through before it hangs:
> sys_subfile_open()
> VOP_CREATE()
> ufs_makeinode()
> ufs_direnter()
> UFS_BALLOC()
Why don't you just give the exact place where it is hanging? Getting a
backtrace or even just the program counter is quite trivial (but varies
in detail depending on your setup ;).
> I had a few other questions:
> 1. Is VERIEXEC_PATH_GET / VERIEXEC_PATH_PUT necessary for VOP_CREATE?
> 2. When you said "calling ... ultimately VOP_LOOKUP()", did you mean
> me calling it (like I am trying to do).
No, I meant namei() (or actually lookup() which is called by namei())
is supposed to call VOP_LOOKUP. What you are doing is ... unorthodox.
I have no idea what horrors will happen if you try to do that. But I
suspect namei() will already have exhausted the entire pathname leaving
your VOP_LOOKUP as a NOP. If you're really interested, single-step
through the code, no need for guessing.
> 3.
> >Or, if you're working just with ffs, you could hack
> >lookup into pieces so you can call the parts involved with the
> >necessary
> >setup for create.
>
> If VOP_LOOKUP is returning but ultimately messing up, could this be
> causing the problems that I'm having with VOP_CREATE? I ask because I
> am having a problem with VOP_LOOKUP not releasing some sort of lock on
> the fs. It is not letting me umount my test fs and manifest a some
> other weird errors (not being able to find files). The deadline is
> coming up so I was inclined to skip the problem and come back to it
> since it didn't seem like it was hanging the rest of the program and I
> want to have some functionality to show.
I have no idea without seeing all of your code. If the regular system
calls still work and you can unmount, the problem is most likely your
subfile syscalls. I suggest to adapt sys_mknod() for the VOP_CREATE()
case and see if that gets things rolling.
Home |
Main Index |
Thread Index |
Old Index