From: Omar Sandoval <osandov@osandov.com>
To: Christian Schoenebeck <qemu_oss@crudebyte.com>
Cc: qemu-devel@nongnu.org, Greg Kurz <groug@kaod.org>
Subject: Re: [PATCH] 9pfs: local: ignore O_NOATIME if we don't have permissions
Date: Fri, 17 Apr 2020 11:36:01 -0700 [thread overview]
Message-ID: <20200417183601.GA719237@vader> (raw)
In-Reply-To: <1939315.5ePf2Jtb4B@silver>
On Fri, Apr 17, 2020 at 12:45:36PM +0200, Christian Schoenebeck wrote:
> On Donnerstag, 16. April 2020 20:47:11 CEST Omar Sandoval wrote:
> > > > Luckily, O_NOATIME is effectively a hint, and is often ignored by, e.g.,
> > > > network filesystems. open(2) notes that O_NOATIME "may not be effective
> > > > on all filesystems. One example is NFS, where the server maintains the
> > > > access time." This means that we can honor it when possible but fall
> > > > back to ignoring it.
> > >
> > > I am not sure whether NFS would simply silently ignore O_NOATIME i.e.
> > > without returning EPERM. I don't read it that way.
> >
> > As far as I can tell, the NFS protocol has nothing equivalent to
> > O_NOATIME and thus can't honor it. Feel free to test it:
>
> I did not doubt that NFS does not support O_NOATIME, what I said was that I
> thought using O_NOATIME on NFS would return EPERM, but ...
>
> > # mount -t nfs -o vers=4,rw 10.0.2.2:/ /mnt
> > # echo foo > /mnt/foo
> > # touch -d "1 hour ago" /mnt/foo
> > # stat /mnt/foo | grep 'Access: [0-9]'
> > Access: 2020-04-16 10:43:36.838952593 -0700
> > # # Drop caches so we have to go to the NFS server.
> > # echo 3 > /proc/sys/vm/drop_caches
> > # strace -e openat dd if=/mnt/foo of=/dev/null iflag=noatime |& grep
> > /mnt/foo openat(AT_FDCWD, "/mnt/foo", O_RDONLY|O_NOATIME) = 3
> > # stat /mnt/foo | grep 'Access: [0-9]'
> > Access: 2020-04-16 11:43:36.906462928 -0700
>
> ... I tried this as well, and you are right, O_NOATIME is indeed simply
> *silently* dropped/ignored by NFS (i.e. without raising any error).
>
> > > It would certainly fix the problem in your use case. But it would also
> > > unmask O_NOATIME for all other ones (i.e. regular users on guest).
> >
> > The guest kernel will still check whether processes on the guest have
> > permission to use O_NOATIME. This only changes the behavior when the
> > guest kernel believes that the process has permission even though the
> > host QEMU process doesn't.
>
> Good point!
>
> > > I mean I understand your point, but I also have to take other use cases
> > > into account which might expect to receive EPERM if O_NOATIME cannot be
> > > granted.
> > If you'd still like to preserve this behavior, would it be acceptable to
> > make this a QEMU option? Maybe something like "-virtfs
> > honor_noatime=no": the default would be "yes", which is the current
> > behavior, and "no" would always mask out NOATIME.
>
> That was my initial tendency yesterday, but your arguments now convinced me
> that the implied re-run, in the way your provided patch already does, is in
> this particular case the better choice.
>
> Making that a configurable option would render this issue unnecessarily
> complicated and probably even contra productive for other users which might
> stumble over the same issue.
>
> Just do me a favour: you already thoroughly explained the issue in the commit
> log, that's good, but please also add a short comment in code why the rerun is
> required, because it is not obvious by just reading the code. Finding that
> info from git log becomes tedious as soon as code is refactored there.
>
> Aside of the missing comment in code:
>
> Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Thank you! I'll add the comment and resend.
prev parent reply other threads:[~2020-04-17 18:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-16 0:44 [PATCH] 9pfs: local: ignore O_NOATIME if we don't have permissions Omar Sandoval
2020-04-16 14:58 ` Christian Schoenebeck
2020-04-16 18:47 ` Omar Sandoval
2020-04-17 10:45 ` Christian Schoenebeck
2020-04-17 18:36 ` Omar Sandoval [this message]
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=20200417183601.GA719237@vader \
--to=osandov@osandov.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
/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).