From: "Pali Rohár" <pali@kernel.org>
To: ronnie sahlberg <ronniesahlberg@gmail.com>
Cc: Steve French <smfrench@gmail.com>,
CIFS <linux-cifs@vger.kernel.org>, Tom Talpey <tom@talpey.com>,
samba-technical <samba-technical@lists.samba.org>
Subject: Re: Handling deleted files which are still open on the Linux client
Date: Thu, 10 Apr 2025 18:07:40 +0200 [thread overview]
Message-ID: <20250410160740.nxad4kqwikhsp7xt@pali> (raw)
In-Reply-To: <CAN05THQGpzKTLXzFh8sc=h=rFQACBgFDhSzqNacrOp-50vGSOA@mail.gmail.com>
On Thursday 10 April 2025 16:18:17 ronnie sahlberg wrote:
> On Wed, 9 Apr 2025 at 23:14, Steve French via samba-technical <
> samba-technical@lists.samba.org> wrote:
>
> > There was a suggestion (see attached patch) to change how we report
> > errors on a file which is deleted (usually by the same Linux client)
> > but still open (so "STATUS_DELETE_PENDING" if another process or
> > client tries to open it). It can be confusing when an open file is
> > deleted to see it in "ls" output (until the file is closed and removed
> > from the namespace). This is not an issue when using the SMB3.1.1
> > POSIX/Linux extensions but if the server were e.g. Windows it can be
> > confusing.
> >
> > Currently we return "ENOENT" which is more accurate (since the file
> > should not be displayed in directory listings, and attempts to open
> > such a file should fail in order to obey POSIX/Linux semantics), but
> > the suggestion in attached patch is to change that to "EBUSY" which
> > may imply that the file will be accessible in the future (which in
> > POSIX/Linux would not be the case so could be confusing).
> >
> > There may be better ways to handle this as well (e.g. simply filter
> > out from query dir responses any files which we know are in delete
> > pending state - since one common scenario is getting this error when
> > doing an ls of a directory which contains an open file which has been
> > deleted).
> >
>
> This is an area where it is impossible to match semantics exactly because
> the semantics are just different.
>
> Filtering the readdir results feels like the wrong thing to do. It is just
> trading one
> bad experience for another.
> For example, if it is filtered out and a client tries to create a new file
> with the same
> filename, should they see "EEXIST"?
> According to readdir() the object does not exist but if you try to create
> it you can't because EEXIST.
Exactly, this is another case where the filtering or returning ENOENT is
causing problems.
> IMHO the least bad option is probably to let the object show up in
> readdir() but
> return an error to applications that want to operate on it.
> Maybe consiider such files as having the same behaviour as a "chattr +i"
> file that has mode 0000
> and can not be opened for reading neither data not attributes.
This is what I already suggested. To return EBUSY from open(), instead
of ENOENT. Some other suggestions which I receive was to return ESTALE.
>
>
> >
> > One of my concerns is that with this change "stat
> > /mnt/deleted-but-still-open-file" could return EBUSY which implies the
> > filename still exists (which violates the whole point of delete in
> > POSIX), and a simpler fix is to just make sure we don't show any files
> > (e.g. in readdir) in delete pending state and make sure their dentries
> > are gone.
> >
> > Any thoughts?
> >
> >
> > --
> > Thanks,
> >
> > Steve
> >
prev parent reply other threads:[~2025-04-10 16:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 13:13 Handling deleted files which are still open on the Linux client Steve French
2025-04-09 13:51 ` Pali Rohár
2025-04-10 5:54 ` Tom Talpey
[not found] ` <CAN05THQGpzKTLXzFh8sc=h=rFQACBgFDhSzqNacrOp-50vGSOA@mail.gmail.com>
2025-04-10 16:07 ` Pali Rohár [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=20250410160740.nxad4kqwikhsp7xt@pali \
--to=pali@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=smfrench@gmail.com \
--cc=tom@talpey.com \
/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