Re: [PATCH 1/2] iomap: support tail packing inline read

From: Gao Xiang
Date: Mon Jul 19 2021 - 09:31:24 EST


On Mon, Jul 19, 2021 at 12:15:47PM +0100, Christoph Hellwig wrote:
> On Sat, Jul 17, 2021 at 09:38:18PM +0800, Gao Xiang wrote:
> > >From 62f367245492e389711bcebbf7da5adae586299f Mon Sep 17 00:00:00 2001
> > From: Christoph Hellwig <hch@xxxxxx>
> > Date: Fri, 16 Jul 2021 10:52:48 +0200
> > Subject: [PATCH] iomap: support tail packing inline read
>
> I'd still credit this to you as you did all the hard work.

Ok.

>
> > + /* inline source data must be inside a single page */
> > + BUG_ON(iomap->length > PAGE_SIZE - offset_in_page(iomap->inline_data));
> > + /* handle tail-packing blocks cross the current page into the next */
> > + if (size > PAGE_SIZE - poff)
> > + size = PAGE_SIZE - poff;
>
> This should probably use min or min_t.

Okay, will update.

>
> >
> > addr = kmap_atomic(page);
> > - memcpy(addr, iomap->inline_data, size);
> > - memset(addr + size, 0, PAGE_SIZE - size);
> > + memcpy(addr + poff, iomap->inline_data - iomap->offset + pos, size);
> > + memset(addr + poff + size, 0, PAGE_SIZE - poff - size);
> > kunmap_atomic(addr);
> > - SetPageUptodate(page);
> > + flush_dcache_page(page);
>
> The flush_dcache_page addition should be a separate patch.

I wondered what is the target order of recent iomap patches, since this is
a quite small change, so I'd like to just rebase on for-next for now . So
ok, I won't touch this in this patchset and I think flush_dcache_page() does
no harm to x86(_64) and arm(64) at least if I remember correctly.

>
> >
> > if (dio->flags & IOMAP_DIO_WRITE) {
> > loff_t size = inode->i_size;
> > @@ -394,7 +395,8 @@ iomap_dio_inline_actor(struct inode *inode, loff_t pos, loff_t length,
> > mark_inode_dirty(inode);
> > }
> > } else {
> > - copied = copy_to_iter(iomap->inline_data + pos, length, iter);
> > + copied = copy_to_iter(iomap->inline_data + pos - iomap->offset,
> > + length, iter);
>
> We also need to take the offset into account for the write side.
> I guess it would be nice to have a local variable for the inline
> address to not duplicate that calculation multiple times.

ok. Will update.

Thanks,
Gao Xiang