Page MenuHomeFreeBSD

Add FIOBMAP2 ioctl
ClosedPublic

Authored by asomers on Jun 20 2019, 12:34 AM.
Tags
None
Referenced Files
F132470057: D20705.id58835.diff
Fri, Oct 17, 5:01 AM
F132423446: D20705.id.diff
Thu, Oct 16, 7:44 PM
F132423445: D20705.id58819.diff
Thu, Oct 16, 7:44 PM
Unknown Object (File)
Thu, Oct 16, 9:52 AM
Unknown Object (File)
Thu, Sep 25, 7:17 PM
Unknown Object (File)
Aug 30 2025, 4:03 AM
Unknown Object (File)
Aug 30 2025, 2:56 AM
Unknown Object (File)
Aug 29 2025, 9:33 PM
Subscribers

Details

Summary

Add FIOBMAP2 ioctl

This ioctl exposes VOP_BMAP information to userland. It can be used by
programs like fragmentation analyzers and optimized cp implementations. But
I'm using it to test fusefs's VOP_BMAP implementation. The "2" in the name
distinguishes it from the similar but incompatible FIOBMAP ioctls in NetBSD
and Linux.

Test Plan

Tested with a dumb command line utility with files on NFS, UFS, devfs, and
fusefs.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

The name, etc, beg the question: what's the motivation to differ from FIOBMAP in Linux (or NetBSD)?

In D20705#447490, @cem wrote:

The name, etc, beg the question: what's the motivation to differ from FIOBMAP in Linux (or NetBSD)?

  1. FIOBMAP stores the block number in an int instead of an int64_t
  2. FIOBMAP does not return runp and runb.

Ah, I was thinking of FIEMAP I think. So the better question might be, why not add FIEMAP instead? https://www.kernel.org/doc/Documentation/filesystems/fiemap.txt

One answer is that it's a less direct way of testing VOP_BMAP, I guess.

In D20705#447498, @cem wrote:

Ah, I was thinking of FIEMAP I think. So the better question might be, why not add FIEMAP instead? https://www.kernel.org/doc/Documentation/filesystems/fiemap.txt

One answer is that it's a less direct way of testing VOP_BMAP, I guess.

Because FIEMAP is far more complicated. It works in terms of extents instead of blocks, and returns a variable sized array. Plus, it hasn't worked out very well on Linux. It was introduced in response to Solaris's SEEK_HOLE, but was too buggy for the purpose. Linux later had to add SEEK_HOLE too.

Changing ufs_bamparray() to return errors rather than panicing is a helpful move forward.

This revision is now accepted and ready to land.Jun 20 2019, 6:08 AM
This revision was automatically updated to reflect the committed changes.
head/sys/kern/vfs_vnops.c
1474–1475

style(9): the second line should be 4-space indented

1504–1505

ditto here