On Wed, Aug 28, 2019 at 10:05:11PM +1000, Matthew Bobrowski wrote: > > What is not clear to me at this point though is whether it is still > > necessary to explicitly track unwritten extents via in-core inode > > attributes i.e. ->i_unwritten and ->i_state_flags under the new direct > > IO code path implementation, which makes use of the iomap > > infrastructure. Or, whether we can get away with simply not using > > these in-core inode attributes and rely just on checks against the > > extent record directly, as breifly mentioned by Darrick. I would think > > that this type of check would be enough, however the checks around > > whether the inode is currently undergoing direct IO were implemented > > at some point, so there must be a reason for having them > > (a9b8241594add)? The original reason why we created the DIO_STATE_UNWRITTEN flag was a fast path, where the common case is writing blocks to an existing location in a file where the blocks are already allocated, and marked as written. So consulting the on-disk extent tree to determine whether unwritten extents need to be converted and/or split is certainly doable. However, it's expensive for the common case. So having a hint whether we need to schedule a workqueue to possibly convert an unwritten region is helpful. If we can just free the bio and exit the I/O completion handler without having to take shared locks to examine the on-disk extent tree, so much the better. > Maybe it's a silly question, although I'm wanting to clarify my > understanding around why it is that when we either try prepend or > append to an existing extent, we don't permit merging of extents if If I recall correctly, the reason for this check was mainly the concern that we would end up merging an extent that we would then have to split later on (when the direct I/O completed). To be honest, i'm not 100% sure what would happen if we removed that restriction; it might be that things would work just fine (just slower in some workloads), or whether there is some hidden dependency that would explode. I suspect we'd have to try the experiment to be sure. - Ted