maharmstone / btrfs

WinBtrfs - an open-source btrfs driver for Windows
GNU Lesser General Public License v3.0
5.8k stars 222 forks source link

Remounting BTRFS file system requires a reboot (after a successful dismount) #665

Open sskras opened 3 months ago

sskras commented 3 months ago

(everything CLI done from the elevated MSYS2 environment in this report)

I have a spare partition formatted to NTFS and mounted as E:.


saukrs@DESKTOP-O7JE7JE MSYS ~
$ wmic volume where "DriveLetter = 'E:'" get Capacity,DeviceId,DriveLetter,FileSystem,Label
Capacity      DeviceID                                           DriveLetter  FileSystem  Label
244047671296  \\?\Volume{b653c32e-f770-4464-a9aa-d04dc6425286}\  E:           NTFS        skirsnis

saukrs@DESKTOP-O7JE7JE MSYS ~
$ wmic volume where "DeviceID LIKE '_%{b653c32e-f770-4464-a9aa-d04dc6425286}_%'" get Capacity,DeviceId,DriveLetter,FileSystem,Label
Capacity      DeviceID                                           DriveLetter  FileSystem  Label
244047671296  \\?\Volume{b653c32e-f770-4464-a9aa-d04dc6425286}\  E:           NTFS        skirsnis
I can dismount it and then remount it successfully.

- dismounting NTFS volume is OK: ```sh saukrs@DESKTOP-O7JE7JE MSYS ~ $ mountvol E: /P The volume is still in use. A force dismount was issued and current handles to the volume have been invalidated. saukrs@DESKTOP-O7JE7JE MSYS ~ $ wmic volume where "DeviceID LIKE '_%{b653c32e-f770-4464-a9aa-d04dc6425286}_%'" get Capacity,DeviceId,DriveLetter,FileSystem,Label Capacity DeviceID DriveLetter FileSystem Label \\?\Volume{b653c32e-f770-4464-a9aa-d04dc6425286}\ ``` - remounting NTFS volume is OK: ```sh saukrs@DESKTOP-O7JE7JE MSYS ~ $ mountvol E: '\\?\Volume{b653c32e-f770-4464-a9aa-d04dc6425286}\' saukrs@DESKTOP-O7JE7JE MSYS ~ $ wmic volume where "DeviceID LIKE '_%{b653c32e-f770-4464-a9aa-d04dc6425286}_%'" get Capacity,DeviceId,DriveLetter,FileSystem,Label Capacity DeviceID DriveLetter FileSystem Label 244047671296 \\?\Volume{b653c32e-f770-4464-a9aa-d04dc6425286}\ E: NTFS skirsnis saukrs@DESKTOP-O7JE7JE MSYS ~ $ cmd /c dir /s E: Volume in drive E is skirsnis Volume Serial Number is 66F6-8D31 Directory of E:\System Volume Information 11/06/2024 10:42 76 IndexerVolumeGuid 11/06/2024 10:42 12 WPSettings.dat 2 File(s) 88 bytes Total Files Listed: 2 File(s) 88 bytes 0 Dir(s) 243,940,261,888 bytes free ```

But if I format it to Btrfs ...

```sh saukrs@DESKTOP-O7JE7JE MSYS ~ $ wmic volume where "DeviceID LIKE '_%{b653c32e-f770-4464-a9aa-d04dc6425286}_%'" get Capacity,DeviceId,DriveLetter,FileSystem,Label Capacity DeviceID DriveLetter FileSystem Label 244047671296 \\?\Volume{b653c32e-f770-4464-a9aa-d04dc6425286}\ E: NTFS skirsnis saukrs@DESKTOP-O7JE7JE MSYS ~ $ format.com E: /q /fs:btrfs The type of the file system is NTFS. The new file system is BTRFS. Enter current volume label for drive E: skirsnis WARNING, ALL DATA ON NON-REMOVABLE DISK DRIVE E: WILL BE LOST! Proceed with Format (Y/N)? Y QuickFormatting 227.3 GB Format cannot run because the volume is in use by another process. Format may run if this volume is dismounted first. ALL OPENED HANDLES TO THIS VOLUME WOULD THEN BE INVALID. Would you like to force a dismount on this volume? (Y/N) Y Volume dismounted. All opened handles to this volume are now invalid. BitLocker encryption and the encrypted data on the volume has been removed. You may enable BitLocker again after formatting is complete. saukrs@DESKTOP-O7JE7JE MSYS ~ $ wmic volume where "DriveLetter = 'E:'" get Capacity,DeviceId,DriveLetter,FileSystem,Label Capacity DeviceID DriveLetter FileSystem Label 244047675392 \\?\Volume{0869fa25-bd66-7074-6498-7f4d08d64db0}\ E: Btrfs ``` (please note the changed volume UUID)

