From owner-freebsd-current Sun Jun 2 1: 8:50 2002 Delivered-To: freebsd-current@freebsd.org Received: from hotmail.com (oe50.pav0.hotmail.com [64.4.32.130]) by hub.freebsd.org (Postfix) with ESMTP id 1AD9437B400; Sun, 2 Jun 2002 01:08:34 -0700 (PDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 2 Jun 2002 01:08:33 -0700 X-Originating-IP: [210.74.136.33] From: "kai ouyang" To: "John Baldwin" , Subject: Help: from proc to thread? Date: Sun, 2 Jun 2002 16:08:30 +0800 MIME-Version: 1.0 X-Mailer: MSN Explorer 7.00.0021.1900 Content-Type: multipart/mixed; boundary="----=_NextPart_001_0003_01C20A4F.BD05C000" Message-ID: X-OriginalArrivalTime: 02 Jun 2002 08:08:33.0932 (UTC) FILETIME=[B0A58CC0:01C20A0C] Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG ------=_NextPart_001_0003_01C20A4F.BD05C000 Content-Type: multipart/alternative; boundary="----=_NextPart_002_0004_01C20A4F.BD05C000" ------=_NextPart_002_0004_01C20A4F.BD05C000 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Hi, Very thank your help! Now the box can boot. =20 I have some other problems about proc and thread. From the FreeBSD5.0 viewpoint, there are real thread in kernel, there are= associated with KSE. So many functions parameters change from proc to thread. There is the function in RAIDFrame in FreeBSD4.x. =20 int raidlookup(path, p, vpp) char *path; struct proc *p; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); =20 if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir =3D rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir =3D rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p); flags =3D FREAD | FWRITE; if ((error =3D vn_open(&nd, flags, 0)) !=3D 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp =3D nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error =3D VOP_GETATTR(vp, &va, p->p_ucred, p)) !=3D 0) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type !=3D VCHR) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, p); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp =3D vp; return (0); } Based on the explain of the thread: struct proc *td_proc; /* Associated p= rocess. */ in the struct thread. and refer to the CCD code. I modify this function as following: int raidlookup(path, td, vpp) char *path; struct thread *td; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; struct proc *p; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ p =3D td->td_proc; if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); =20 if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir =3D rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir =3D rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td); flags =3D FREAD | FWRITE; if ((error =3D vn_open(&nd, &flags, 0)) !=3D 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp =3D nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error =3D VOP_GETATTR(vp, &va, td->td_ucred, td)) !=3D 0) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type !=3D VCHR) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE,td->td_ucred, td); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp =3D vp; return (0); } Now the system will be crash , when it excutes the "p =3D td->td_proc". the system Information is : kernel: type 12 trap, code=3D0 Stopped at raidlookup+0x19: movl 0(%eax),%ebx If I mask the instructions form "p =3D td->td_proc" to "p->p_fd->fd_cdir = =3D rootvnode;", trace the code, I find it will be crash in vn_open. system infor: Stopped at vn_open+0x9: pushl 0x78(%eax) Why? I analyse the ccd code, it transfered the vn_open function, only change t= he second parameter. Best Regards Ouyang kai=B4=D3=CD=F8=D5=BE=B5=C3=B5=BD=B8=FC=B6=E0=D0=C5=CF=A2=A1=A3M= SN Explorer =C3=E2=B7=D1=CF=C2=D4=D8:http://explorer.msn.com/lccn ------=_NextPart_002_0004_01C20A4F.BD05C000 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
Hi,
Very thank your help! Now the box can boot.
I have some other proble= ms about proc and thread.
From the FreeBSD5.0 viewpoint, there are rea= l thread in kernel, there are associated with KSE.
So many functions p= arameters change from proc to thread.
There is the function in RAIDFra= me in FreeBSD4.x.
int raidlookup(path, p, vpp)
 char&= nbsp;  *path;
 struct proc *p;
 struct vnode **vpp;&= nbsp;/* result */
{
 struct nameidata nd;
 struct vnod= e *vp;
 struct vattr va;
 int     err= or, flags;
 /* Sanity check the p_fd fields.  This i= s really just a hack */
 if (!p->p_fd->fd_rdir || !p->p_= fd->fd_cdir)
  printf("Warning: p_fd fields not set\n");<= BR> 
 if (!p->p_fd->fd_rdir)
  p->p_fd= ->fd_rdir =3D rootvnode;
 if (!p->p_fd->fd_cdir)
&nbs= p; p->p_fd->fd_cdir =3D rootvnode;
 NDINIT(&nd, LO= OKUP, FOLLOW, UIO_SYSSPACE, path, p);
 flags =3D FREAD | FWRITE;<= BR> if ((error =3D vn_open(&nd, flags, 0)) !=3D 0) {
 &n= bsp;rf_printf(2, "RAIDframe: vn_open returned %d\n", error);
 &nb= sp;return (error);
 }
 vp =3D nd.ni_vp;
 if (vp-&= gt;v_usecount > 1) {
  VOP_UNLOCK(vp, 0, p);
 &nb= sp;(void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p);
  = rf_printf(1, "raidlookup() vp->v_usecount > 1\n");
  r= eturn (EBUSY);
 }
 if ((error =3D VOP_GETATTR(vp, &va= , p->p_ucred, p)) !=3D 0) {
  VOP_UNLOCK(vp, 0, p);
&n= bsp; (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p);
 = ; rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error);
&n= bsp; return (error);
 }
 /* XXX: eventually we shoul= d handle VREG, too. */
 if (va.va_type !=3D VCHR) {
 &nbs= p;VOP_UNLOCK(vp, 0, p);
  (void) vn_close(vp, FREAD | FWRITE= , p->p_ucred, p);
  rf_printf(1, "Returning ENOTBLK\n");<= BR>  return (ENOTBLK);
 }
 VOP_UNLOCK(vp, 0, p)= ;
 NDFREE(&nd, NDF_ONLY_PNBUF);
 *vpp =3D vp;
