From: Linus Torvalds <torvalds@linux-foundation.org>
To: L29Ah <l29ah@cock.li>
Cc: Dominique Martinet <asmadeus@codewreck.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
v9fs-developer@lists.sourceforge.net
Subject: Re: [GIT PULL] 9p update for 5.7
Date: Tue, 7 Apr 2020 10:59:03 -0700 [thread overview]
Message-ID: <CAHk-=wiE6_L2NnSo82erMHxbP8fa=f_b64G+Muu0JnUEBgDwOg@mail.gmail.com> (raw)
In-Reply-To: <20200407021626.cd3wwbg7ayiwt4ry@l29ah-x201.l29ah-x201>
On Mon, Apr 6, 2020 at 7:16 PM L29Ah <l29ah@cock.li> wrote:
>
> In fact i would prefer disabling the full reads unconditionally, but AFAIR some userspace programs might interpret a short read as EOF (and also would need to check the logic that motivated the kernel-side looping).
Oh, it's even worse than "might interpret a short read as EOF".
Lots of ad-hoc small tools will basically do something like
fd = open(name, O_RDONLY);
fstat(fd, &st);
buf = malloc(st.st_size);
read(fd, buf, st.st_size);
and be done with it. Obviously they may have some error handling (ie
imagine the above being written with proper tests for buf beign NULL
and 'fstat()' returning an error), but if they check the return value
of "read()" at all, it might be just to verify that it matches
st.st_size.
I've written stuff like that myself.
Sure, the "real" programs I write would have loops with EAGAIN and
partial reads, and maybe I'd have a helper function called "xread()"
that does that. And most major applications will do things like that,
exactly because they've seen years of development, they're trying to
be portable, and they might even have hit other network filesystems
that do partial reads or return EAGAIN - or they might have more
complex functionality anyway which allows you to pipe things in from a
buffer etc.
But the above kind of "assume read() gets the whole thing" is not
unusual for quick hacks.
After all, it's a _valid_ assumption for a proper POSIX filesystem,
although it obviously _also_ assumes that nobody else is writing to
that file at the same time.
And some of those quick hacks may end up existing for years in major
code-bases, who knows..
[ Honesty in advertising: the Linux VFS layer itself says "screw
POSIX" for some things.
Particularly, if somebody tries to do a read larger than 2GB in
size, the VFS layer will just say "POSIX is garbage in this situation,
we _will_ truncate this read".
So if you deal with huge files, you _have_ to do the proper "loop
until EOF" even for regular files, and POSIX be damned.
The kernel refuses to do crazy things, and no amount of standard
paperwork matters. ]
But basically honoring full reads for any _reasonable_ situation is
pretty much required for a lot of reasons. Yes, lots of apps will deal
gracefully with partial reads - maybe even most. But "lots" is not
"all".
Linus
next prev parent reply other threads:[~2020-04-07 17:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-06 11:07 [GIT PULL] 9p update for 5.7 Dominique Martinet
2020-04-06 15:53 ` Linus Torvalds
2020-04-06 16:40 ` Dominique Martinet
2020-04-06 16:46 ` Matthew Wilcox
2020-04-06 16:55 ` Dominique Martinet
2020-04-06 17:04 ` Linus Torvalds
2020-04-06 17:39 ` Matthew Wilcox
2020-04-06 17:46 ` Linus Torvalds
2020-04-06 18:42 ` Dominique Martinet
2020-04-07 2:16 ` L29Ah
2020-04-07 6:31 ` Dominique Martinet
2020-04-07 17:59 ` Linus Torvalds [this message]
2020-04-06 16:45 ` pr-tracker-bot
2020-04-08 15:12 ` [GIT PULL v2] " Dominique Martinet
2020-04-09 4:53 ` Linus Torvalds
2020-04-09 4:55 ` pr-tracker-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHk-=wiE6_L2NnSo82erMHxbP8fa=f_b64G+Muu0JnUEBgDwOg@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=asmadeus@codewreck.org \
--cc=l29ah@cock.li \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).