Bug 266158 - bio_length and bio_bcount in the GEOM bio structure are documented to be the same, but they are not
Summary: bio_length and bio_bcount in the GEOM bio structure are documented to be the ...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-01 14:09 UTC by Mateusz Piotrowski
Modified: 2022-09-01 14:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Piotrowski freebsd_committer freebsd_triage 2022-09-01 14:09:05 UTC
In the source code (sys/sys/bio.h), bio_bcount is documented as "Valid bytes in buffer". bio_length is documented as "Like bio_bcount". Unfortunately, they are not the same. Here's a sh(1) script to show that:

    # Create a memory device.
    md=$(mdconfig -s 1G)
    # Trace the io subsystem when the dd command is executing. Limit the results to
    # the PID of the dd command only.
    dtrace -n '
            io:::start /pid == $target/ {
                    @bcount[execname] = quantize(args[0]->bio_bcount);
                    @length[execname] = quantize(args[0]->bio_length);
            }
    ' -c "dd if=/dev/random of=/dev/$md bs=1m count=230 oflag=sync"
    # Remove the memory device.
    mdconfig -d -u "$md"