tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: VOP_CREATE hanging
On Aug 12, 2008, at 8:59 AM, David Holland wrote:
On Tue, Aug 12, 2008 at 06:02:21PM +0300, Antti Kantee wrote:
On Tue Aug 12 2008 at 07:40:05 -0700, Adam Burkepile wrote:
For my subfile project I am creating a directory and not attaching
it
to a parent directory, but rather storing the inode number of the
directory and retrieving it using VGET.
What does '..' point to in such a directory? Isn't that going to make
fsck angry?
Yeah, the plan was to make . and .. point to the subfile directory.
fsck is throwing a hissy fit right now but another part of the plan
was to make fsck realize that it should treat nodes that were these
special subfile directories differently, which is another problem that
I will have to tackle.
On Aug 12, 2008, at 8:02 AM, Antti Kantee wrote:
/* lock subfile directory */
if(VOP_ISLOCKED(sdvp) == 0){
printf("sdvp is unlocked, now locking\n");
vn_lock(sdvp, LK_EXCLUSIVE | LK_RETRY);
}
Please don't write code which does locking like this, it's just
begging
for trouble. Your code should always know if it has a node locked
or not.
I have taken out the unnecessary locks/unlocks, it was just easier at
the time.
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;
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()
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).
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.
Home |
Main Index |
Thread Index |
Old Index