.... this sequence breaks,

saukrs@DESKTOP-O7JE7JE MSYS ~
$ mountvol E: /P

saukrs@DESKTOP-O7JE7JE MSYS ~
$ wmic volume where "DeviceID LIKE '_%{0869fa25-bd66-7074-6498-7f4d08d64db0}_%'" get Capacity,DeviceId,DriveLetter,FileSystem,Label
Capacity  DeviceID                                           DriveLetter  FileSystem  Label
          \\?\Volume{0869fa25-bd66-7074-6498-7f4d08d64db0}\
saukrs@DESKTOP-O7JE7JE MSYS ~
$ mountvol E: '\\?\Volume{0869fa25-bd66-7074-6498-7f4d08d64db0}\'

saukrs@DESKTOP-O7JE7JE MSYS ~
$ wmic volume where "DeviceID LIKE '_%{0869fa25-bd66-7074-6498-7f4d08d64db0}_%'" get Capacity,DeviceId,DriveLetter,FileSystem,Label
Capacity  DeviceID                                           DriveLetter  FileSystem  Label
          \\?\Volume{0869fa25-bd66-7074-6498-7f4d08d64db0}\

saukrs@DESKTOP-O7JE7JE MSYS ~
$ cmd /c dir /s E:
The device is not ready.

The result I see in File Explorer:

BTRFS-ghost-drive-letter-after-volume-dismount-v2


Looks like WinBtrfs doesn't receive / fails to handle some mounting request.

sskras commented 3 months ago

Now if I try to reformat it to NTFS, this fails too:

saukrs@DESKTOP-O7JE7JE MSYS ~
$ format.com E: /q /fs:ntfs
The type of the file system is RAW.
The new file system is NTFS.

WARNING, ALL DATA ON NON-REMOVABLE DISK
DRIVE E: WILL BE LOST!
Proceed with Format (Y/N)? Y
QuickFormatting 227.3 GB
Volume label (32 characters, ENTER for none)? ntfs-vol
Creating file system structures.
Incorrect write at offset 0x0 for 0x20000 bytes but wrote 0x0 bytes.
Format failed.
Incorrect write at offset 0x3221225472 for 0x4000 bytes but wrote 0x0 bytes.
Incorrect write at offset 0x244047671296 for 0x1000 bytes but wrote 0x0 bytes.
Format failed.

But that might already be an issue of Windows itself, not related to WinBtrfs.

sskras commented 3 months ago

Of course, after I reboot the OS, the file system is back:

saukrs@DESKTOP-O7JE7JE MSYS ~
$ systeminfo | grep -i boot
System Boot Time:          11/06/2024, 12:40:38
Boot Device:               \Device\HarddiskVolume3

saukrs@DESKTOP-O7JE7JE MSYS ~
$ wmic volume where "DeviceID LIKE '_%{0869fa25-bd66-7074-6498-7f4d08d64db0}_%'" get Capacity,DeviceId,DriveLetter,FileSystem,Label
Capacity      DeviceID                                           DriveLetter  FileSystem  Label
244047675392  \\?\Volume{0869fa25-bd66-7074-6498-7f4d08d64db0}\  E:           Btrfs

saukrs@DESKTOP-O7JE7JE MSYS ~
$ cmd /c dir /a /s E:
 Volume in drive E has no label.
 Volume Serial Number is 08D6-4DB0

 Directory of E:\

11/06/2024  11:57    <DIR>          System Volume Information
               0 File(s)             62 bytes

     Total Files Listed:
               0 File(s)             62 bytes
               1 Dir(s)  244,047,036,416 bytes free
sskras commented 3 months ago

Now if I try dismounting + remounting Btrfs volume again, my w10 crashes with NO_MORE_IRP_STACK_LOCATIONS: 061124-14437-01.dmp