From: Josef Bacik <josef@toxicpanda.com>
To: Han-Wen Nienhuys <hanwenn@gmail.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: FUSE passthrough: fd lifetime?
Date: Tue, 27 Aug 2024 13:04:58 -0400 [thread overview]
Message-ID: <20240827170458.GD2466167@perftesting> (raw)
In-Reply-To: <CAOw_e7bB3C_zbpq6U+FdrjbwJAOKFJk1ZLLETrR+5xqRmv44SQ@mail.gmail.com>
On Tue, Aug 27, 2024 at 11:41:04AM +0200, Han-Wen Nienhuys wrote:
> Hi folks,
>
> I am implementing passthrough support for go-fuse. It seems to be
> working now (code:
> https://review.gerrithub.io/c/hanwen/go-fuse/+/1199984 and
> predecessors), but I am unsure of the correct lifetimes for the file
> descriptors.
>
> The passthrough_hp example seems to do:
>
> Open:
> backing_fd = ..
> backing_id = ioctl(fuse_device_fd,
> FUSE_DEV_IOC_BACKING_OPEN, backing_fd)
>
> Release:
> ioctl(fuse_device_fd,
> FUSE_DEV_IOC_BACKING_CLOSE, backing_id)
> close(backing_fd)
>
> Is it necessary to keep backing_fd open while the backing file is
> used? In the case of go-fuse, the backing_fd is managed by client
> code, so I can't ensure it is kept open long enough. I can work around
> this by doing
>
> Open:
> new_backing_fd = ioctl(backing_fd, DUP_FD, 0)
> backing_id = ioctl(fuse_device_fd,
> FUSE_DEV_IOC_BACKING_OPEN, new_backing_fd)
>
> Release:
> ioctl(fuse_device_fd,
> FUSE_DEV_IOC_BACKING_CLOSE, backing_id)
> close(new_backing_fd)
>
> but it would double the number of FDs the process uses.
>
> I tried simply closing the backing FD right after obtaining the
> backing ID, and it seems to work. Is this permitted?
Yes that's permitted, we're holding a reference to the file in the kernel. The
dup thing works too, but as you say that's a lot more fd's. Thanks,
Josef
prev parent reply other threads:[~2024-08-27 17:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 9:41 FUSE passthrough: fd lifetime? Han-Wen Nienhuys
2024-08-27 13:48 ` Amir Goldstein
2024-08-27 15:32 ` Han-Wen Nienhuys
2024-08-27 15:41 ` Han-Wen Nienhuys
2024-08-27 17:34 ` Amir Goldstein
2024-08-27 19:31 ` Han-Wen Nienhuys
2024-08-27 19:02 ` Antonio SJ Musumeci
2024-08-28 10:00 ` Han-Wen Nienhuys
2024-08-28 10:05 ` Amir Goldstein
2024-08-28 10:33 ` Han-Wen Nienhuys
2024-08-28 10:47 ` Amir Goldstein
2024-08-28 11:02 ` Han-Wen Nienhuys
2024-08-28 11:53 ` Amir Goldstein
2024-08-27 17:04 ` Josef Bacik [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=20240827170458.GD2466167@perftesting \
--to=josef@toxicpanda.com \
--cc=hanwenn@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
/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.