Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jun 2002 10:40:17 +0800
From:      "kai ouyang" <oykai@msn.com>
To:        "John Baldwin" <jhb@FreeBSD.org>, <current@FreeBSD.org>
Subject:   Please help: why bufwait() will cause the thread status change to SSLEEP?
Message-ID:  <OE41l4maEqxGGmNN79x00013818@hotmail.com>

next in thread | raw e-mail | index | archive | help

------=_NextPart_001_0000_01C20C7D.61FF45C0
Content-Type: multipart/alternative; boundary="----=_NextPart_002_0001_01C20C7D.61FF45C0"


------=_NextPart_002_0001_01C20C7D.61FF45C0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: quoted-printable

Dear John and everyone,

I do not know the thread group means what in FreeBSD5.0.
Could you give me some information?
Now, I mask the code about thread group operations.
When I want to get the RAIDFrame information(exist in the disk block).
I can call raidread_component_label(), as the following:
int raidread_component_label(dev, b_vp, clabel)
 udev_t dev;
 struct vnode *b_vp;
 RF_ComponentLabel_t *clabel;
{
 =20
 struct buf *bp;
 int error;
 =20
 /* XXX should probably ensure that we don't try to do this if
    someone has changed rf_protected_sectors. */ =20
 if (b_vp =3D=3D NULL) {
  /* For whatever reason, this component is not valid.
     Don't try to read a component label from it. */
  return(EINVAL);
 }
 /* get a block of the appropriate size... */
 bp =3D geteblk((int)RF_COMPONENT_INFO_SIZE);
 bp->b_dev =3D udev2dev(dev, 0);
 /* get our ducks in a row for the read */
 bp->b_blkno =3D RF_COMPONENT_INFO_OFFSET / DEV_BSIZE;
 bp->b_bcount =3D RF_COMPONENT_INFO_SIZE;
 /*oyk add here to support FreeBSD5.0*/
 bp->b_flags |=3D BIO_READ;
  bp->b_resid =3D RF_COMPONENT_INFO_SIZE / DEV_BSIZE;
 DEV_STRATEGY(bp, 0);
 error =3D bufwait(bp);
        bp->b_flags |=3D B_INVAL | B_AGE;
        bp->b_ioflags &=3D ~BIO_ERROR;
       if (!error) {
  memcpy(clabel, bp->b_data,
         sizeof(RF_ComponentLabel_t));
        }
 brelse(bp); =20
 return(error);
}
Now, when I excute the 'error =3D bufwait(bp);', the system will be crash=
. the error information
is also thread status SSLEEP.
I do know what will cause the thread status change to SSLEEP.
The function in FreeBSD4.x as following:
int raidread_component_label(dev, b_vp, clabel)
 udev_t dev;
 struct vnode *b_vp;
 RF_ComponentLabel_t *clabel;
{
 struct buf *bp;
 int error;
 =20
 /* XXX should probably ensure that we don't try to do this if
    someone has changed rf_protected_sectors. */ =20
 if (b_vp =3D=3D NULL) {
  /* For whatever reason, this component is not valid.
     Don't try to read a component label from it. */
  return(EINVAL);
 }
 /* get a block of the appropriate size... */
 bp =3D geteblk((int)RF_COMPONENT_INFO_SIZE);
 bp->b_dev =3D udev2dev(dev, 0);
 /* get our ducks in a row for the read */
 bp->b_blkno =3D RF_COMPONENT_INFO_OFFSET / DEV_BSIZE;
 bp->b_bcount =3D RF_COMPONENT_INFO_SIZE;
 bp->b_flags |=3D B_READ;
  bp->b_resid =3D RF_COMPONENT_INFO_SIZE / DEV_BSIZE;
 BUF_STRATEGY(bp, 0);
 error =3D biowait(bp); =20
 if (!error) {
  memcpy(clabel, bp->b_data,
         sizeof(RF_ComponentLabel_t));
        }
 brelse(bp); =20
 return(error);
}
 I transfer it to FreeBSD5.0 according vinum example.

Best Regards
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:http://explorer.msn.com/lccn

------=_NextPart_002_0001_01C20C7D.61FF45C0
Content-Type: text/html; charset="gb2312"
Content-Transfer-Encoding: quoted-printable

