On Fri, 5 Nov 2021 at 08:44, Hao Peng <flyingpenghao@xxxxxxxxx> wrote: > > On Thu, Nov 4, 2021 at 8:18 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > > > On Wed, 3 Nov 2021 at 02:15, Peng Hao <flyingpenghao@xxxxxxxxx> wrote: > > > > > > The 'written' that generic_file_direct_write return through > > > filemap_write_and_wait_range is not necessarily sequential, > > > and its iocb->ki_pos has not been updated. > > > > I don't see the bug, but maybe I'm missing something. Can you please > > explain in detail? > > > I think we shouldn't add "written" to variable pos. > generic_file_direct_write: > .... > written = filemap_write_and_wait_range(mapping, pos, > pos + write_len - 1); > if (written) //the number of writes here reflects the > amount of writeback data No. It's actually an error code in this case. It is confusing, though, so I guess cleaning this up (e.g. rename "written" to "retval") would make sense. Thanks, Miklos