linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: The 8472 <kernel@infinite-source.de>
To: Antonio SJ Musumeci <trapexit@spawn.link>,
	The 8472 <kernel@infinite-source.de>,
	linux-fsdevel@vger.kernel.org
Subject: Re: EBADF returned from close() by FUSE
Date: Fri, 19 Apr 2024 20:18:54 +0200	[thread overview]
Message-ID: <ff9b490d-421f-4092-8497-84f545a47e6a@infinite-source.de> (raw)
In-Reply-To: <8c7552b1-f371-4a75-98cc-f2c89816becb@spawn.link>

On 19-04-2024 13:42, Antonio SJ Musumeci wrote:
> On 4/19/24 01:55, The 8472 wrote:
>> On 19-04-2024 05:30, Antonio SJ Musumeci wrote:
>>> I can't see how the kernel could meaningfully know of or limit errors
>>> coming from the FUSE server without compromising the nature of the
>>> technology. So in that sense... yes, it is intentional.
>> File descriptor numbers are not a FUSE-managed resource, so I was hoping
>> it would reserve error codes that are documented to signal incorrect
>> access to that resource and convert external errors to another code (e.g. EIO).
>> This would then signal that the file descriptor itself was valid but the underlying
>> resource encountered an error while performing the operation.
> Anything can be a FUSE managed resource by proxy. [...]

I'm referring to the slots in the file descriptor table of a process (A) that is opening
a file on a FUSE filesystem. Whether a slot (FD number) is occupied or not
is between the kernel and that process, not the server (S).
Imo the kernel should only return EBADF when the process accesses an FD
that is not in its table, which tends to be a fatal error in multithreaded
programs.

If S internally accesses invalid file descriptors that has no
bearing on the state of the FD table of A. From A's perspective
some sort of IO error occurred in the underlying storage system
while releasing the FD, but it did use a valid file descriptor.

> [...] There are a number of
> situations where FUSE itself return errors but the largest surface area
> for errors are from the FUSE server. And the server needs the ability to
> return nearly anything.

I'm not talking about what the server is allowed to return. I'm referring
to which errors from the server get bubbled up verbatim through syscalls on
files that are a FUSE mount.
Is it necessary to pass through arbitrary FUSE errors, especially EBADF,
when a processes closes a file that's backed by fuse?

This shouldn't happen:

|openat(AT_FDCWD, "./fuse-test/foo", O_RDONLY|O_CLOEXEC) = 5 close(5) = -1 EBADF (Bad file descriptor)|

> Errnos are not *really* standard. They vary by
> kernel release, different OSes, different libcs, different filesystems,
> etc. As I pointed out recently to someone the use of EPERM to mean a
> filesystem doesn't support "link" is not defined everywhere. Including
> POSIX IIRC. And given FUSE is a cross platform protocol it shouldn't,
> within reason, be interpreting any errors sent from the server (IMO).

FUSE can send any errnos it wants over its client-server protocol.
But the kernel could still translate them to error codes that don't
have a documented meaning for a specific syscall.


  parent reply	other threads:[~2024-04-19 18:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18 22:10 EBADF returned from close() by FUSE The 8472
2024-04-19  3:30 ` Antonio SJ Musumeci
2024-04-19  6:55   ` The 8472
     [not found]     ` <8c7552b1-f371-4a75-98cc-f2c89816becb@spawn.link>
2024-04-19 18:18       ` The 8472 [this message]
2024-04-19 20:07         ` Antonio SJ Musumeci
2024-04-19 20:45           ` The 8472
2024-04-19 21:29             ` Antonio SJ Musumeci
2024-04-19 22:04               ` The 8472
2024-04-19 22:47                 ` Antonio SJ Musumeci
2024-04-19 23:04                   ` The 8472
2024-04-23 12:46                     ` Miklos Szeredi
2024-04-23 13:24                       ` Antonio SJ Musumeci
2024-04-23 13:38                         ` Miklos Szeredi
     [not found]                           ` <692a9f0b-9c2b-4850-b8bc-48f09fe41762@infinite-source.de>
2024-04-23 21:38                             ` The 8472
2024-04-26  8:52                               ` Miklos Szeredi

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=ff9b490d-421f-4092-8497-84f545a47e6a@infinite-source.de \
    --to=kernel@infinite-source.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=trapexit@spawn.link \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).