linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Do we need to unrevert "fs: do not prefault sys_write() user buffer pages"?
@ 2021-06-22 15:20 David Howells
  2021-06-22 15:27 ` Al Viro
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: David Howells @ 2021-06-22 15:20 UTC (permalink / raw)
  To: torvalds
  Cc: dhowells, Ted Ts'o, Dave Hansen, Andrew Morton, willy, viro,
	linux-mm, linux-ext4, linux-fsdevel, linux-kernel

Hi Linus,

I've been looking at generic_perform_write() with an eye to adapting a version
for network filesystems in general.  I'm wondering if it's actually safe or
whether it needs 00a3d660cbac05af34cca149cb80fb611e916935 reverting, which is
itself a revert of 998ef75ddb5709bbea0bf1506cd2717348a3c647.

Anyway, I was looking at this bit:

	bytes = min_t(unsigned long, PAGE_SIZE - offset,
					iov_iter_count(i));
	...
	if (unlikely(iov_iter_fault_in_readable(i, bytes))) {
		status = -EFAULT;
		break;
	}

	if (fatal_signal_pending(current)) {
		status = -EINTR;
		break;
	}

	status = a_ops->write_begin(file, mapping, pos, bytes, flags,
					&page, &fsdata);
	if (unlikely(status < 0))
		break;

	if (mapping_writably_mapped(mapping))
		flush_dcache_page(page);

	copied = iov_iter_copy_from_user_atomic(page, i, offset, bytes);


and wondering if the iov_iter_fault_in_readable() is actually effective.  Yes,
it can make sure that the page we're intending to modify is dragged into the
pagecache and marked uptodate so that it can be read from, but is it possible
for the page to then get reclaimed before we get to
iov_iter_copy_from_user_atomic()?  a_ops->write_begin() could potentially take
a long time, say if it has to go and get a lock/lease from a server.

Also, I've been thinking about Willy's folio/THP stuff that allows bunches of
pages to be glued together into single objects for efficiency.  This is
problematic with the above code because the faultahead is limited to a maximum
of PAGE_SIZE, but we might be wanting to modify a larger object than that.

David


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

end of thread, other threads:[~2021-06-22 22:31 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 15:20 Do we need to unrevert "fs: do not prefault sys_write() user buffer pages"? David Howells
2021-06-22 15:27 ` Al Viro
2021-06-22 15:36   ` Al Viro
2021-06-22 17:25     ` Matthew Wilcox
2021-06-22 17:39       ` Linus Torvalds
2021-06-22 17:55       ` David Howells
2021-06-22 18:04         ` Matthew Wilcox
2021-06-22 18:07           ` Linus Torvalds
2021-06-22 18:16             ` Nadav Amit
2021-06-22 18:23             ` Matthew Wilcox
2021-06-22 18:28               ` Linus Torvalds
2021-06-22 18:36                 ` Matthew Wilcox
2021-06-22 18:51                   ` Nadav Amit
2021-06-22 18:57                     ` Linus Torvalds
2021-06-22 18:23           ` David Howells
2021-06-22 18:32             ` Linus Torvalds
2021-06-22 18:13         ` David Howells
2021-06-22 15:32 ` Linus Torvalds
2021-06-22 15:53   ` Linus Torvalds
2021-06-22 15:32 ` Matthew Wilcox
2021-06-22 16:27 ` David Howells
2021-06-22 21:55   ` David Laight
2021-06-22 22:04     ` Matthew Wilcox
2021-06-22 22:31       ` David Laight
2021-06-22 22:20     ` Dave Chinner

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