linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	David Howells <dhowells@redhat.com>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v13] fs: Add VirtualBox guest shared folder (vboxsf) support
Date: Fri, 16 Aug 2019 11:39:32 +0200	[thread overview]
Message-ID: <5ce18de2-b594-c06d-21a0-aa9677dbcc0a@redhat.com> (raw)
In-Reply-To: <412a10a9-a681-4c7a-9175-e7509b3fea87@redhat.com>

P.S.

On 16-08-19 11:01, Hans de Goede wrote:
> On 16-08-19 09:56, Christoph Hellwig wrote:

<snip>

>>> + * Ideally we would wrap generic_file_read_iter with a function which also
>>> + * does this check, to reduce the chance of us missing writes happening on the
>>> + * host side after open(). But the vboxsf stat call to the host only works on
>>> + * filenames, so that would require caching the filename in our
>>> + * file->private_data and there is no guarantee that filename will still
>>> + * be valid at read_iter time. So this would be in no way bulletproof.
>>
>> Well, you can usually generate a file name from file->f_path.dentry.
>> The only odd case is opened by unliked files.  NFS has a special hack
>> for those called sillyrename (you can grep for that). 
> 
> Right, so since the unlink or a normal rename could happen on the host side
> and there is no notification of that, those will be 2 areas where a stat
> call to verify will fail, which leaves us with 3 options:
> 
> 1) Make stat calls before read() calls, if they fail purge the cache to be safe
> 2) Make stat calls before read(), on failure ignore the stat call
> 3) Treat read() calls like other page-cache reads such as sendfile or mmap
> and only check if the cache is stale at open() time.

I just realized there is a 4th option, which is to make vboxsf read_iter
simply always do:

4) Always evict non dirt pages from page-cache from read_iter, to ensure we
    get the latest version from the host:

So something like this:

	/*
          * Evict non dirt pages from page-cache, so that we reget them from
          * the host in case they have been changed.
          * /
	invalidate_mapping_pages(inode->i_mapping, pos >> PAGE_SHIFT,
				 (pos + len) >> PAGE_SHIFT);
         generic_file_read_iter(...)

This is in essence what the out of tree driver is doing on read(), except
that it does not go through the page-cache at all.

I think this might be the best option, perhaps controlled by a mount
flag ?

Regards,

Hans

  reply	other threads:[~2019-08-16  9:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15 13:12 [PATCH v13] fs: Add VirtualBox guest shared folder (vboxsf) support Hans de Goede
2019-08-15 13:12 ` Hans de Goede
2019-08-16  7:56   ` Christoph Hellwig
2019-08-16  9:01     ` Hans de Goede
2019-08-16  9:39       ` Hans de Goede [this message]
2019-08-16 12:49       ` Christoph Hellwig
2019-08-15 13:33 ` Hans de Goede

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=5ce18de2-b594-c06d-21a0-aa9677dbcc0a@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).