WSL2-Linux-Kernel/fs/vboxsf
Hans de Goede 52dfd86aa5 vboxsf: Add support for the atomic_open directory-inode op
Opening a new file is done in 2 steps on regular filesystems:

1. Call the create inode-op on the parent-dir to create an inode
to hold the meta-data related to the file.
2. Call the open file-op to get a handle for the file.

vboxsf however does not really use disk-backed inodes because it
is based on passing through file-related system-calls through to
the hypervisor. So both steps translate to an open(2) call being
passed through to the hypervisor. With the handle returned by
the first call immediately being closed again.

Making 2 open calls for a single open(..., O_CREATE, ...) calls
has 2 problems:

a) It is not really efficient.
b) It actually breaks some apps.

An example of b) is doing a git clone inside a vboxsf mount.
When git clone tries to create a tempfile to store the pak
files which is downloading the following happens:

1. vboxsf_dir_mkfile() gets called with a mode of 0444 and succeeds.
2. vboxsf_file_open() gets called with file->f_flags containing
O_RDWR. When the host is a Linux machine this fails because doing
a open(..., O_RDWR) on a file which exists and has mode 0444 results
in an -EPERM error.

Other network-filesystems and fuse avoid the problem of needing to
pass 2 open() calls to the other side by using the atomic_open
directory-inode op.

This commit fixes git clone not working inside a vboxsf mount,
by adding support for the atomic_open directory-inode op.
As an added bonus this should also make opening new files faster.

The atomic_open implementation is modelled after the atomic_open
implementations from the 9p and fuse code.

Fixes: 0fd1695766 ("fs: Add VirtualBox guest shared folder (vboxsf) support")
Reported-by: Ludovic Pouzenc <bugreports@pouzenc.fr>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-06-23 14:36:52 +02:00
..
Kconfig
Makefile
dir.c vboxsf: Add support for the atomic_open directory-inode op 2021-06-23 14:36:52 +02:00
file.c vboxsf: Add vboxsf_[create|release]_sf_handle() helpers 2021-06-23 14:36:46 +02:00
shfl_hostintf.h
super.c vboxsf: don't allow to change the inode type 2021-03-12 22:15:00 -05:00
utils.c vboxsf: don't allow to change the inode type 2021-03-12 22:15:00 -05:00
vboxsf_wrappers.c
vfsmod.h vboxsf: Add vboxsf_[create|release]_sf_handle() helpers 2021-06-23 14:36:46 +02:00