Re: [PATCH] netfs: Miscellaneous fixes

Matthew Wilcox
2021-04-26T21:09:59Z

On Mon, Apr 26, 2021 at 10:06:24PM +0100, David Howells wrote:
> @@ -968,7 +968,7 @@ int netfs_readpage(struct file *file,
> return -ENOMEM;
> }
> rreq->mapping = page_file_mapping(page);
> - rreq->start = page_index(page) * PAGE_SIZE;
> + rreq->start = page_offset(page);

This one needs to use page_file_offset() because swap-over-NFS.

> @@ -1105,8 +1105,8 @@ int netfs_write_begin(struct file *file, struct address_space *mapping,
> rreq = netfs_alloc_read_request(ops, netfs_priv, file);
> if (!rreq)
> goto error;
> - rreq->mapping = page->mapping;
> - rreq->start = page->index * PAGE_SIZE;
> + rreq->mapping = page_file_mapping(page);

There's nothing wrong with using page->mapping here. The swap-over-NFS
path doesn't use write_begin, it uses O_DIRECT writes.