Commit graph

16 commits

Author SHA1 Message Date
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
Thomas Faber 303f17f884
[FASTFAT] Implement the overflow queue. CORE-17344 CORE-17328
This avoids blocking all Ex worker threads in fastfat, thereby making Cc
unable to issue the lazy writes that would unblock those workers.
This is more or less directly taken from fastfat_new.
2020-10-24 19:53:36 +02:00
Stanislav Motylkov 06d5ed7ece
[FASTFAT] Support 64 KiB cluster sizes
FAT16 filesystem was not recognized on some 4GB USB flash drives.
This change makes them just work.

References:
- https://chat.reactos.org/reactos/pl/h83pm5ngkffk7qiyrmqnaaopxh
- https://support.microsoft.com/en-us/help/140365/default-cluster-size-for-ntfs-fat-and-exfat

CORE-16511
2020-07-22 19:50:24 +03:00
Hermès Bélusca-Maïto b77824a375 [FASTFAT] Improvements for volume dismount + minor bugfixing.
- Cache the RootFcb so that its cleanup can be handled separately
  during dismounting.

- Force volume dismount at cleanup if the VCB_DISMOUNT_PENDING flag
  is set.

- Actually dismount a volume if its VCB has been flagged as not good,
  or if we force dismounting.

NOTE: In their *CheckForDismount() function, our 3rd-party FS drivers
as well as MS' fastfat, perform a comparison check of the current VCB's
VPB ReferenceCount with some sort of "dangling"/"residual" open count.
It seems to be related to the fact that the volume root directory as
well as auxiliary data stream(s) are still opened, and only these are
allowed to be opened at that moment. After analysis it appears that for
the ReactOS' fastfat, this number is equal to "3".

- On dismounting, cleanup and destroy the RootFcb, VolumeFcb and the
  FATFileObject. Then cleanup the SpareVPB or the IoVPB members, and
  finish by removing the dismounted volume from the VolumeListEntry
  and cleaning up the notify synchronization object and the resources.

- During dismounting, and on shutdown, flush the volume before
  resetting its dirty bit.

- On shutdown, after volume flushing, try to unmount it without forcing.

- Release the VCB resources only when we actually dismount the volume
  in VfatCheckForDismount().

- Initialize first the notify list and the synchronization object,
  before sending the FSRTL_VOLUME_MOUNT notification.

- If we failed at mounting a volume but its VCB's FATFileObject was
  already initialized, first call CcUninitializeCacheMap() on it
  before dereferencing it.

- Send FSRTL_VOLUME_LOCK, FSRTL_VOLUME_LOCK_FAILED and
  FSRTL_VOLUME_UNLOCK notifications during volume locking (and failure)
  and volume unlocking.

- Flush the volume before locking it, and clean its dirty bit if needed.

NOTE: In addition to checking for VCB_CLEAR_DIRTY, we also check for the
presence of the VCB_IS_DIRTY flag before cleaning up the dirty bit: this
allows us to not re-clean the bit if it has been previously cleaned.
This is needed for instance in this scenario:
- The volume is locked (it gets flushed and the dirty bit is possibly cleared);
- The volume then gets formatted with a completely different FS, that
  possibly clears up the first sector (e.g. BTRFS ignores 1st sector);
- The volume is then dismounted: if we didn't check whether VCB_IS_DIRTY
  was set prior to resetting it, we could attempt clearing it again! But
  now that the volume's filesystem has been completely changed, we would
  then try to modify the dirty bit on an erroneous position on disk!
  That's why it should not be touched in this case during dismounting.
- The volume is unlocked (same comment as above), and later can be
  detected as being BTRFS.
2018-11-25 09:00:40 +01:00
Hermès Bélusca-Maïto 8c0c90112e
[FASTFAT] Don't mess my debug log when partition SysType is printed! (when invalid chars are printed) 2018-10-13 19:57:24 +02:00
Pierre Schweitzer 4bb1baa860
[FASTFAT] Finally drop the TAG_VFAT allocation tag 2018-08-21 08:36:51 +02:00
Pierre Schweitzer 047479e0a2
[FASTFAT] Don't leak statistics on dismount 2018-08-18 19:03:30 +02:00
Pierre Schweitzer 639e6d635f
[FASTFAT] Reduce the usage of the generic allocation tag
And use tag compatible with MS FastFAT, to use debug with WinDBG
2018-08-18 19:03:30 +02:00
Pierre Schweitzer 6aa4beeefb
[FASTFAT] Use the FastFAT mechanism for counting clusters already implemented
This allows us having more accurate statistics regarding available clusters
count. Even though FastFAT and chkdsk still don't agree!

CORE-3877
2018-06-09 18:23:07 +02:00
Pierre Schweitzer 04640f9264
[FASTFAT] Save the FSINFO sector location 2018-06-09 12:11:43 +02:00
Pierre Schweitzer 7c01587680
[FASTFAT] Completely rewrite support for dirty volumes.
Until now, our support for dirty volumes was totally broken
to a point where, on FAT32 volume, the dirty couldn't even
be written nor read from the disk.

This commit totally rewrites its handling, for both FAT16 and FAT32
so that it's now fully functionnal. Furthermore, it also gets
totally compatible with our vfatlib, and thus, autochk.
Now, on mount, FastFAT will check if the volume is dirty or not, and
autochk will be able to ask for a repair if dirty. vfatlib will
repair the volume and remove the dirty bit. So that, on next
reboot, the volume will be mounted clean.

As a reminder, the dirty bit is set immediately after mounting
the volume, so that, if you crash or have a powercut, autochk
will always attempt to repair your volume (with more or less,
that's FAT!).

If you want to experience without breaking your FAT volume,
just boot, open a cmd prompt and type: fsutil dirty set c:
and reboot!

CORE-13758
CORE-13760
CORE-13759
2018-05-18 23:05:05 +02:00
Pierre Schweitzer efa75dd5b2
[FASTFAT] Allow locking system volume on boot.
This is a hack, and totally not the default behavior.
But it will allow autochk locking the boot volume in
order to verify it on boot, in case it would have
been improperly dismounted.

CORE-13759
2018-05-18 23:05:05 +02:00
Pierre Schweitzer d37280efaa
[FASTFAT] Deny dismounting system volume or a volume with a pagefile 2018-05-16 21:45:35 +02:00
Pierre Schweitzer 64bc96558e
[FASTFAT] While closing FCBs on dismount, release from tail to head and not the contrary.
It fixes assertion failure in vfatDestroyFCB() where we would have release parent before child.
This is still not perfect, but less bug prone...

With this commits (and ENABLE_SWAPOUT defined), ReactOS seems to unmount FAT volumes quite nice! :-)
(Tried with fsutil volume dismount X:)
2017-12-17 18:24:01 +01:00
Pierre Schweitzer 27773dbb3f
[FASTFAT] When not able to lock a volume due to open handles, print open handles 2017-12-17 18:24:01 +01:00
Colin Finck c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
Renamed from reactos/drivers/filesystems/fastfat/fsctl.c (Browse further)