Menu

#10 FreeBSD: Add workaround for 4096-aligned drives

Unstable (example)
open
nobody
None
5
2026-05-17
2026-04-14
No

On 4096-aligned drives DIOCGSTRIPEOFFSET ioctl used for determining of partition offset always returns 0. Probably due to a bug. Fallback to value provided by GEOM in that case. It looks correct.

1 Attachments

Discussion

  • Henrik Carlqvist

    Thanks for the patch!

    The declaration of the new function diocgstripeoffset and the call to that function is only made if DIOCGFWSECTORS is defined. However, the function seem to need sysctl and sysctl.h and some more .h files are only included if DIOCGFWSECTORS and (APPLE or FreeBSD) is defined.

    Do you think that the call and declaration also only should be made if APPLE or FreeBSD is defined? Or would you prefer if the includes were done also without APPLE or FreeBSD?

     
  • Vladimir Kondratyev

    The declaration and the call is FreeBSD-specific. Like any DIOC... macro. APPLE's ioctl name PREFIX is DKIO rather than DIOC. They share only header file (sys/disk.h) with completely different content.
    So only FreeBSD is supported by new code that is achieved with DIOCGFWSECTORS #define check.

     
  • Henrik Carlqvist

    Ok, thanks again! I hope to be able to create a new development release some weekend in the future, probably not in April, but hopefully some weekend in May.

     
  • Alexey Dokuchaev

    DIOCGSTRIPEOFFSET ioctl used for determining of partition offset always returns 0

    That's probably because it returns not the partition offset, but the offset of the first device's optimal access block, per man disk(4).

     
  • Vladimir Kondratyev

    Minor patch improvement based on similar ntfs-3g work.

    • Rename diocgstripeoffset()
    • Use proper type for sys_offset
    • malloc(3) -> alloca(3)
    • Join sscanf(3)
     
  • Henrik Carlqvist

    Thanks for the updated patch! I hope to be able to release a development version of ms-sys some weekend in May.

     
  • Vladimir Kondratyev

    Thanks for the updated patch! I hope to be able to release a development version of ms-sys some weekend in May.

    Thanks! I've glanced over the code once again and added some more FreeBSD-related fixes:

    1. Fix is_disk_device() always returning TRUE
    2. Drop DIOCGSTRIPEOFFSET ioctl. It looks to be misused.
    3. Fix 'set but unused' variable compile-time warnings.
     
  • Henrik Carlqvist

     
  • Henrik Carlqvist

    Thanks again for your latest patch! It has now been included in development release 2.9.0. Unless you mind, I will set the status of this to closed-accepted.

     

Log in to post a comment.

MongoDB Logo MongoDB