Re: [GIT PULL] 9p update for 5.7

From: Linus Torvalds
Date: Mon Apr 06 2020 - 13:04:32 EST


On Mon, Apr 6, 2020 at 9:46 AM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> POSIX may well "allow" short reads, but userspace programmers basically
> never check the return value from read(). Short reads aren't actually
> allowed. That's why signals are only allowed to interrupt syscalls if
> they're fatal (and the application will never see the returned value
> because it's already dead).

Well, that's true for some applications.

But look at anybody who ever worked more with NFS mounts, and they got
used to having the 'intr' mount flag set and incomplete reads and
-EAGAIN as a result.

So a lot of normal applications are actually used to partial reads
even from file reads.

Are there apps that react badly? I'm sure - but they also wouldn't
have O_NONBLOCK set on a regular file. The only reason to set
O_NONBLOCK is because you think the fd might be a pipe or something,
and you _are_ ready to get partial reads.

So the 9p behavior certainly isn't outrageously out of line for a
network filesystem. In fact, because of O_NONBLOCK rather than a mount
option, I think it's a lot safer than a fairly standard NFS option.

Linus