On Mon, Jul 26, 2021 at 03:03:14PM +0200, Andreas Gruenbacher wrote: > On Mon, Jul 26, 2021 at 2:33 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > On Mon, Jul 26, 2021 at 01:06:11PM +0200, Andreas Gruenbacher wrote: > > > @@ -671,11 +683,11 @@ static size_t iomap_write_end_inline(struct inode *inode, struct page *page, > > > void *addr; > > > > > > WARN_ON_ONCE(!PageUptodate(page)); > > > - BUG_ON(pos + copied > PAGE_SIZE - offset_in_page(iomap->inline_data)); > > > + BUG_ON(!iomap_inline_data_size_valid(iomap)); > > > > > > flush_dcache_page(page); > > > addr = kmap_atomic(page); > > > - memcpy(iomap->inline_data + pos, addr + pos, copied); > > > + memcpy(iomap_inline_data(iomap, pos), addr + pos, copied); > > > kunmap_atomic(addr); > > > > > > mark_inode_dirty(inode); > > > > Only tangentially related ... why do we memcpy the data into the tail > > at write_end() time instead of at writepage() time? I see there's a > > workaround for that in gfs2's page_mkwrite(): > > > > if (gfs2_is_stuffed(ip)) { > > err = gfs2_unstuff_dinode(ip); > > > > (an mmap store cannot change the size of the file, so this would be > > unnecessary) > > Not sure if an additional __set_page_dirty_nobuffers is needed in that > case, but doing the writeback at writepage time should work just as > well. It's just that gfs2 did it at write time historically. The > un-inlining in gfs2_page_mkwrite() could probably also be removed. > > I can give this a try, but I'll unfortunately be AFK for the next > couple of days. I tend to leave it as another new story and can be resolved with another patch to improve it (or I will stuck in this, I need to do my own development stuff instead of spinning with this iomap patch since I can see this already work well for gfs2 and erofs), I will update the patch Andreas posted with Christoph's comments. Thanks, Gao Xiang