linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Out of order read() completion and buffer filling beyond returned amount
@ 2022-01-17  9:57 David Howells
  2022-01-17 10:19 ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: David Howells @ 2022-01-17  9:57 UTC (permalink / raw)
  To: Alexander Viro, Linus Torvalds
  Cc: dhowells, Anna Schumaker, Dave Wysochanski, Dominique Martinet,
	Jeff Layton, Latchesar Ionkov, Marc Dionne, Matthew Wilcox,
	Omar Sandoval, Shyam Prasad N, Steve French, Trond Myklebust,
	Peter Zijlstra, ceph-devel, linux-afs, linux-cachefs, linux-cifs,
	linux-fsdevel, linux-mm, linux-nfs, v9fs-developer, linux-kernel

Hi Al, Linus,

Do you have an opinion on whether it's permissible for a filesystem to write
into the read() buffer beyond the amount it claims to return, though still
within the specified size of the buffer?

I'm working on common DIO routines for 9p, afs, ceph and cifs in netfs lib,
and I can see that at least three of those four filesystems either can or must
split a read, possibly being required to distribute across multiple servers.

If a filesystem was to emit multiple read RPCs in parallel, there is the
possibility that they would complete out of order - particularly if they go to
multiple servers.

Would it be a violation of the way the read() family of syscalls work to write
the data into the buffers out of order, and then abandon the extra data
written at the end if one of the RPCs returned a short read?  We would have
clobbered some of the buffer that we haven't said we've modified.

For buffered reads, it's not a problem as we can fill the pagecache out of
order with no issue.

David


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-18  7:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17  9:57 Out of order read() completion and buffer filling beyond returned amount David Howells
2022-01-17 10:19 ` Linus Torvalds
2022-01-17 13:30   ` Matthew Wilcox
2022-01-18  7:25     ` Christoph Hellwig

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).