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 // in the previous page cache, and iocb->ki_pos do not change and // no data in iocb is written. goto out; ... out: return written; > The patch looks good as a cleanup, but I'd very much like to know > first if it fixes a bug or not. > When the direct read & write and cache read & write of different processes, there is some synchronization in the user mode, but it is still found that there is data out of synchronization. Just analyze that there may be problems here. Thanks. > Thanks, > Miklos