&nbs= p;return (0);
}
Based on the explain of the thread: struct = proc *td_proc; /* Associated process. */ in the struct thread.<= BR>and refer to the CCD code.
I modify this function as following:
= int raidlookup(path, td, vpp)
 char   *path;
 s= truct thread *td;
 struct vnode **vpp; /* result */
{
=  struct nameidata nd;
 struct vnode *vp;
 struct vat= tr va;
 struct proc *p;
 int     erro= r, flags;
 /* Sanity check the p_fd fields.  This is= really just a hack */
 p =3D td->td_proc;
 if (!p->= ;p_fd->fd_rdir || !p->p_fd->fd_cdir)
  printf("Warn= ing: p_fd fields not set\n");
 
 if (!p->p_fd->fd_r= dir)
  p->p_fd->fd_rdir =3D rootvnode;
 if (!p= ->p_fd->fd_cdir)
  p->p_fd->fd_cdir =3D rootvnod= e;
 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
&= nbsp;flags =3D FREAD | FWRITE;
 if ((error =3D vn_open(&nd, &= amp;flags, 0)) !=3D 0) {
  rf_printf(2, "RAIDframe: vn_open = returned %d\n", error);
  return (error);
 }
&nbs= p;vp =3D nd.ni_vp;
 if (vp->v_usecount > 1) {
 &nbs= p;VOP_UNLOCK(vp, 0, td);
  (void) vn_close(vp, FREAD | FWRIT= E, td->td_ucred, td);
  rf_printf(1, "raidlookup() vp->= ;v_usecount > 1\n");
  return (EBUSY);
 }
&nbs= p;if ((error =3D VOP_GETATTR(vp, &va, td->td_ucred, td)) !=3D 0) {=
  VOP_UNLOCK(vp, 0, td);
  (void) vn_close(vp,= FREAD | FWRITE, td->td_ucred, td);
  rf_printf(1, "raidl= ookup() VOP_GETATTR returned %d", error);
  return (error);<= BR> }
 /* XXX: eventually we should handle VREG, too. */
=  if (va.va_type !=3D VCHR) {
  VOP_UNLOCK(vp, 0, td);  (void) vn_close(vp, FREAD | FWRITE,td->td_ucred, td);  rf_printf(1, "Returning ENOTBLK\n");
  return (= ENOTBLK);
 }
 VOP_UNLOCK(vp, 0, td);
 NDFREE(&= ;nd, NDF_ONLY_PNBUF);
 *vpp =3D vp;
 return (0);
}
Now the system will be crash , when it excutes the "p =3D td->= td_proc".
the system Information is :
kernel: type 12 trap, code=3D= 0
Stopped at raidlookup+0x19: movl 0(%eax),%ebx
If I mask t= he instructions form "p =3D td->td_proc" to "p->p_fd->fd_cdir =3D= rootvnode;",
trace the code, I find it will be crash in vn_open.
s= ystem infor:
Stopped at vn_open+0x9: pushl 0x78(%eax)
Why?
I ana= lyse the ccd code, it transfered the vn_open function, only change the se= cond parameter.
 
