>> What happens if bytes_remaining < PAGE_SIZE? I think on a call where that occurs, new_len won't get set and readahead_expand won't get called. I don't see how that's not correct, but I question me more than I question you :-) ... >> what happens if bytes_remaining % PAGE_SIZE != 0 I think bytes_remaining % PAGE_SIZE worth of bytes won't get read on that call, but that the readahead callout keeps getting called until all the bytes are read? After you asked this, I thought about adding 1 to new_len in such cases, and did some tests that way, it seems to me like it works out as is. >> I wonder if you should use iov_length(&iter) iov_length has two arguments. The first one would maybe be iter.iov and the second one would be... ? >> should you cache inode->i_size lest it change under you due to truncate That seems important, but I can't return an error from the void readahead callout. Would I react by somehow returning the pages back to their original condition, or ? Anywho... I see that you've force pushed a new netfs... I think you have it applied to a linus-tree-of-the-day on top of 5.12-rc4? I have taken these patches from git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git (netfs-lib) 0001-iov_iter-Add-ITER_XARRAY.patch 0002-mm-Add-set-end-wait-functions-for-PG_private_2.patch 0003-mm-filemap-Pass-the-file_ra_state-in-the-ractl.patch 0004-fs-Document-file_ra_state.patch 0005-mm-readahead-Handle-ractl-nr_pages-being-modified.patch 0006-mm-Implement-readahead_control-pageset-expansion.patch 0007-netfs-Make-a-netfs-helper-module.patch 0008-netfs-Documentation-for-helper-library.patch 0009-netfs-mm-Move-PG_fscache-helper-funcs-to-linux-netfs.patch 0010-netfs-mm-Add-set-end-wait_on_page_fscache-aliases.patch 0011-netfs-Provide-readahead-and-readpage-netfs-helpers.patch 0012-netfs-Add-tracepoints.patch 0013-netfs-Gather-stats.patch 0014-netfs-Add-write_begin-helper.patch 0015-netfs-Define-an-interface-to-talk-to-a-cache.patch 0016-netfs-Add-a-tracepoint-to-log-failures-that-would-be.patch 0017-fscache-cachefiles-Add-alternate-API-to-use-kiocb-fo.patch ... and added them on top of Linux 5.12-rc8 and added my readahead patch to that. Now I fail one extra xfstest, I fail generic/075, generic/112, generic/127, generic/263 and generic/438. I haven't found an obvious (to me) problem with my patch and I can't claim to understand everything that is going on in the patches I have of yours... I'll keep looking... -Mike On Fri, Apr 16, 2021 at 11:41 AM David Howells <dhowells@xxxxxxxxxx> wrote: > > In orangefs_readahead(): > > loff_t bytes_remaining = inode->i_size - readahead_pos(rac); > loff_t pages_remaining = bytes_remaining / PAGE_SIZE; > > What happens if bytes_remaining < PAGE_SIZE? Or even what happens if > bytes_remaining % PAGE_SIZE != 0? > > if ((ret = wait_for_direct_io(ORANGEFS_IO_READ, inode, > &offset, &iter, readahead_length(rac), > inode->i_size, NULL, NULL, file)) < 0) > > I wonder if you should use iov_length(&iter) rather than > readahead_length(rac). They *should* be the same. > > Also, should you cache inode->i_size lest it change under you due to truncate? > > David >