Revision: 14005
          http://edk2.svn.sourceforge.net/edk2/?rev=14005&view=rev
Author:   lzeng14
Date:     2012-12-17 03:18:16 +0000 (Mon, 17 Dec 2012)
Log Message:
-----------
Reclaim work space when the remaining space size is even not enough to contain 
one header + one record.

Signed-off-by: Star Zeng <[email protected]>
Reviewed-by: Liming Gao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c

Modified: 
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
===================================================================
--- 
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c    
    2012-12-17 03:17:36 UTC (rev 14004)
+++ 
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c    
    2012-12-17 03:18:16 UTC (rev 14005)
@@ -166,6 +166,7 @@
 {
   EFI_STATUS                      Status;
   UINTN                           Length;
+  UINTN                           RemainingSpaceSize;
 
   //
   // Initialize WorkSpace as FTW_ERASED_BYTE
@@ -198,7 +199,15 @@
             FtwDevice->FtwWorkSpaceSize,
             &FtwDevice->FtwLastWriteHeader
             );
-  if (EFI_ERROR (Status)) {
+  RemainingSpaceSize = FtwDevice->FtwWorkSpaceSize - ((UINTN) 
FtwDevice->FtwLastWriteHeader - (UINTN) FtwDevice->FtwWorkSpace);
+  DEBUG ((EFI_D_INFO, "Ftw: Remaining work space size - %x\n", 
RemainingSpaceSize));
+  //
+  // If FtwGetLastWriteHeader() returns error, or the remaining space size is 
even not enough to contain
+  // one EFI_FAULT_TOLERANT_WRITE_HEADER + one 
EFI_FAULT_TOLERANT_WRITE_RECORD(It will cause that the header
+  // pointed by FtwDevice->FtwLastWriteHeader or record pointed by 
FtwDevice->FtwLastWriteRecord may contain invalid data),
+  // it needs to reclaim work space.
+  //
+  if (EFI_ERROR (Status) || RemainingSpaceSize < sizeof 
(EFI_FAULT_TOLERANT_WRITE_HEADER) + sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD)) {
     //
     // reclaim work space in working block.
     //

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to