minix/minix/tests
David van Moolenbroek c2bd30203c Fix soft faults in FSes resulting in partial I/O
In order to resolve page faults on file-mapped pages, VM may need to
communicate (through VFS) with a file system.  The file system must
therefore not be the one to cause, and thus end up being blocked on,
such page faults.  To resolve this potential deadlock, the safecopy
system was previously extended with the CPF_TRY flag, which causes the
kernel to return EFAULT to the caller of a safecopy function upon
getting a pagefault, bypassing VM and thus avoiding the loop.  VFS was
extended to repeat relevant file system calls that returned EFAULT,
after resolving the page fault, to keep these soft faults from being
exposed to applications.

However, general UNIX I/O semantics dictate that if an I/O transfer
partially succeeded before running into a failure, the partial result
is to be returned.  Proper file system implementations may therefore
end up returning partial success rather than the EFAULT code resulting
from a soft fault.  Since VFS does not get the EFAULT code in this
case, it does not know that a soft fault occurred, and thus does not
repeat the call either.  The end result is that an application may get
partial I/O results (e.g., a short read(2)) even on regular files.
Applications cannot reasonably be expected to deal with this.

Due to the fact that most of the current file system implementations
do not implement proper partial-failure semantics, this problem is not
yet widespread.  In fact, it has only occurred on direct block device
I/O so far.  However, the next generation of file system services will
be implementing proper I/O semantics, thus exacerbating the problem.

To remedy this situation, this patch changes the CPF_TRY semantics:
whenever the kernel experiences a soft fault during a safecopy call,
in addition to returning FAULT, the kernel also stores a mark in the
grant created with CPF_TRY.  Instead of testing on EFAULT, VFS checks
whether the grant was marked, as part of revoking the grant.  If the
grant was indeed marked by the kernel, VFS repeats the file system
operation, regardless of its initial return value.  Thus, the EFAULT
code now only serves to make the file system fail the call faster.

The approach is currently supported for both direct and magic grants,
but is used only with magic grants - arguably the only case where it
makes sense.  Indirect grants should not have CPF_TRY set; in a chain
of indirect grants, the original grant is marked, as it should be.
In order to avoid potential SMP issues, the mark stored in the grant
is its grant identifier, so as to discard outdated kernel writes.
Whether this is necessary or effective remains to be evaluated.

This patch also cleans up the grant structure a bit, removing reserved
space and thus making the structure slightly smaller.  The structure
is used internally between system services only, so there is no need
for binary compatibility.

