From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.32258.1585208066963607856 for ; Thu, 26 Mar 2020 00:34:27 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: christopher.j.zurcher@intel.com) IronPort-SDR: lyd8KwB/G/p/ITcL0avWcMmq22ALlBAFqFCPP3yMtP/PNTHteLjX/9rJl2Skx6mC/9KtuUfBF7 4GqAzT+ybiEA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2020 00:34:26 -0700 IronPort-SDR: 7uHum6uLHodQSO1ESiyoC//juCx/zykeTblY/2/HS3ReLgvikaGPL2twnOKxMUufNDZMz8Ycb6 T2ECuYIkjYkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,307,1580803200"; d="scan'208";a="393889984" Received: from cjzurch-desk.amr.corp.intel.com ([10.9.70.181]) by orsmga004.jf.intel.com with ESMTP; 26 Mar 2020 00:34:25 -0700 From: "Zurcher, Christopher J" To: devel@edk2.groups.io Cc: Michael D Kinney , Jian J Wang , Liming Gao , Zhiguang Liu Subject: [PATCH v2 0/1] UefiScsiLib: Set FUA bit for synchronous SCSI Write operations Date: Thu, 26 Mar 2020 00:34:23 -0700 Message-Id: <20200326073424.69960-1-christopher.j.zurcher@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 V2 changes: Add bit defines for cache control parameters from SBC-2. 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 Cc: Zhiguang Liu Christopher J Zurcher (1): MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations MdePkg/Include/IndustryStandard/Scsi.h | 8 +++++++- MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) -- 2.16.2.windows.1