On Thu, 21 Mar 2019 at 22:43, Dave Chinner <david@xxxxxxxxxxxxx> wrote: > The problem is calling balance_dirty_pages() inside the > ->iomap_begin/->iomap_end calls and not that it is called by the > iomap infrastructure itself, right? > > Is so, I'd prefer to see this in iomap_apply() after the call to > ops->iomap_end because iomap_file_buffered_write() can iterate and > call iomap_apply() multiple times. This would keep the balancing to > a per-iomap granularity, rather than a per-syscall granularity. > > i.e. if we do write(2GB), we want more than one balancing call > during that syscall, so it would be up to the filesystem to a) limit > the size of write mappings to something smaller (e.g. 1024 pages) > so that there are still frequent balancing calls for large writes. Hmm. The looping across multiple mappings isn't done in iomap_apply but in iomap_file_buffered_write, so the balancing could go into iomap_apply or iomap_file_buffered_write, but can't go further up the stack. Given that, iomap_file_buffered_write seems the better place, but this is still quite horrible. Thanks, Andreas