Best Regards
&nbs= p; Ouyang kai


=B4=D3=CD=F8=D5=BE=B5= =C3=B5=BD=B8=FC=B6=E0=D0=C5=CF=A2=A1=A3MSN Explorer =C3=E2=B7=D1=CF=C2=D4= =D8=A3=BAhttp://explorer.msn.com= /lccn

------=_NextPart_002_0004_01C20A4F.BD05C000-- ------=_NextPart_001_0003_01C20A4F.BD05C000 Content-Type: text/plain; name="help.txt" Content-Disposition: attachment; filename="help.txt" Content-Transfer-Encoding: quoted-printable Hi, Very thank your help! Now the box can boot. =20 I have some other problems about proc and thread. From the FreeBSD5.0 viewpoint, there are real thread in kernel, there are= associated with KSE. So many functions parameters change from proc to thread. There is the function in RAIDFrame in FreeBSD4.x. =20 int raidlookup(path, p, vpp) char *path; struct proc *p; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); =20 if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir =3D rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir =3D rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p); flags =3D FREAD | FWRITE; if ((error =3D vn_open(&nd, flags, 0)) !=3D 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp =3D nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error =3D VOP_GETATTR(vp, &va, p->p_ucred, p)) !=3D 0) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type !=3D VCHR) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, p); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp =3D vp; return (0); } Based on the explain of the thread: struct proc *td_proc; /* Associated p= rocess. */ in the struct thread. and refer to the CCD code. I modify this function as following: int raidlookup(path, td, vpp) char *path; struct thread *td; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; struct proc *p; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ p =3D td->td_proc; if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); =20 if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir =3D rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir =3D rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td); flags =3D FREAD | FWRITE; if ((error =3D vn_open(&nd, &flags, 0)) !=3D 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp =3D nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error =3D VOP_GETATTR(vp, &va, td->td_ucred, td)) !=3D 0) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type !=3D VCHR) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE,td->td_ucred, td); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp =3D vp; return (0); } Now the system will be crash , when it excutes the "p =3D td->td_proc". the system Information is : kernel: type 12 trap, code=3D0 Stopped at raidlookup+0x19: movl 0(%eax),%ebx If I mask the instructions form "p =3D td->td_proc" to "p->p_fd->fd_cdir = =3D rootvnode;", trace the code, I find it will be crash in vn_open. system infor: Stopped at vn_open+0x9: pushl 0x78(%eax) Why? I analyse the ccd code, it transfered the vn_open function, only change t= he second parameter. Best Regards Ouyang kai ------=_NextPart_001_0003_01C20A4F.BD05C000-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message