On Mon, Oct 12, 2020 at 10:03:49AM -0400, Brian Foster wrote: > iomap seek hole/data currently uses page Uptodate state to track > data over unwritten extents. This is odd and unpredictable in that > the existence of clean pages changes behavior. For example: > > $ xfs_io -fc "falloc 0 32k" -c "seek -d 0" \ > -c "pread 16k 4k" -c "seek -d 0" /mnt/file > Whence Result > DATA EOF > ... > Whence Result > DATA 16384 I don't think there is any way around this, because the page cache lookup done by the seek hole/data code is an unlocked operation and can race with other IO and operations. That is, seek does not take IO serialisation locks at all so read/write/page faults/fallocate/etc all run concurrently with it... i.e. we get an iomap that is current at the time the iomap_begin() call is made, but we don't hold any locks to stabilise that extent range while we do a page cache traversal looking for cached data. That means any region of the unwritten iomap can change state while we are running the page cache seek. We cannot determine what the data contents without major overhead, and if we are seeking over a large unwritten extent covered by clean pages that then gets partially written synchronously by another concurrent write IO then we might trip across clean uptodate pages with real data in them by the time the page cache scan gets to it. Hence the only thing we are looking at here is whether there is data present in the cache or not. As such, I think assuming that only dirty/writeback pages contain actual user data in a seek data/hole operation is a fundametnally incorrect premise. Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx