When free bio #15173
-
In this funtion,bio is not free.
}` This is printed.I don't understand, when is bio released. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
All you're testing is that the pointer isn't NULL, which says nothing about what, if anything, its pointing to. As it is, the bio is handed to the kernel ( When the IO operation is complete, the kernel calls |
Beta Was this translation helpful? Give feedback.
All you're testing is that the pointer isn't NULL, which says nothing about what, if anything, its pointing to.
As it is, the bio is handed to the kernel (
vdev_submit_bio_impl
->submit_bio
), which then takes ownership of it.When the IO operation is complete, the kernel calls
vdev_disk_io_flush_completion
with the completed bio. This usually the bio that was passed in, but not necessarily - the kernel may modify it, split it or whatever it wants. Regardless,bio_put(bio)
returns the bio to the kernel when we're done with it, and it will free it or reuse it as it likes.