Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 3ef6a71ed186d1e8e44c26c24a1cbea5533e3554
      
https://github.com/tianocore/edk2/commit/3ef6a71ed186d1e8e44c26c24a1cbea5533e3554
  Author: Oliver Smith-Denny <o...@linux.microsoft.com>
  Date:   2024-09-23 (Mon, 23 Sep 2024)

  Changed paths:
    M FatPkg/EnhancedFatDxe/Init.c

  Log Message:
  -----------
  FatPkg: Check BlockIo Device Has Supported BlockSize

Per the FAT spec, FAT32 supports block sizes of 512B, 1KB, 2KB, or 4KB.
This patch adds a check to the FAT driver initialization to ensure that
the underlying BlockIo device supports one of those block sizes and fails
initialization otherwise. The underlying BlockIo blocksize is used when
we flush the FatDiskCache back to disk and if the block size is an
unsupported size, we could cause file corruption.

Signed-off-by: Oliver Smith-Denny <o...@linux.microsoft.com>


  Commit: a131839a3db7f933f51efc6c13d5986d7f09eab3
      
https://github.com/tianocore/edk2/commit/a131839a3db7f933f51efc6c13d5986d7f09eab3
  Author: Mike Turner <mike...@microsoft.com>
  Date:   2024-09-23 (Mon, 23 Sep 2024)

  Changed paths:
    M FatPkg/EnhancedFatDxe/DiskCache.c
    M FatPkg/EnhancedFatDxe/Fat.h
    M FatPkg/EnhancedFatDxe/Init.c
    M FatPkg/FatPkg.ci.yaml

  Log Message:
  -----------
  FatPkg: Improvements to Fat to Fix File Corruption

This patch improves dirty bit checking in FAT and coalesces multiple
writes to adjacent blocks into a single write.

For good read performance, the Fat code caches 64KB lines from the
file system. Any update to the data will force 64KB writes. Writing
the full 64KB causes collateral blocks (i.e. blocks belonging to
other files) to be written. This is inefficient to write blocks that
are not dirty, the FAT driver should only be writing blocks that have
actually been updated through its cache.

This also resolves an issue with existing bootloaders which have ways
to update files outside of the FAT code and the collateral write can
corrupt those files. One such file is the Windows BCD that gets updated
outside of the FAT code and has been seen to be corrupted by the
collateral writes, causing the OS to fail to boot.

This fix keeps track of physical disk block (LBA) size and will only
mark LBA size zones of the 64KB cache line that are written to. When the
file is closed and the cached data is written, only the dirty LBAs are
written, which avoids the collateral write and therefore the corruption.
In addition, adjacent LBAs will be coalesced into one write for
performance considerations.

Signed-off-by: Oliver Smith-Denny <o...@linux.microsoft.com>


Compare: https://github.com/tianocore/edk2/compare/4c3bffaeb3cf...a131839a3db7

To unsubscribe from these emails, change your notification settings at 
https://github.com/tianocore/edk2/settings/notifications


_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to