Regarding bi_end_io functions

Gaurav Mahajan gauravmahajan2007 at gmail.com
Fri Jan 21 03:14:14 EST 2011


Hello all,

I was writing a device mapper target.

Now in that target for each bio request I set the bi_end_io field to
my endio function "my_end_io".
So that whenever the bio request gets complete it will call the
"my_end_io" function.

While registering the device mapper target we provide a structure
called "target_type" to the device mapper.
This structure is like this.
static struct target_type my_dm_target = {
	.name   = "my_dmt",
	.version = {1, 0, 0},
	.module = THIS_MODULE,
	.ctr    = dmt_ctr,
	.dtr	= dmt_dtr,
	.map    = dmt_map,
	.end_io = dmt_endio,
};
It contains many other fields(Mainly function pointers).

Now if you have observed the end_io field in the target_type, this is function.

I was not able to figure out why there is another end_io filed is
given if we can set the bi_end_io field in each bio(my_end_io).

I was also not getting what's the purpose of the end_io function given
in the target_type. And when this function gets called.


Earlier I did not define end_io function (from target_type ) but
because of that OOPS was generated. Later I dug the logs, I found that
clone_endio function in dm.c is trying to access the end_io field from
the target_type structure. But since function was not defined the
end_io field was NULL. So it gives OOPS NULL pointer reference at that
point.

Looking forward for some help.....


Regards,
Gaurav



More information about the Kernelnewbies mailing list