diff mbox series

[v2,1/2] scsi: core: Introduce the BLIST_BROKEN_FUA flag

Message ID 20230202220041.560919-2-bvanassche@acm.org
State New
Headers show
Series Use SYNCHRONIZE CACHE instead of FUA for UFS devices | expand

Commit Message

Bart Van Assche Feb. 2, 2023, 10 p.m. UTC
UFS devices perform better when using SYNCHRONIZE CACHE command instead of
the FUA flag. Introduce the BLIST_BROKEN_FUA flag for using SYNCHRONIZE
CACHE instead of FUA.

The BLIST_BROKEN_FUA flag can be set by using one of the following
approaches:
* From user space, by writing into /proc/scsi/device_info.
* From the kernel, by setting sdev_bflags from the slave_alloc callback.

For a prior version of this patch, see also
https://lore.kernel.org/lkml/YpecaXfIxZBHIcfj@google.com/T/

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_scan.c    | 3 +++
 include/scsi/scsi_devinfo.h | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Bart Van Assche May 5, 2023, 8:36 p.m. UTC | #1
On 2/2/23 14:00, Bart Van Assche wrote:
> UFS devices perform better when using SYNCHRONIZE CACHE command instead of
> the FUA flag. Introduce the BLIST_BROKEN_FUA flag for using SYNCHRONIZE
> CACHE instead of FUA.
> 
> The BLIST_BROKEN_FUA flag can be set by using one of the following
> approaches:
> * From user space, by writing into /proc/scsi/device_info.
> * From the kernel, by setting sdev_bflags from the slave_alloc callback.
> 
> For a prior version of this patch, see also
> https://lore.kernel.org/lkml/YpecaXfIxZBHIcfj@google.com/T/
> 
> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
> Cc: Asutosh Das <quic_asutoshd@quicinc.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/scsi_scan.c    | 3 +++
>   include/scsi/scsi_devinfo.h | 4 +++-
>   2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index a62925355c2c..c1eb6bfe7ed2 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -1020,6 +1020,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
>   	if (*bflags & BLIST_NO_RSOC)
>   		sdev->no_report_opcodes = 1;
>   
> +	if (*bflags & BLIST_BROKEN_FUA)
> +		sdev->broken_fua = 1;
> +
>   	/* set the device running here so that slave configure
>   	 * may do I/O */
>   	mutex_lock(&sdev->state_mutex);
> diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
> index 5d14adae21c7..783451dfa46e 100644
> --- a/include/scsi/scsi_devinfo.h
> +++ b/include/scsi/scsi_devinfo.h
> @@ -68,8 +68,10 @@
>   #define BLIST_RETRY_ITF		((__force blist_flags_t)(1ULL << 32))
>   /* Always retry ABORTED_COMMAND with ASC 0xc1 */
>   #define BLIST_RETRY_ASC_C1	((__force blist_flags_t)(1ULL << 33))
> +/* Use SYNCHRONIZE CACHE instead of FUA */
> +#define BLIST_BROKEN_FUA	((__force blist_flags_t)(1ULL << 34))
>   
> -#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1
> +#define __BLIST_LAST_USED BLIST_BROKEN_FUA
>   
>   #define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \
>   			       (__force blist_flags_t) \

(replying to an email from two months ago)

I plan to repost the above patch because this patch will allow us to set the
broken_fua flag from user space. Please let me know if there are any objections
or concerns.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index a62925355c2c..c1eb6bfe7ed2 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1020,6 +1020,9 @@  static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	if (*bflags & BLIST_NO_RSOC)
 		sdev->no_report_opcodes = 1;
 
+	if (*bflags & BLIST_BROKEN_FUA)
+		sdev->broken_fua = 1;
+
 	/* set the device running here so that slave configure
 	 * may do I/O */
 	mutex_lock(&sdev->state_mutex);
diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index 5d14adae21c7..783451dfa46e 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -68,8 +68,10 @@ 
 #define BLIST_RETRY_ITF		((__force blist_flags_t)(1ULL << 32))
 /* Always retry ABORTED_COMMAND with ASC 0xc1 */
 #define BLIST_RETRY_ASC_C1	((__force blist_flags_t)(1ULL << 33))
+/* Use SYNCHRONIZE CACHE instead of FUA */
+#define BLIST_BROKEN_FUA	((__force blist_flags_t)(1ULL << 34))
 
-#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1
+#define __BLIST_LAST_USED BLIST_BROKEN_FUA
 
 #define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \
 			       (__force blist_flags_t) \