On Fri, May 27, 2022 at 10:59:03PM -0700, Christoph Hellwig wrote: > On Fri, May 27, 2022 at 04:50:26PM +0100, Matthew Wilcox (Oracle) wrote: > > read_mapping_folio() returns an ERR_PTR if the folio is not > > uptodate, so this check is simply dead code. > > Looks good: > > Reviewed-by: Christoph Hellwig <hch@xxxxxx> > > > /* Read a page's worth of file data into the page cache. */ > > static struct folio *vfs_dedupe_get_folio(struct file *file, loff_t pos) > > { > > + return read_mapping_folio(file->f_mapping, pos >> PAGE_SHIFT, file); > > } > > But I wonder if this isn't useful enough to go to filemap.c in one form > or another. It looks like it should be, but most in-kernel users of read_mapping_folio() and its friends want to pass NULL for file as they don't have an open file. Indeed, this code used to until I realised we actually do have open files here, so should pass them. I don't think it affects anything; the only users who need the struct file are network filesystems, and nobody does dedupe across the network. If it's not done transparently by the server, it's an obvious server offload operation.