]> git.proxmox.com Git - mirror_qemu.git/commit - tools/virtiofsd/passthrough_ll.c
virtiofsd: passthrough_ll: add fallback for racy ops
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 14 Nov 2018 15:52:03 +0000 (16:52 +0100)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Thu, 23 Jan 2020 16:41:36 +0000 (16:41 +0000)
commit5fe319a7b19c9c328e6e061bffcf1ff6cc8b89ce
tree258008123741e2d70ad0e23185b8c04b6720df31
parent73b4d19dfc4248a74c1f3e511cfa934681d9c602
virtiofsd: passthrough_ll: add fallback for racy ops

We have two operations that cannot be done race-free on a symlink in
certain cases: utimes and link.

Add racy fallback for these if the race-free method doesn't work.  We do
our best to avoid races even in this case:

  - get absolute path by reading /proc/self/fd/NN symlink

  - lookup parent directory: after this we are safe against renames in
    ancestors

  - lookup name in parent directory, and verify that we got to the original
    inode,  if not retry the whole thing

Both utimes(2) and link(2) hold i_lock on the inode across the operation,
so a racing rename/delete by this fuse instance is not possible, only from
other entities changing the filesystem.

If the "norace" option is given, then disable the racy fallbacks.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tools/virtiofsd/helper.c
tools/virtiofsd/passthrough_ll.c