Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Tom Talpey <tom@talpey.com>
To: "Pali Rohár" <pali@kernel.org>
Cc: Steve French <sfrench@samba.org>,
	Paulo Alcantara <pc@manguebit.com>,
	Namjae Jeon <linkinjeon@kernel.org>,
	linux-cifs@vger.kernel.org
Subject: Re: SMB2 DELETE vs UNLINK
Date: Fri, 27 Dec 2024 11:43:58 -0500	[thread overview]
Message-ID: <749690fc-4647-487b-ba21-d208d72f754e@talpey.com> (raw)
In-Reply-To: <20241227163202.ihp3cxmhe2sehxoh@pali>

On 12/27/2024 11:32 AM, Pali Rohár wrote:
> On Friday 27 December 2024 11:21:49 Tom Talpey wrote:
>> On 12/25/2024 9:47 AM, Pali Rohár wrote:
>>> On Sunday 06 October 2024 12:31:27 Pali Rohár wrote:
>>>> Hello,
>>>>
>>>> Windows NT systems and SMB2 protocol support only DELETE operation which
>>>> unlinks file from the directory after the last client/process closes the
>>>> opened handle.
>>>>
>>>> So when file is opened by more client/processes and somebody wants to
>>>> unlink that file, it stay in the directory until the last client/process
>>>> stop using it.
>>>>
>>>> This DELETE operation can be issued either by CLOSE request on handle
>>>> opened by DELETE_ON_CLOSE flag, or by SET_INFO request with class 13
>>>> (FileDispositionInformation) and with set DeletePending flag.
>>>>
>>>>
>>>> But starting with Windows 10, version 1709, there is support also for
>>>> UNLINK operation, via class 64 (FileDispositionInformationEx) [1] where
>>>> is FILE_DISPOSITION_POSIX_SEMANTICS flag [2] which does UNLINK after
>>>> CLOSE and let file content usable for all other processes. Internally
>>>> Windows NT kernel moves this file on NTFS from its directory into some
>>>> hidden are. Which is de-facto same as what is POSIX unlink. There is
>>>> also class 65 (FileRenameInformationEx) which is allows to issue POSIX
>>>> rename (unlink the target if it exists).
>>>>
>>>> What do you think about using & implementing this functionality for the
>>>> Linux unlink operation? As the class numbers are already reserved and
>>>> documented, I think that it could make sense to use them also over SMB
>>>> on POSIX systems.
>>>>
>>>>
>>>> Also there is another flag FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
>>>> which can be useful for unlink. It allows to unlink also file which has
>>>> read-only attribute set. So no need to do that racy (unset-readonly,
>>>> set-delete-pending, set-read-only) compound on files with more file
>>>> hardlinks.
>>>>
>>>> I think that this is something which SMB3 POSIX extensions can use and
>>>> do not have to invent new extensions for the same functionality.
>>>>
>>>>
>>>> [1] - https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ne-wdm-_file_information_class
>>>> [2] - https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-_file_disposition_information_ex
>>>> [3] - https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_rename_information
>>>
>>> And now I figured out that struct FILE_FS_ATTRIBUTE_INFORMATION which
>>> has member FileSystemAttributes contains new documented bit:
>>>
>>> 0x00000400 - FILE_SUPPORTS_POSIX_UNLINK_RENAME
>>> The file system supports POSIX-style delete and rename operations.
>>>
>>> See Windows NT spec:
>>> https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_fs_attribute_information
>>>
>>> Interesting is that this struct FILE_FS_ATTRIBUTE_INFORMATION is
>>> available over SMB protocol too but bit value 0x00000400 is not
>>> documented in [MS-FSCC] section 2.5.1 FileFsAttributeInformation:
>>> https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/ebc7e6e5-4650-4e54-b17c-cf60f6fbeeaa
>>>
>>> So it really looks like that POSIX unlink is prepared for SMB, just is
>>> not documented or implemented in Windows yet.
>>>
>>> Maybe somebody could ask Microsoft documentation team for more details?
>> We absolutely should do this, if the bit is visible remotely then it's
>> an obvious omission. If it can be set remotely, even better.
> 
> Now I check that Windows Server 2022 via both SMB3.1.1 FileFsAttributeInformation
> and via SMB1 QUERY_FS_INFO/FS_ATTRIBUTES announce the 0x00000400 bit for
> FILE_SUPPORTS_POSIX_UNLINK_RENAME.
> 
> See other email in this tread, I was able to send POSIX UNLINK as
> FILE_DISPOSITION_POSIX_SEMANTICS via SMB1, but not over SMB3.1.1
> (but it is possible that I did it in wrong way).
> 
>> Feel free to raise the issue yourself! Simply email "dochelp@microsoft.com".
>> Send as much supporting evidence as you have gathered.
>>
>> Tom.
> 
> Ok. I can do it. Should I include somebody else into copy?

Sure, you may include me, tell them I sent you. :)

Tom.


  reply	other threads:[~2024-12-27 16:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-06 10:31 SMB2 DELETE vs UNLINK Pali Rohár
2024-10-07  4:18 ` Steve French
2024-10-07 18:48   ` Pali Rohár
2024-10-08  0:07     ` Steve French
2024-10-08  9:40 ` Ralph Boehme
2024-10-08 18:18   ` Pali Rohár
2024-10-08 20:16     ` Ralph Boehme
2024-10-09  5:03     ` Steve French
2024-10-14  9:49       ` Pali Rohár
2024-12-27 15:58         ` Pali Rohár
2024-12-27 16:30           ` Tom Talpey
2024-12-25 14:47 ` Pali Rohár
2024-12-27 16:21   ` Tom Talpey
2024-12-27 16:32     ` Pali Rohár
2024-12-27 16:43       ` Tom Talpey [this message]
2024-12-27 18:51         ` Pali Rohár
2025-04-08 22:43           ` Pali Rohár
2025-04-09  6:50             ` Fwd: " Ralph Boehme
2025-04-09 15:57               ` [EXTERNAL] Fwd: SMB2 DELETE vs UNLINK - TrackingID#2504090040009564 Michael Bowen
2025-04-10  5:57                 ` Tom Talpey
2025-04-10 11:07                 ` Obaid Farooqi
2025-05-06 19:00                   ` Obaid Farooqi
2025-08-31 12:55                     ` Pali Rohár

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=749690fc-4647-487b-ba21-d208d72f754e@talpey.com \
    --to=tom@talpey.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=pc@manguebit.com \
    --cc=sfrench@samba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox