Bug 223838 - g_bio_clone vs g_bio_duplicate
Summary: g_bio_clone vs g_bio_duplicate
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-geom (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-24 09:17 UTC by Andriy Gapon
Modified: 2017-11-24 16:34 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Gapon freebsd_committer freebsd_triage 2017-11-24 09:17:20 UTC
g_duplicate_bio() was introduced in base r159304:
> Add g_duplicate_bio() function which does the same thing what g_clone_bio()
> is doing, but g_duplicate_bio() allocates new bio with M_WAITOK flag.
Originally it was almost a complete duplicate (or a clone) of g_bio_clone except for the M_NOWAIT vs M_MWAITOK difference.

But over the time some additional differences have accumulated.  Among them handling of bio_flags and geom schedulers.
It is very hard to tell which differences are intentional and which are not.

It would be nice to identify and remove the unintentional differences.
Also, it would be nice to move the common code into a helper function to avoid the code duplication and the resulting unintentional divergence.

Finally, perhaps g_duplicate_bio() needs a better name while it is not very widely used.  "Duplicate" and "clone" are synonyms, so it's hard telling them apart. 
Some ideas: g_bio_reliable_clone, g_bio_clone_waitok.