Repository navigation
Conversation
jorisdral
left a comment
There was a problem hiding this comment.
I think the plan you outline in the PR description is sensible! But something may have gone wrong with your commits, because I'm missing code changes.
P.S.: no need to post screenshots of your console with test output. CI will verify that the tests succeed.
| * Add a portable serial `HasBlockIO` implementation for POSIX systems that do | ||
| not have a dedicated one, so `blockio` builds on more than Linux, MacOS, | ||
| Windows, and FreeBSD. Operations the platform does not support | ||
| (`posix_fallocate`, `O_DIRECT`/`F_NOCACHE`) degrade to no-ops. See [issue | ||
| #872][issue-872] and [PR #NNN][pr-NNN]. | ||
| * Add the `posixblockio` cabal flag, which forces the portable implementation | ||
| on any platform, for testing it. See [PR #NNN][pr-NNN]. |
There was a problem hiding this comment.
Fill in the [PR #NNN][pr-NNN] links
There was a problem hiding this comment.
I don't see the changes yet
59e4238 to
e9b447d
Compare
| * Add a portable serial `HasBlockIO` implementation for POSIX systems that do | ||
| not have a dedicated one, so `blockio` builds on more than Linux, MacOS, | ||
| Windows, and FreeBSD. Operations the platform does not support | ||
| (`posix_fallocate`, `O_DIRECT`/`F_NOCACHE`) degrade to no-ops. See [issue | ||
| #872][issue-872] and [PR #NNN][pr-NNN]. | ||
| * Add the `posixblockio` cabal flag, which forces the portable implementation | ||
| on any platform, for testing it. See [PR #NNN][pr-NNN]. |
There was a problem hiding this comment.
I don't see the changes yet
| * Add a portable serial `HasBlockIO` implementation for POSIX systems that do | ||
| not have a dedicated one, so `blockio` builds on more than Linux, MacOS, | ||
| Windows, and FreeBSD. Operations the platform does not support | ||
| (`posix_fallocate`, `O_DIRECT`/`F_NOCACHE`) degrade to no-ops. See [issue | ||
| #872][issue-872] and [PR #NNN][pr-NNN]. | ||
| * Add the `posixblockio` cabal flag, which forces the portable implementation | ||
| on any platform, for testing it. See [PR #NNN][pr-NNN]. |
There was a problem hiding this comment.
I'm unsure about using the name "POSIX" to describe the fallback implementation. Posix is a standard, not an operating system. I think we should call it something like "unix-like", or maybe even "fallback". Do you have thoughts on this?
| as well. On other POSIX systems a portable serial implementation is used that | ||
| relies only on the parts of the `unix` package available on the platform; it | ||
| can be selected explicitly on any platform with the `posixblockio` cabal flag. | ||
| The simulated implementation also performs each I/O operation sequentially. |
There was a problem hiding this comment.
| as well. On other POSIX systems a portable serial implementation is used that | |
| relies only on the parts of the `unix` package available on the platform; it | |
| can be selected explicitly on any platform with the `posixblockio` cabal flag. | |
| The simulated implementation also performs each I/O operation sequentially. | |
| as well. If the operating system is none of the above, then the system is assumed to be Unix-like, in which case the library uses a fallback implementation that performs I/O operations sequentially. | |
| The simulated implementation also performs each I/O operation sequentially. |
| * Add a portable serial `HasBlockIO` implementation for POSIX systems that do | ||
| not have a dedicated one, so `blockio` builds on more than Linux, MacOS, | ||
| Windows, and FreeBSD. Operations the platform does not support | ||
| (`posix_fallocate`, `O_DIRECT`/`F_NOCACHE`) degrade to no-ops. See [issue | ||
| #872][issue-872] and [PR #NNN][pr-NNN]. |
There was a problem hiding this comment.
This should also emphasize that the OS is now assumed to be Unix-like in case the OS is not one of the explicitly supported OS's (Linux, MacOS, Windows, FreeBSD). This is different from the previous behaviour, where the library would simply be unbuildable on unsupported OS's.
| flag posixblockio | ||
| description: | ||
| Use the portable POSIX HasBlockIO implementation regardless of the | ||
| operating system. Intended for testing that implementation on platforms | ||
| that have a dedicated one. Not supported on Windows. | ||
|
|
||
| default: False | ||
| manual: True |
There was a problem hiding this comment.
| flag posixblockio | |
| description: | |
| Use the portable POSIX HasBlockIO implementation regardless of the | |
| operating system. Intended for testing that implementation on platforms | |
| that have a dedicated one. Not supported on Windows. | |
| default: False | |
| manual: True | |
| flag unixlikeblockio | |
| description: | |
| Use the Unix-like HasBlockIO implementation regardless of the | |
| operating system. Intended for testing that implementation on platforms | |
| that have a dedicated one. No-op on Windows. | |
| default: False | |
| manual: True |
There was a problem hiding this comment.
You probably copied this module from another System.FS.BlockIO.Internal.Fcntl, but it's no longer necessary. This type of module is only necessary to support unix versions <unix-2.8.7, but we support >=unix-2.8.7.
| 'submitIO', just like the MacOS, Windows, FreeBSD, and portable POSIX | ||
| implementations do. |
There was a problem hiding this comment.
| 'submitIO', just like the MacOS, Windows, FreeBSD, and portable POSIX | |
| implementations do. | |
| 'submitIO', just like the MacOS, Windows, FreeBSD, and Unix-like | |
| implementations do. |
| * MacOS: a mocked context using an @MVar@ | ||
| * Windows: a mocked context using an @MVar@ | ||
| * FreeBSD: a mocked context using an @MVar@ | ||
| * Other POSIX systems: a mocked context using an @MVar@ |
There was a problem hiding this comment.
We should update this everywhere:
| * Other POSIX systems: a mocked context using an @MVar@ | |
| * Unix-like systems: a mocked context using an @MVar@ |
There was a problem hiding this comment.
yes I have done updates
| -- | A portable, serial implementation of 'HasBlockIO' for POSIX systems that | ||
| -- do not have a dedicated implementation (Linux, MacOS, and FreeBSD do). It | ||
| -- uses only the parts of the @unix@ package that are available on the | ||
| -- platform, and degrades to no-ops where an operation is not supported. |
There was a problem hiding this comment.
| -- | A portable, serial implementation of 'HasBlockIO' for POSIX systems that | |
| -- do not have a dedicated implementation (Linux, MacOS, and FreeBSD do). It | |
| -- uses only the parts of the @unix@ package that are available on the | |
| -- platform, and degrades to no-ops where an operation is not supported. | |
| -- | A portable, serial implementation of 'HasBlockIO' for Unix-like systems that | |
| -- do not have a dedicated implementation (Linux, MacOS, and FreeBSD do). |
| hSynchronise :: Handle HandleIO -> IO () | ||
| hSynchronise h = FS.withOpenHandle "hSynchronise" (handleRaw h) $ \fd -> | ||
| Unix.fileSynchronise fd |
There was a problem hiding this comment.
Looks to me like fileSynchronise can also throw an error if the system does not HAVE_FSYNC. We should also make it a no-op in that case, like we do with hAllocate. We should also update the docs accordingly.
Linux, MacOS, Windows, and FreeBSD each have a dedicated HasBlockIO implementation, but every other platform couldn't build blockio at all. This adds a serial fallback in src-unix, used when the platform isn't one of those four. It relies only on the parts of the unix package that are actually available, and degrades to no-ops where the platform doesn't support an operation (O_DIRECT/F_NOCACHE, posix_fallocate, fsync). Also adds the unixlikeblockio cabal flag, which forces the fallback on any platform, so CI can build and test it on Linux without needing dedicated runners for the other platforms. Resolves IntersectMBO#872.
e9b447d to
03b89f0
Compare
Description
Resolves #872.
I added a generic portable fallback: serial
HasBlockIOinsrc-unix, which gets picked when the platform isn't Linux, MacOS, Windows or FreeBSD. I also introduced aposixblockiocabal flag that forces this fallback on any platform, allowing CI to build and test it on Linux without needing extra runners.Instead of reusing the macOS backend (as #847 did, which assumes
F_NOCACHE), I chose the dedicated fallback route for Unix. The generic POSIX layer cannot assume thatO_DIRECT,F_NOCACHEorposix_fallocateexist, andunix'sfileAllocateandfileSetCachingthrow where they're missing. Therefore I guarded those features using theHAVE_*macros fromHsUnix.h(the same include used by the FreeBSD backend) so they gracefully degrade to no-ops, similar to how the macOS backend already handleshAllocate. Both modules are.hscrather than.hsbecause GHC'scppcan't processHsUnix.h(it pulls in glibc headers) while hsc2hs can the same reason the FreeBSD backend'sFcntlis.hsc.Finally, I added a
+posixblockioentry to the CI matrix alongside+serialblockio, and updated the platform notes inIO.hs, the README and the changelog.Tested locally: the default Linux build is unchanged,
cabal build blockio --flag=+posixblockiocompiles the fallback, andcabal test blockio:test --flag=+posixblockiopasses all 11 tests against it. One limitation: on Linux all theHAVE_*macros are true, so CI only compiles the "supported" branches; the#elseno-ops are only compiled on a platform that actually lacks the syscalls. Running--flag=+posixblockioon FreeBSD would be a useful second data point.Checklist