public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* FUSE passthrough: fd lifetime?
@ 2024-08-27  9:41 Han-Wen Nienhuys
  2024-08-27 13:48 ` Amir Goldstein
  2024-08-27 17:04 ` Josef Bacik
  0 siblings, 2 replies; 14+ messages in thread
From: Han-Wen Nienhuys @ 2024-08-27  9:41 UTC (permalink / raw)
  To: linux-fsdevel

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?

-- 
Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-08-28 11:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox