All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Van Hensbergen <ericvh@gmail.com>
To: Bug 1336794 <1336794@bugs.launchpad.net>
Cc: Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	V9FS Developers <v9fs-developer@lists.sourceforge.net>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Bug 1336794] Re: 9pfs does not honor open file handles on unlinked files
Date: Sun, 12 Apr 2015 07:42:35 -0500	[thread overview]
Message-ID: <CAFkjPTm1gbHiRJqvWj74=T1Bs0KfiEb2xiN9F69EVHkHA8vn=g@mail.gmail.com> (raw)
In-Reply-To: <20150410123059.26540.1036.malone@gac.canonical.com>

[-- Attachment #1: Type: text/plain, Size: 4064 bytes --]

I've done some digging from the client side.  As is mentioned in Miklos'
original patch (which appears to have been shot down) the higher level
implementation appear to be broken for this.  Here's what the code looks
like for fstat in fs/stat.c:

int vfs_fstat(unsigned int fd, struct kstat *stat)
{
        struct fd f = fdget_raw(fd);
        int error = -EBADF;

        if (f.file) {
                error = vfs_getattr(&f.file->f_path, stat);
                fdput(f);
        }
        return error;
}

In other words, it only uses the open fd to derrive a path and then
executes the getattr off of that path.  If that path no longer exists
(because of unlink or remove) then you are hosed.  In my understanding, the
"work around" I suppose is the so-called 'silly renaming' where
remove/unlink simply does a rename until all open instances are closed.

The frustrating thing is that the 9p protocol is setup to work off of the
fid, which maps to the fd -- so its perfectly capable of the original
semantic but the high level code in fs/stat.c only wants to give a path.

I can do a work around on the client where a getattr "favors" open fids for
the operation or I can do the sillyrename hack that NFS and CIFS has used
but both of those look god-awful.

     -eric




On Fri, Apr 10, 2015 at 7:30 AM, Mark Glines <mark@glines.org> wrote:

> This bug makes it difficult to run a Debian Jessie guest with a 9pfs
> root filesystem, because "apt-get update" uses the open-unlink-fstat
> idiom.  With this bug present, apt dies with the following error:
>
> E: Unable to determine file size for fd 7 - fstat (2: No such file or
> directory)
>
> --
> You received this bug notification because you are a member of qemu-
> devel-ml, which is subscribed to QEMU.
> https://bugs.launchpad.net/bugs/1336794
>
> Title:
>   9pfs does not honor open file handles on unlinked files
>
> Status in QEMU:
>   New
>
> Bug description:
>   This was originally filed over here:
>   https://bugzilla.redhat.com/show_bug.cgi?id=1114221
>
>   The open-unlink-fstat idiom used in some places to create an anonymous
>   private temporary file does not work in a QEMU guest over a virtio-9p
>   filesystem.
>
>   Version-Release number of selected component (if applicable):
>
>   qemu-kvm-1.6.2-6.fc20.x86_64
>   qemu-system-x86-1.6.2-6.fc20.x86_64
>   (those are fedora RPMs)
>
>   How reproducible:
>
>   Always. See this example C program:
>
>   https://bugzilla.redhat.com/attachment.cgi?id=913069
>
>   Steps to Reproduce:
>   1. Export a filesystem with virt-manager for the guest.
>         (type: mount, driver: default, mode: passthrough)
>   2. Start guest and mount that filesystem
>         (mount -t 9p -o trans=virtio,version=9p2000.L  ...)
>   3. Run a program that uses open-unlink-fstat
>         (in my case it was trying to compile Perl 5.20)
>
>   Actual results:
>
>   fstat fails:
>
>   open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
>   unlink("/home/tst/filename")            = 0
>   fstat(3, 0x23aa1a8)                     = -1 ENOENT (No such file or
> directory)
>   close(3)
>
>   Expected results:
>
>   open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
>   unlink("/home/tst/filename")            = 0
>   fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
>   fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
>   close(3)
>
>   Additional info:
>
>   There was a patch put into the kernel back in '07 to handle this very
>   problem for other filesystems; maybe its helpful:
>
>         http://lwn.net/Articles/251228/
>
>   There is also a thread on LKML from last December specifically about
>   this very problem:
>
>         https://lkml.org/lkml/2013/12/31/163
>
>   There was a discussion on the QEMU list back in '11 that doesn't seem
>   to have come to a conclusion, but did provide the test program that
>   i've attached to this report:
>
>         http://marc.info/?l=qemu-devel&m=130443605720648&w=2
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1336794/+subscriptions
>
>

[-- Attachment #2: Type: text/html, Size: 5761 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Eric Van Hensbergen <ericvh@gmail.com>
To: Bug 1336794 <1336794@bugs.launchpad.net>
Cc: Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	V9FS Developers <v9fs-developer@lists.sourceforge.net>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Bug 1336794] Re: 9pfs does not honor open file handles on unlinked files
Date: Sun, 12 Apr 2015 07:42:35 -0500	[thread overview]
Message-ID: <CAFkjPTm1gbHiRJqvWj74=T1Bs0KfiEb2xiN9F69EVHkHA8vn=g@mail.gmail.com> (raw)
In-Reply-To: <20150410123059.26540.1036.malone@gac.canonical.com>

[-- Attachment #1: Type: text/plain, Size: 4064 bytes --]

I've done some digging from the client side.  As is mentioned in Miklos'
original patch (which appears to have been shot down) the higher level
implementation appear to be broken for this.  Here's what the code looks
like for fstat in fs/stat.c:

int vfs_fstat(unsigned int fd, struct kstat *stat)
{
        struct fd f = fdget_raw(fd);
        int error = -EBADF;

        if (f.file) {
                error = vfs_getattr(&f.file->f_path, stat);
                fdput(f);
        }
        return error;
}

In other words, it only uses the open fd to derrive a path and then
executes the getattr off of that path.  If that path no longer exists
(because of unlink or remove) then you are hosed.  In my understanding, the
"work around" I suppose is the so-called 'silly renaming' where
remove/unlink simply does a rename until all open instances are closed.

The frustrating thing is that the 9p protocol is setup to work off of the
fid, which maps to the fd -- so its perfectly capable of the original
semantic but the high level code in fs/stat.c only wants to give a path.

I can do a work around on the client where a getattr "favors" open fids for
the operation or I can do the sillyrename hack that NFS and CIFS has used
but both of those look god-awful.

     -eric




On Fri, Apr 10, 2015 at 7:30 AM, Mark Glines <mark@glines.org> wrote:

> This bug makes it difficult to run a Debian Jessie guest with a 9pfs
> root filesystem, because "apt-get update" uses the open-unlink-fstat
> idiom.  With this bug present, apt dies with the following error:
>
> E: Unable to determine file size for fd 7 - fstat (2: No such file or
> directory)
>
> --
> You received this bug notification because you are a member of qemu-
> devel-ml, which is subscribed to QEMU.
> https://bugs.launchpad.net/bugs/1336794
>
> Title:
>   9pfs does not honor open file handles on unlinked files
>
> Status in QEMU:
>   New
>
> Bug description:
>   This was originally filed over here:
>   https://bugzilla.redhat.com/show_bug.cgi?id=1114221
>
>   The open-unlink-fstat idiom used in some places to create an anonymous
>   private temporary file does not work in a QEMU guest over a virtio-9p
>   filesystem.
>
>   Version-Release number of selected component (if applicable):
>
>   qemu-kvm-1.6.2-6.fc20.x86_64
>   qemu-system-x86-1.6.2-6.fc20.x86_64
>   (those are fedora RPMs)
>
>   How reproducible:
>
>   Always. See this example C program:
>
>   https://bugzilla.redhat.com/attachment.cgi?id=913069
>
>   Steps to Reproduce:
>   1. Export a filesystem with virt-manager for the guest.
>         (type: mount, driver: default, mode: passthrough)
>   2. Start guest and mount that filesystem
>         (mount -t 9p -o trans=virtio,version=9p2000.L  ...)
>   3. Run a program that uses open-unlink-fstat
>         (in my case it was trying to compile Perl 5.20)
>
>   Actual results:
>
>   fstat fails:
>
>   open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
>   unlink("/home/tst/filename")            = 0
>   fstat(3, 0x23aa1a8)                     = -1 ENOENT (No such file or
> directory)
>   close(3)
>
>   Expected results:
>
>   open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
>   unlink("/home/tst/filename")            = 0
>   fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
>   fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
>   close(3)
>
>   Additional info:
>
>   There was a patch put into the kernel back in '07 to handle this very
>   problem for other filesystems; maybe its helpful:
>
>         http://lwn.net/Articles/251228/
>
>   There is also a thread on LKML from last December specifically about
>   this very problem:
>
>         https://lkml.org/lkml/2013/12/31/163
>
>   There was a discussion on the QEMU list back in '11 that doesn't seem
>   to have come to a conclusion, but did provide the test program that
>   i've attached to this report:
>
>         http://marc.info/?l=qemu-devel&m=130443605720648&w=2
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1336794/+subscriptions
>
>

[-- Attachment #2: Type: text/html, Size: 5761 bytes --]

  reply	other threads:[~2015-04-12 12:42 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-02 13:52 [Qemu-devel] [Bug 1336794] [NEW] 9pfs does not honor open file handles on unlinked files Cole Robinson
2015-04-10 12:30 ` [Qemu-devel] [Bug 1336794] " Mark Glines
2015-04-12 12:42   ` Eric Van Hensbergen [this message]
2015-04-12 12:42     ` Eric Van Hensbergen
2015-04-12 14:09     ` Al Viro
2015-04-12 19:08       ` Eric Van Hensbergen
2015-04-13  8:27     ` [V9fs-developer] " Dominique Martinet
2015-04-13  8:27       ` [Qemu-devel] " Dominique Martinet
2015-04-13 16:05       ` Eric Van Hensbergen
2015-04-13 16:05         ` [Qemu-devel] " Eric Van Hensbergen
2015-04-14 16:07         ` Al Viro
2015-04-14 16:07           ` Al Viro
2015-04-14 16:19           ` Eric Van Hensbergen
2015-04-14 16:19             ` [Qemu-devel] " Eric Van Hensbergen
2015-04-14 21:44             ` Al Viro
2015-04-14 21:44               ` Al Viro
2015-04-15 11:28         ` Dominique Martinet
2015-04-15 11:28           ` [Qemu-devel] " Dominique Martinet
2015-04-15 14:17           ` Eric Van Hensbergen
2015-04-15 14:17             ` [Qemu-devel] " Eric Van Hensbergen
2015-04-12 12:45 ` [Qemu-devel] " Eric Van Hensbergen
2016-05-05 20:54 ` Server Angels
2016-05-25 11:14   ` Greg Kurz
2016-05-25 11:51     ` Sean Keeney
2016-05-05 21:01 ` Server Angels
2016-05-24 14:43 ` Launchpad Bug Tracker
2016-06-02 11:59 ` Greg Kurz
2016-06-25  8:25 ` Greg Kurz
2016-06-25  9:24 ` Greg Kurz
2017-08-04  6:03 ` Maxim Kuvyrkov
2017-08-04  8:00 ` Greg Kurz
2018-11-26 21:47 ` Alexander Gretha
2018-11-27  8:07 ` Greg Kurz
2018-11-28 21:20 ` Alexander Gretha
2020-05-26 11:58 ` Greg Kurz
2020-05-27  6:03 ` Greg Kurz
2020-12-10  8:47 ` Thomas Huth
2020-12-10 11:48 ` Thomas Huth
2021-05-03 16:40 ` Thomas Huth

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='CAFkjPTm1gbHiRJqvWj74=T1Bs0KfiEb2xiN9F69EVHkHA8vn=g@mail.gmail.com' \
    --to=ericvh@gmail.com \
    --cc=1336794@bugs.launchpad.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.