Change-Id: I6bb3990dce67a80146d954546075ceda4d6567f8
2016-01-13 20:33:11 +01:00
..
blocktest Fix soft faults in FSes resulting in partial I/O 2016-01-13 20:33:11 +01:00
ddekit merge libminlib with libc 2014-08-28 18:49:19 +02:00
ds merge libminlib with libc 2014-08-28 18:49:19 +02:00
fbdtest Move all services to /service 2014-07-31 16:00:31 +02:00
kernel merge libminlib with libc 2014-08-28 18:49:19 +02:00
safecopy merge libminlib with libc 2014-08-28 18:49:19 +02:00
check-install /usr/tests/minix-posix/check-install 2014-08-13 16:42:57 +02:00
common-socket.c Resolve more warnings 2015-09-23 12:04:58 +00:00
common-socket.h Add new tests 80 (TCP) and 81 (UDP) 2015-07-08 09:46:56 +02:00
common.c NetBSD re-synchronization of the source tree 2016-01-13 20:32:14 +01:00
common.h NetBSD re-synchronization of the source tree 2016-01-13 20:32:14 +01:00
magic.h New sources layout 2014-07-31 16:00:30 +02:00
Makefile IPC server: major fixes, test set for semaphores 2016-01-13 20:33:00 +01:00
Makefile.inc New sources layout 2014-07-31 16:00:30 +02:00
mod.c New sources layout 2014-07-31 16:00:30 +02:00
run IPC server: major fixes, test set for semaphores 2016-01-13 20:33:00 +01:00
t10a.c New sources layout 2014-07-31 16:00:30 +02:00
t11a.c New sources layout 2014-07-31 16:00:30 +02:00
t11b.c New sources layout 2014-07-31 16:00:30 +02:00
t40a.c New sources layout 2014-07-31 16:00:30 +02:00
t40b.c New sources layout 2014-07-31 16:00:30 +02:00
t40c.c New sources layout 2014-07-31 16:00:30 +02:00
t40d.c New sources layout 2014-07-31 16:00:30 +02:00
t40e.c New sources layout 2014-07-31 16:00:30 +02:00
t40f.c New sources layout 2014-07-31 16:00:30 +02:00
t40g.c New sources layout 2014-07-31 16:00:30 +02:00
t60a.c New sources layout 2014-07-31 16:00:30 +02:00
t60b.c New sources layout 2014-07-31 16:00:30 +02:00
t67a.c New sources layout 2014-07-31 16:00:30 +02:00
t67b.c New sources layout 2014-07-31 16:00:30 +02:00
t68a.c New sources layout 2014-07-31 16:00:30 +02:00
t68b.c New sources layout 2014-07-31 16:00:30 +02:00
t84_h_nonexec.sh libc: add posix_spawn family of functions 2015-07-28 14:18:03 +00:00
t84_h_spawn.c libc: add posix_spawn family of functions 2015-07-28 14:18:03 +00:00
t84_h_spawnattr.c libc: add posix_spawn family of functions 2015-07-28 14:18:03 +00:00
test1.c New sources layout 2014-07-31 16:00:30 +02:00
test2.c New sources layout 2014-07-31 16:00:30 +02:00
test3.c New sources layout 2014-07-31 16:00:30 +02:00
test4.c New sources layout 2014-07-31 16:00:30 +02:00
test5.c New sources layout 2014-07-31 16:00:30 +02:00
test6.c New sources layout 2014-07-31 16:00:30 +02:00
test7.c VFS: add support for F_DUPFD_CLOEXEC 2015-07-20 13:55:10 +00:00
test8.c New sources layout 2014-07-31 16:00:30 +02:00
test9.c New sources layout 2014-07-31 16:00:30 +02:00
test10.c New sources layout 2014-07-31 16:00:30 +02:00
test11.c New sources layout 2014-07-31 16:00:30 +02:00
test12.c New sources layout 2014-07-31 16:00:30 +02:00
test13.c New sources layout 2014-07-31 16:00:30 +02:00
test14.c New sources layout 2014-07-31 16:00:30 +02:00
test15.c New sources layout 2014-07-31 16:00:30 +02:00
test16.c New sources layout 2014-07-31 16:00:30 +02:00
test17.c New sources layout 2014-07-31 16:00:30 +02:00
test18.c New sources layout 2014-07-31 16:00:30 +02:00
test19.c New sources layout 2014-07-31 16:00:30 +02:00
test20.c New sources layout 2014-07-31 16:00:30 +02:00
test21.c New sources layout 2014-07-31 16:00:30 +02:00
test22.c New sources layout 2014-07-31 16:00:30 +02:00
test23.c New sources layout 2014-07-31 16:00:30 +02:00
test24.c New sources layout 2014-07-31 16:00:30 +02:00
test25.c New sources layout 2014-07-31 16:00:30 +02:00
test26.c New sources layout 2014-07-31 16:00:30 +02:00
test27.c New sources layout 2014-07-31 16:00:30 +02:00
test28.c New sources layout 2014-07-31 16:00:30 +02:00
test29.c New sources layout 2014-07-31 16:00:30 +02:00
test30.c New sources layout 2014-07-31 16:00:30 +02:00
test31.c New sources layout 2014-07-31 16:00:30 +02:00
test32.c New sources layout 2014-07-31 16:00:30 +02:00
test33.c NetBSD re-synchronization of the source tree 2016-01-13 20:32:14 +01:00
test34.c Resolve more warnings 2015-09-23 12:04:58 +00:00
test35.c Resolve more warnings 2015-09-23 12:04:58 +00:00
test36.c New sources layout 2014-07-31 16:00:30 +02:00
test37.c tests: fix clang warnings 2014-09-29 16:16:32 +00:00
test38.c New sources layout 2014-07-31 16:00:30 +02:00
test39.c New sources layout 2014-07-31 16:00:30 +02:00
test40.c New sources layout 2014-07-31 16:00:30 +02:00
test41.c New sources layout 2014-07-31 16:00:30 +02:00
test42.c Resolve more warnings 2015-09-23 12:04:58 +00:00
test43.c New sources layout 2014-07-31 16:00:30 +02:00
test44.c New sources layout 2014-07-31 16:00:30 +02:00
test45.c New sources layout 2014-07-31 16:00:30 +02:00
test45.h New sources layout 2014-07-31 16:00:30 +02:00
test46.c NetBSD re-synchronization of the source tree 2016-01-13 20:32:14 +01:00
test47.c New sources layout 2014-07-31 16:00:30 +02:00
test48.c test48: skip some redundant combinations of parameters 2015-07-08 09:32:17 +02:00
test49.c New sources layout 2014-07-31 16:00:30 +02:00
test50.c New sources layout 2014-07-31 16:00:30 +02:00
test51.c tests: fix clang warnings 2014-09-29 16:16:32 +00:00
test52.c New sources layout 2014-07-31 16:00:30 +02:00
test53.c New sources layout 2014-07-31 16:00:30 +02:00
test54.c New sources layout 2014-07-31 16:00:30 +02:00
test55.c New sources layout 2014-07-31 16:00:30 +02:00
test56.c Resolve more warnings 2015-09-23 12:04:58 +00:00
test57.c New sources layout 2014-07-31 16:00:30 +02:00
test57loop.S New sources layout 2014-07-31 16:00:30 +02:00
test58.c New sources layout 2014-07-31 16:00:30 +02:00
test59.c test59: fix status type for mthread_join call 2014-08-24 09:22:35 +00:00
test60.c New sources layout 2014-07-31 16:00:30 +02:00
test61.c New sources layout 2014-07-31 16:00:30 +02:00
test62.c New sources layout 2014-07-31 16:00:30 +02:00
test63.c New sources layout 2014-07-31 16:00:30 +02:00
test64.c New sources layout 2014-07-31 16:00:30 +02:00
test65.c New sources layout 2014-07-31 16:00:30 +02:00
test66.c New sources layout 2014-07-31 16:00:30 +02:00
test66expected.h New sources layout 2014-07-31 16:00:30 +02:00
test67.c New sources layout 2014-07-31 16:00:30 +02:00
test68.c VFS: fix error behavior for partial pipe writes 2015-06-05 18:40:57 +00:00
test69.c Resolve more warnings 2015-09-23 12:04:58 +00:00
test70.c Resolve more warnings 2015-09-23 12:04:58 +00:00
test71.c New sources layout 2014-07-31 16:00:30 +02:00
test72.c libminixfs: better support for read errors and EOF 2015-08-14 18:39:26 +00:00
test73.c NetBSD re-synchronization of the source tree 2016-01-13 20:32:14 +01:00
test74.c Fix soft faults in FSes resulting in partial I/O 2016-01-13 20:33:11 +01:00
test75.c PM: add support for wait4(2) 2015-09-29 18:15:28 +00:00
test76.c Add PTYFS, Unix98 pseudo terminal support 2015-06-23 17:43:46 +00:00
test77.c Add PTYFS, Unix98 pseudo terminal support 2015-06-23 17:43:46 +00:00
test78.c New sources layout 2014-07-31 16:00:30 +02:00
test79.c New sources layout 2014-07-31 16:00:30 +02:00
test80.c tests: resolve new compiler warnings 2015-07-28 14:18:35 +00:00
test81.c tests: resolve new compiler warnings 2015-07-28 14:18:35 +00:00
test82.c test82: share support functions in common.[ch] for test83 2015-07-22 22:24:22 +02:00
test83.c Resolve more warnings 2015-09-23 12:04:58 +00:00
test84.c libc: add posix_spawn family of functions 2015-07-28 14:18:03 +00:00
test85.c NetBSD re-synchronization of the source tree 2016-01-13 20:32:14 +01:00
test86.c VFS: check X bit, not R bit, opening executables 2015-08-31 12:55:55 +00:00
test87.c Add MIB service, sysctl(2) support 2016-01-13 20:32:37 +01:00
test88.c IPC server: major fixes, test set for semaphores 2016-01-13 20:33:00 +01:00
testcache.c New sources layout 2014-07-31 16:00:30 +02:00
testcache.h New sources layout 2014-07-31 16:00:30 +02:00
testinterp.sh New sources layout 2014-07-31 16:00:30 +02:00
testisofs.sh isofs: reworked for better performance 2015-10-07 12:40:24 +02:00
testkyua.sh New sources layout 2014-07-31 16:00:30 +02:00
testmfs.sh New sources layout 2014-07-31 16:00:30 +02:00
testrelpol.sh tests: extend multicomponent live update test 2015-09-17 14:11:48 +00:00
testsh1.sh Porting uuencode/uudecode from NetBSD 2014-09-08 19:51:28 +02:00
testsh2.sh Import NetBSD sysctl(8) 2016-01-13 20:32:48 +01:00
testvm.c libfsdriver: support mmap on FSes with no device 2014-11-15 11:19:52 +00:00
testvm.conf libminixfs/VM: fix memory-mapped file corruption 2015-08-13 13:46:46 +00:00
testvm.h New sources layout 2014-07-31 16:00:30 +02:00
testvnd.sh Importing bin/sh 2014-08-29 12:56:04 -04:00
tvnd.c New sources layout 2014-07-31 16:00:30 +02:00