I was wondering about the struct page rules of
iov_iter_get_pages_alloc(), used in various places. There's no
documentation whatsoever in lib/iov_iter.c, nor in
include/linux/uio.h, and the changelog that introduced it only says:
Author: Al Viro <viro(a)zeniv.linux.org.uk>
Date: Fri Mar 21 04:58:33 2014 -0400
new helper: iov_iter_get_pages_alloc()
same as iov_iter_get_pages(), except that pages array is allocated
(kmalloc if possible, vmalloc if that fails) and left for caller to
free. Lustre and NFS ->direct_IO() switched to it.
Signed-off-by: Al Viro <viro(a)zeniv.linux.org.uk>
So if code does iov_iter_get_pages_alloc() on a user address that has
a real struct page behind it - and some other code does a regular
get_user_pages() on it, we'll have two sets of struct page
descriptors, the 'real' one, and a fake allocated one, right?
How does that work? Nobody else can ever discover these fake page
structs, so they don't really serve any 'real' synchronization purpose
other than the limited role of IO completion.