From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.1997.1582337513724814393 for ; Fri, 21 Feb 2020 18:11:54 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: christopher.j.zurcher@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2020 18:11:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,470,1574150400"; d="scan'208";a="270202770" Received: from cjzurch-desk.amr.corp.intel.com ([10.9.70.181]) by fmsmga002.fm.intel.com with ESMTP; 21 Feb 2020 18:11:53 -0800 From: "Zurcher, Christopher J" To: devel@edk2.groups.io Cc: Michael D Kinney , Jian J Wang , Liming Gao Subject: [PATCH 0/1] UefiScsiLib: Set FUA bit for synchronous SCSI Write operations Date: Fri, 21 Feb 2020 18:11:51 -0800 Message-Id: <20200222021152.23016-1-christopher.j.zurcher@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Some SCSI devices have very aggressive write caching implemented, causing data to be lost if the system is shut down or rebooted soon after receiving a successful write confirmation from the device. By setting the FUA bit in the synchronous versions of the Write10/Write16 commands, the write cache is skipped and data is forced directly to the disk. The Asynchronous (WriteEx) commands will not have this bit set, allowing performance-sensitive transactions to continue utilizing the write cache. An alternative, more complicated solution would be to implement the SYNCHRONIZE CACHE command and call it from ScsiDiskFlushBlocks, which currently returns EFI_SUCCESS without flushing anything. Since the SYNCHRONIZE CACHE command requires the caller to provide the specific blocks to flush, and the BlockIO FlushBlocks function does not accept any arguments, this would require keeping track of the write history inside the ScsiDiskDxe driver. I have not tested the asynchronous commands for this issue, so there is a chance that resetting the system even after a call to FlushBlocksEx might still result in lost data. Currently the ScsiDiskFlushBlocksEx command waits for the BlockIo2 requests queue to empty, but does not ask the device itself to flush anything. (EFI_SCSI_OP_SYNC_CACHE is defined in IndustryStandard/Scsi.h but is not implemented anywhere.) Cc: Michael D Kinney Cc: Jian J Wang Cc: Liming Gao Christopher J Zurcher (1): MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.16.2.windows.1