From: Hans de Goede <hdegoede@redhat.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: David Howells <dhowells@redhat.com>, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v9] fs: Add VirtualBox guest shared folder (vboxsf) support
Date: Tue, 9 Apr 2019 17:29:28 +0200 [thread overview]
Message-ID: <3cebf7a6-c29f-121b-5243-43341c93560e@redhat.com> (raw)
In-Reply-To: <700ac073-ef5f-a5a7-698f-67465cfa81ac@redhat.com>
Hi,
<big snip>
>>> + if (err)
>>> + return err;
>>> +
>>> + *off += nwritten;
>>> + if (*off > inode->i_size)
>>> + i_size_write(inode, *off);
>>> +
>>> + /* Invalidate page-cache so that mmap using apps see the changes too */
>>> + invalidate_mapping_pages(inode->i_mapping, pos >> PAGE_SHIFT,
>>> + *off >> PAGE_SHIFT);
>>> +
>>> + /* mtime changed */
>>> + sf_i->force_restat = 1;
>>> + return nwritten;
>>> +}
>>
>>> + /* Already open? */
>>> + if (sf_i->handle != SHFL_HANDLE_NIL) {
>>> + sf_r->handle = sf_i->handle;
>>> + sf_i->handle = SHFL_HANDLE_NIL;
>>> + sf_i->file = file;
>>> + file->private_data = sf_r;
>>
>> Obviously racy.
>
> Ok, so how do we fix this? Add a mutex to the private
> struct sf_inode_info and take that here and in other
> relevant places I guess?
>
>
>>> + /* the host may have given us different attr then requested */
>>> + sf_i->force_restat = 1;
>>> + sf_r->handle = params.handle;
>>> + sf_i->file = file;
>>
>> Ditto. Two opens in parallel and you are in trouble.
>
> I assume what you fall over there is the "sf_i->file = file" which
> is a hack which is purely implemented to have a handle for writepage.
>
> Looking at this closer, I think the right thing todo might be to
> implement our own .mmap callback + vma_close callback and then
> refcount the handle and store it in vm_private_data so that we
> can get it from there rather then having this hack of storing
> a struct file * in the inode which as you rightly point out is
> obviously buggy.
>
> What do you think of using the vm_private_data approach?
Ok this is of course nonsense as we do not have access to the vma
from the writepage callback. So instead I plan to store a list
of writeable handles in the inode combined with a custom vma_close
like fuse is doing to make sure we dump any changes before loosing
the last handle.
Does that sound ok?
Regards,
Hans
prev parent reply other threads:[~2019-04-09 15:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 11:54 [PATCH v9 0/1] fs: Add VirtualBox guest shared folder (vboxsf) support Hans de Goede
2019-04-02 11:54 ` [PATCH v9] " Hans de Goede
2019-04-03 20:49 ` Al Viro
2019-04-09 13:27 ` Hans de Goede
2019-04-09 15:29 ` Hans de Goede [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=3cebf7a6-c29f-121b-5243-43341c93560e@redhat.com \
--to=hdegoede@redhat.com \
--cc=dhowells@redhat.com \
--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).