From: Matthew Wilcox <willy@infradead.org> To: Christoph Hellwig <hch@infradead.org> Cc: Andreas Gruenbacher <agruenba@redhat.com>, "Darrick J. Wong" <djwong@kernel.org>, LKML <linux-kernel@vger.kernel.org>, Joseph Qi <joseph.qi@linux.alibaba.com>, Liu Bo <bo.liu@linux.alibaba.com>, linux-fsdevel@vger.kernel.org, Gao Xiang <hsiangkao@linux.alibaba.com>, Liu Jiang <gerry@linux.alibaba.com>, linux-erofs@lists.ozlabs.org Subject: Re: [PATCH 1/2] iomap: support tail packing inline read Date: Fri, 16 Jul 2021 14:47:35 +0100 [thread overview] Message-ID: <YPGN97vWokqkWSZn@casper.infradead.org> (raw) In-Reply-To: <YPFPDS5ktWJEUKTo@infradead.org> On Fri, Jul 16, 2021 at 10:19:09AM +0100, Christoph Hellwig wrote: > static void > iomap_read_inline_data(struct inode *inode, struct page *page, > - struct iomap *iomap) > + struct iomap *iomap, loff_t pos, unsigned int size) > { > - size_t size = i_size_read(inode); > + unsigned int block_aligned_size = round_up(size, i_blocksize(inode)); > + unsigned int poff = offset_in_page(pos); > void *addr; > > - if (PageUptodate(page)) > - return; > - > - BUG_ON(page_has_private(page)); > - BUG_ON(page->index); > + /* make sure that inline_data doesn't cross page boundary */ > BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data)); > + BUG_ON(size != i_size_read(inode) - pos); > > 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, block_aligned_size - size); > kunmap_atomic(addr); > - SetPageUptodate(page); > + > + iomap_set_range_uptodate(page, poff, block_aligned_size); > } This should be relatively straightforward to port to folios. 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); } > - if (iomap->type == IOMAP_INLINE) { > - WARN_ON_ONCE(pos); > - iomap_read_inline_data(inode, page, iomap); > - return PAGE_SIZE; > - } > + if (iomap->type == IOMAP_INLINE && !pos) > + WARN_ON_ONCE(to_iomap_page(page) != NULL); > + else > + iop = iomap_page_create(inode, page); This WARN_ON doesn't make sense to me. If a file contains bytes 0-2047 that are !INLINE and then bytes 2048-2050 that are INLINE, we're going to trigger it. Perhaps just make this: if (iomap->type != IOMAP_INLINE || pos) iop = iomap_page_create(inode, page);
next prev parent reply other threads:[~2021-07-16 13:48 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-16 5:07 [PATCH 0/2] erofs: iomap support for tailpacking cases Gao Xiang 2021-07-16 5:07 ` [PATCH 1/2] iomap: support tail packing inline read Gao Xiang 2021-07-16 9:19 ` Christoph Hellwig 2021-07-16 9:46 ` Gao Xiang 2021-07-16 13:47 ` Matthew Wilcox [this message] 2021-07-16 14:38 ` Matthew Wilcox 2021-07-16 13:02 ` Matthew Wilcox 2021-07-16 13:56 ` Gao Xiang 2021-07-16 14:44 ` Matthew Wilcox 2021-07-16 15:03 ` Gao Xiang 2021-07-16 15:53 ` Andreas Grünbacher 2021-07-17 13:38 ` Gao Xiang 2021-07-17 15:01 ` Matthew Wilcox 2021-07-17 15:15 ` Gao Xiang 2021-07-17 18:40 ` Matthew Wilcox 2021-07-19 11:19 ` Christoph Hellwig 2021-07-19 13:45 ` Gao Xiang 2021-07-19 11:15 ` Christoph Hellwig 2021-07-19 13:31 ` Gao Xiang 2021-07-16 5:07 ` [PATCH 2/2] erofs: convert all uncompressed cases to iomap Gao Xiang
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=YPGN97vWokqkWSZn@casper.infradead.org \ --to=willy@infradead.org \ --cc=agruenba@redhat.com \ --cc=bo.liu@linux.alibaba.com \ --cc=djwong@kernel.org \ --cc=gerry@linux.alibaba.com \ --cc=hch@infradead.org \ --cc=hsiangkao@linux.alibaba.com \ --cc=joseph.qi@linux.alibaba.com \ --cc=linux-erofs@lists.ozlabs.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --subject='Re: [PATCH 1/2] iomap: support tail packing inline read' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).