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

From: Matthew Wilcox
Date: Fri Jul 16 2021 - 10:40:12 EST


On Fri, Jul 16, 2021 at 02:47:35PM +0100, Matthew Wilcox wrote:
> I think it looks something like this ...
>
> @@ -211,23 +211,18 @@ struct iomap_readpage_ctx {
> };
>
> static void iomap_read_inline_data(struct inode *inode, struct folio *folio,
> - struct iomap *iomap)
> + struct iomap *iomap, loff_t pos, size_t size)
> {
> - size_t size = i_size_read(inode);
> void *addr;
> + size_t offset = offset_in_folio(folio, pos);
>
> - if (folio_test_uptodate(folio))
> - return;
> + BUG_ON(size != i_size_read(inode) - pos);
>
> - BUG_ON(folio->index);
> - BUG_ON(folio_multi(folio));
> - BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data));
> -
> - addr = kmap_local_folio(folio, 0);
> + addr = kmap_local_folio(folio, offset);
> memcpy(addr, iomap->inline_data, size);
> memset(addr + size, 0, PAGE_SIZE - size);
> kunmap_local(addr);
> - folio_mark_uptodate(folio);
> + iomap_set_range_uptodate(folio, to_iomap_page(folio), pos, size);

That should be s/size/PAGE_SIZE - offset/
(because this has just zeroed all the bytes in the page after end-of-file)