<HTML><BODY STYLE=3D"font:10pt verdana; border:none;"><DIV>Dear John and =
everyone,</DIV> <DIV>&nbsp;</DIV> <DIV>I do not know the thread group mea=
ns what in FreeBSD5.0.<BR>Could you give me some information?<BR>Now, I m=
ask the code about thread group operations.<BR>When I want to get the RAI=
DFrame information(exist in the disk block).<BR>I can call raidread_compo=
nent_label(), as the following:<BR>int raidread_component_label(dev, b_vp=
, clabel)<BR>&nbsp;udev_t dev;<BR>&nbsp;struct vnode *b_vp;<BR>&nbsp;RF_C=
omponentLabel_t *clabel;<BR>{<BR>&nbsp;<BR>&nbsp;struct buf *bp;<BR>&nbsp=
;int error;<BR>&nbsp;<BR>&nbsp;/* XXX should probably ensure that we don'=
t try to do this if<BR>&nbsp;&nbsp;&nbsp; someone has changed rf_protecte=
d_sectors. */ <BR>&nbsp;if (b_vp =3D=3D NULL) {<BR>&nbsp;&nbsp;/* For wha=
tever reason, this component is not valid.<BR>&nbsp;&nbsp;&nbsp;&nbsp; Do=
n't try to read a component label from it. */<BR>&nbsp;&nbsp;return(EINVA=
L);<BR>&nbsp;}</DIV> <DIV>&nbsp;/* get a block of the appropriate size...=
 */<BR>&nbsp;bp =3D geteblk((int)RF_COMPONENT_INFO_SIZE);<BR>&nbsp;bp-&gt=
;b_dev =3D udev2dev(dev, 0);</DIV> <DIV>&nbsp;/* get our ducks in a row f=
or the read */<BR>&nbsp;bp-&gt;b_blkno =3D RF_COMPONENT_INFO_OFFSET / DEV=
_BSIZE;<BR>&nbsp;bp-&gt;b_bcount =3D RF_COMPONENT_INFO_SIZE;<BR>&nbsp;/*o=
yk add here to support FreeBSD5.0*/<BR>&nbsp;bp-&gt;b_flags |=3D BIO_READ=
;<BR>&nbsp;&nbsp;bp-&gt;b_resid =3D RF_COMPONENT_INFO_SIZE / DEV_BSIZE;<B=
R>&nbsp;DEV_STRATEGY(bp, 0);<BR>&nbsp;error =3D bufwait(bp);<BR>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bp-&gt;b_flags |=3D B_INVAL | B_AGE;<BR=
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bp-&gt;b_ioflags &amp;=3D ~BI=
O_ERROR;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;if (!error) {<BR>&nbsp;&=
nbsp;memcpy(clabel, bp-&gt;b_data,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; sizeof(RF_ComponentLabel_t));</DIV> <DIV>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;brelse(bp); <BR>&nbsp;return(error);<=
BR>}</DIV> <DIV>Now, when I excute the 'error =3D bufwait(bp);', the syst=
em will be crash. the error information<BR>is also thread status SSLEEP.<=
BR>I do know what will cause the thread status change to SSLEEP.<BR>The f=
unction in FreeBSD4.x as following:<BR>int raidread_component_label(dev, =
b_vp, clabel)<BR>&nbsp;udev_t dev;<BR>&nbsp;struct vnode *b_vp;<BR>&nbsp;=
RF_ComponentLabel_t *clabel;<BR>{<BR>&nbsp;struct buf *bp;<BR>&nbsp;int e=
rror;<BR>&nbsp;<BR>&nbsp;/* XXX should probably ensure that we don't try =
to do this if<BR>&nbsp;&nbsp;&nbsp; someone has changed rf_protected_sect=
ors. */ </DIV> <DIV>&nbsp;if (b_vp =3D=3D NULL) {<BR>&nbsp;&nbsp;/* For w=
hatever reason, this component is not valid.<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
Don't try to read a component label from it. */<BR>&nbsp;&nbsp;return(EIN=
VAL);<BR>&nbsp;}</DIV> <DIV>&nbsp;/* get a block of the appropriate size.=
.. */<BR>&nbsp;bp =3D geteblk((int)RF_COMPONENT_INFO_SIZE);<BR>&nbsp;bp-&=
gt;b_dev =3D udev2dev(dev, 0);</DIV> <DIV>&nbsp;/* get our ducks in a row=
 for the read */<BR>&nbsp;bp-&gt;b_blkno =3D RF_COMPONENT_INFO_OFFSET / D=
EV_BSIZE;<BR>&nbsp;bp-&gt;b_bcount =3D RF_COMPONENT_INFO_SIZE;<BR>&nbsp;b=
p-&gt;b_flags |=3D B_READ;<BR>&nbsp;&nbsp;bp-&gt;b_resid =3D RF_COMPONENT=
_INFO_SIZE / DEV_BSIZE;</DIV> <DIV>&nbsp;BUF_STRATEGY(bp, 0);</DIV> <DIV>=
&nbsp;error =3D biowait(bp); </DIV> <DIV>&nbsp;if (!error) {<BR>&nbsp;&nb=
sp;memcpy(clabel, bp-&gt;b_data,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp; sizeof(RF_ComponentLabel_t));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; }<BR>&nbsp;brelse(bp); <BR>&nbsp;return(error);<BR>}<BR>&n=
bsp;I transfer it to FreeBSD5.0 according vinum example.<BR><BR>Best Rega=
rds<BR>Ouyang Kai</DIV></BODY></HTML><br clear=3Dall><hr>=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=BA<a href=3D'http://explorer.msn.com/lccn'>http://explorer.msn.=
com/lccn</a><br></p>

------=_NextPart_002_0001_01C20C7D.61FF45C0--


------=_NextPart_001_0000_01C20C7D.61FF45C0
Content-Type: text/plain; name="bufwait.txt"
Content-Disposition: attachment; filename="bufwait.txt"
Content-Transfer-Encoding: quoted-printable

I do not know the thread group means what in FreeBSD5.0.
Could you give me some information?
Now, I mask the code about thread group operations.
When I want to get the RAIDFrame information(exist in the disk block).
I can call raidread_component_label(), as the following:
int raidread_component_label(dev, b_vp, clabel)
	udev_t dev;
	struct vnode *b_vp;
	RF_ComponentLabel_t *clabel;
{
	=09
	struct buf *bp;
	int error;
	=09
	/* XXX should probably ensure that we don't try to do this if
	   someone has changed rf_protected_sectors. */ =20
	if (b_vp =3D=3D NULL) {
		/* For whatever reason, this component is not valid.
		   Don't try to read a component label from it. */
		return(EINVAL);
	}

	/* get a block of the appropriate size... */
	bp =3D geteblk((int)RF_COMPONENT_INFO_SIZE);
	bp->b_dev =3D udev2dev(dev, 0);

	/* get our ducks in a row for the read */
	bp->b_blkno =3D RF_COMPONENT_INFO_OFFSET / DEV_BSIZE;
	bp->b_bcount =3D RF_COMPONENT_INFO_SIZE;
	/*oyk add here to support FreeBSD5.0*/
	bp->b_flags |=3D BIO_READ;
 	bp->b_resid =3D RF_COMPONENT_INFO_SIZE / DEV_BSIZE;
	DEV_STRATEGY(bp, 0);
	error =3D bufwait(bp);
        bp->b_flags |=3D B_INVAL | B_AGE;
        bp->b_ioflags &=3D ~BIO_ERROR;
      	if (!error) {
		memcpy(clabel, bp->b_data,
		       sizeof(RF_ComponentLabel_t));

        }
	brelse(bp); =20
	return(error);
}

Now, when I excute the 'error =3D bufwait(bp);', the system will be crash=
. the error information
is also thread status SSLEEP.
I do know what will cause the thread status change to SSLEEP.
The function in FreeBSD4.x as following:
int raidread_component_label(dev, b_vp, clabel)
	udev_t dev;
	struct vnode *b_vp;
	RF_ComponentLabel_t *clabel;
{
	struct buf *bp;
	int error;
	=09
	/* XXX should probably ensure that we don't try to do this if
	   someone has changed rf_protected_sectors. */ =20

	if (b_vp =3D=3D NULL) {
		/* For whatever reason, this component is not valid.
		   Don't try to read a component label from it. */
		return(EINVAL);
	}

	/* get a block of the appropriate size... */
	bp =3D geteblk((int)RF_COMPONENT_INFO_SIZE);
	bp->b_dev =3D udev2dev(dev, 0);

	/* get our ducks in a row for the read */
	bp->b_blkno =3D RF_COMPONENT_INFO_OFFSET / DEV_BSIZE;
	bp->b_bcount =3D RF_COMPONENT_INFO_SIZE;
	bp->b_flags |=3D B_READ;
 	bp->b_resid =3D RF_COMPONENT_INFO_SIZE / DEV_BSIZE;

	BUF_STRATEGY(bp, 0);

	error =3D biowait(bp); =20

	if (!error) {
		memcpy(clabel, bp->b_data,
		       sizeof(RF_ComponentLabel_t));
        }
	brelse(bp); =20
	return(error);
}
 I transfer it to FreeBSD5.0 according vinum example.

------=_NextPart_001_0000_01C20C7D.61FF45C0--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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