getting from bio to buf in dastrategy()

Eno Thereska eno at andrew.cmu.edu
Sun Aug 3 16:11:42 PDT 2003


Hi all,

I am hacking into the FreeBSD 5.0 code.
I jumped from using 4.4 to 5.0 and a couple of things
have changed. Here is my question:

in /sys/cam/scsi/scsi_da.c the dastrategy()
function takes as an argument "struct bio* bp"
Now I need to get to the "struct *buf" that bp
belongs to. In /sys/sys/buf.h I see that
struct buf has as the first member "b_io" which is
of type struct bio. I also see the BIOTOBUF
#define which is supposed to take a bio and
return the buf it belongs to.

Now in dastrategy() if I use the BIOTOBUF function
and try to access members of the struct buf
I get junk, which means that the bio passed to the
is not directly related to a buf. Am I missing something
here? How do I know to which buf (if any) the bio belongs
to?

Also it seems to me that the new way of
splitting the old struct buf into a
struct bio and having a bunch of #defines inside
the struct buf is kind of hacky. What was the
rationale behind doing that (rather than
just leaving it the way it was in 4.4)?

Thanks
Eno



More information about the freebsd-hackers mailing list