Rename scsi_get_lba() into scsi_get_pos()
Subsystems (9)
cover Rename scsi_get_lba() into scsi_get_pos()
Hi Martin,
This patch series renames scsi_get_lba() into scsi_get_pos(). The name of scsi_get_lba() is confusing since it does not return an LBA but instead the start offset divided by 512.
Please consider this patch series for kernel v5.14.
Thanks,
Bart.
Bart Van Assche (7):
Introduce scsi_get_pos()
iser: Use scsi_get_pos() instead of scsi_get_lba()
zfcp: Use scsi_get_pos() instead of scsi_get_lba()
iscsi: Use scsi_get_pos() instead of scsi_get_lba()
qla2xxx: Use scsi_get_pos() instead of scsi_get_lba()
ufs: Fix the tracing code
Remove scsi_get_lba()
drivers/infiniband/ulp/iser/iser_verbs.c | 2 +- drivers/s390/scsi/zfcp_fsf.c | 2 +- drivers/scsi/isci/request.c | 4 ++-- drivers/scsi/lpfc/lpfc_scsi.c | 12 ++++++------ drivers/scsi/qla2xxx/qla_iocb.c | 9 +++------ drivers/scsi/qla2xxx/qla_isr.c | 8 ++++---- drivers/scsi/ufs/ufshcd.c | 20 +++++++------------- include/scsi/scsi_cmnd.h | 2 +- include/trace/events/ufs.h | 10 +++++----- 9 files changed, 30 insertions(+), 39 deletions(-)
PATCH 1/7 Introduce scsi_get_pos()
Since scsi_get_lba() returns a sector_t value instead of the LBA, the name of that function is confusing. Introduce an identical function scsi_get_pos(). A later patch will remove scsi_get_lba().
--- include/scsi/scsi_cmnd.h | 5 +++++ 1 file changed, 5 insertions(+)
include/scsi/scsi_cmnd.h +5 -0
@@ -290,6 +290,11 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)return blk_rq_pos (scmd->request); } +static inline sector_t scsi_get_pos (struct scsi_cmnd *scmd) +{ +return blk_rq_pos (scmd->request); +} +static inline unsigned int scsi_prot_interval (struct scsi_cmnd *scmd) {return scmd->device->sector_size;
PATCH 2/7 iser: Use scsi_get_pos() instead of scsi_get_lba()
In reply to Bart Van AsscheUse scsi_get_pos() instead of scsi_get_lba() since the name of the latter is confusing. This patch does not change any functionality.
--- drivers/infiniband/ulp/iser/iser_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/iser/iser_verbs.c +1 -1
@@ -949,7 +949,7 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task,sector_t sector_off = mr_status.sig_err.sig_err_offset;sector_div (sector_off, sector_size +8 ); - *sector =scsi_get_lba (iser_task->sc) + sector_off; + *sector =scsi_get_pos (iser_task->sc) + sector_off; iser_err("PI error found type %d at sector %llx " "expected %x vs actual %x\n",
PATCH 3/7 zfcp: Use scsi_get_pos() instead of scsi_get_lba()
In reply to Bart Van AsscheUse scsi_get_pos() instead of scsi_get_lba() since the name of the latter is confusing. Additionally, use lower_32_bits() instead of open-coding it. This patch does not change any functionality.
--- drivers/s390/scsi/zfcp_fsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/scsi/zfcp_fsf.c +1 -1
@@ -2600,7 +2600,7 @@ int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd)if (scsi_get_prot_op (scsi_cmnd) !=SCSI_PROT_NORMAL ) { io->data_block_length = scsi_cmnd->device->sector_size; - io->ref_tag_value =scsi_get_lba (scsi_cmnd) &0xFFFFFFFF ; + io->ref_tag_value =lower_32_bits (scsi_get_pos (scsi_cmnd)); }if (zfcp_fsf_set_data_dir (scsi_cmnd, &io->data_direction))
PATCH 4/7 iscsi: Use scsi_get_pos() instead of scsi_get_lba()
In reply to Bart Van AsscheUse scsi_get_pos() instead of scsi_get_lba() since the name of the latter is confusing. Additionally, use lower_32_bits() instead of open-coding it. This patch does not change any functionality.
--- drivers/scsi/isci/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/isci/request.c +2 -2
@@ -341,7 +341,7 @@ static void scu_ssp_ireq_dif_insert(struct isci_request *ireq, u8 type, u8 op) tc->reserved_E8_0 =0 ;if ((type &SCSI_PROT_DIF_TYPE1 ) || (type &SCSI_PROT_DIF_TYPE2 )) - tc->ref_tag_seed_gen =scsi_get_lba (scmd) &0xffffffff ; + tc->ref_tag_seed_gen =lower_32_bits (scsi_get_pos (scmd));else if (type &SCSI_PROT_DIF_TYPE3 ) tc->ref_tag_seed_gen =0 ; }
@@ -369,7 +369,7 @@ static void scu_ssp_ireq_dif_strip(struct isci_request *ireq, u8 type, u8 op) tc->app_tag_gen =0 ;if ((type &SCSI_PROT_DIF_TYPE1 ) || (type &SCSI_PROT_DIF_TYPE2 )) - tc->ref_tag_seed_verify =scsi_get_lba (scmd) &0xffffffff ; + tc->ref_tag_seed_verify =lower_32_bits (scsi_get_pos (scmd));else if (type &SCSI_PROT_DIF_TYPE3 ) tc->ref_tag_seed_verify =0 ;
Re: [PATCH 4/7] iscsi: Use scsi_get_pos() instead of scsi_get_lba()
Quoted 25 lines · Bart Van Assche
Use
scsi_get_pos()instead ofscsi_get_lba()since the name of the latter is confusing. Additionally, uselower_32_bits()instead of open-coding it. This patch does not change any functionality.Cc Lee Duncan <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/isci/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/isci/request.c +1
-1@@ -341,7 +341,7 @@ static void scu_ssp_ireq_dif_insert(struct isci_request *ireq, u8 type, u8 op) tc->reserved_E8_0 =0 ;if ((type &SCSI_PROT_DIF_TYPE1 ) || (type &SCSI_PROT_DIF_TYPE2 )) - tc->ref_tag_seed_gen =scsi_get_lba (scmd) &0xffffffff ; + tc->ref_tag_seed_gen =lower_32_bits (scsi_get_pos (scmd));else if (type &SCSI_PROT_DIF_TYPE3 ) tc->ref_tag_seed_gen =0 ; }
drivers/scsi/isci/request.c static void scu_ssp_ireq_dif_strip(struct isci_request *ireq, u8 type, u8 op) · line 375
Quoted 8 lines
drivers/scsi/isci/request.c +1
-1@@ -369,7 +369,7 @@ static void scu_ssp_ireq_dif_strip(struct isci_request *ireq, u8 type, u8 op) tc->app_tag_gen =0 ;if ((type &SCSI_PROT_DIF_TYPE1 ) || (type &SCSI_PROT_DIF_TYPE2 )) - tc->ref_tag_seed_verify =scsi_get_lba (scmd) &0xffffffff ; + tc->ref_tag_seed_verify =lower_32_bits (scsi_get_pos (scmd));else if (type &SCSI_PROT_DIF_TYPE3 ) tc->ref_tag_seed_verify =0 ;
PATCH 5/7 qla2xxx: Use scsi_get_pos() instead of scsi_get_lba()
In reply to Bart Van AsscheUse scsi_get_pos() instead of scsi_get_lba() since the name of the latter is confusing. Additionally, use lower_32_bits() instead of open-coding it. This patch does not change any functionality.
--- drivers/scsi/lpfc/lpfc_scsi.c | 12 ++++++------ drivers/scsi/qla2xxx/qla_iocb.c | 9 +++------ drivers/scsi/qla2xxx/qla_isr.c | 8 ++++---- 3 files changed, 13 insertions(+), 16 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +6 -6
@@ -2963,7 +2963,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"9059 BLKGRD: Guard Tag error in cmd" " 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], - (unsigned long long )scsi_get_lba (cmd), + (u64 )scsi_get_pos (cmd), blk_rq_sectors(cmd->request), bgstat, bghm); }
@@ -2980,7 +2980,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"9060 BLKGRD: Ref Tag error in cmd" " 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], - (unsigned long long )scsi_get_lba (cmd), + (u64 )scsi_get_pos (cmd), blk_rq_sectors(cmd->request), bgstat, bghm); }
@@ -2997,7 +2997,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"9062 BLKGRD: App Tag error in cmd" " 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], - (unsigned long long )scsi_get_lba (cmd), + (u64 )scsi_get_pos (cmd), blk_rq_sectors(cmd->request), bgstat, bghm); }
@@ -3028,7 +3028,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,break ; } - failing_sector =scsi_get_lba (cmd); + failing_sector =scsi_get_pos (cmd); failing_sector += bghm;/* Descriptor Information */
@@ -3041,7 +3041,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"9068 BLKGRD: Unknown error in cmd" " 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], - (unsigned long long )scsi_get_lba (cmd), + (u64 )scsi_get_pos (cmd), blk_rq_sectors(cmd->request), bgstat, bghm);/* Calcuate what type of error it was */
@@ -3174,7 +3174,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,break ; } - failing_sector =scsi_get_lba (cmd); + failing_sector =scsi_get_pos (cmd); failing_sector += bghm;/* Descriptor Information */
drivers/scsi/qla2xxx/qla_iocb.c +3 -6
@@ -778,8 +778,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,* No check for ql2xenablehba_err_chk, as it would be an * I/O error if hba tag generation is not done. */ - pkt->ref_tag =cpu_to_le32 ((uint32_t ) - (0xffffffff &scsi_get_lba (cmd))); + pkt->ref_tag =cpu_to_le32 (lower_32_bits (scsi_get_pos (cmd)));if (!qla2x00_hba_err_chk_enabled (sp))break ;
@@ -799,8 +798,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt, pkt->app_tag_mask[0 ] =0x0 ; pkt->app_tag_mask[1 ] =0x0 ; - pkt->ref_tag =cpu_to_le32 ((uint32_t ) - (0xffffffff &scsi_get_lba (cmd))); + pkt->ref_tag =cpu_to_le32 (lower_32_bits (scsi_get_pos (cmd)));if (!qla2x00_hba_err_chk_enabled (sp))break ;
@@ -824,8 +822,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,* 16 bit app tag. */ case SCSI_PROT_DIF_TYPE1 : - pkt->ref_tag =cpu_to_le32 ((uint32_t ) - (0xffffffff &scsi_get_lba (cmd))); + pkt->ref_tag =cpu_to_le32 (lower_32_bits (scsi_get_pos (cmd))); pkt->app_tag =cpu_to_le16 (0 ); pkt->app_tag_mask[0 ] =0x0 ; pkt->app_tag_mask[1 ] =0x0 ;
drivers/scsi/qla2xxx/qla_isr.c +4 -4
@@ -2632,7 +2632,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)"DIF ERROR in cmd 0x%x lba 0x%llx act ref" " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app" " tag=0x%x, act guard=0x%x, exp guard=0x%x.\n" , - cmd->cmnd[0 ], (u64 )scsi_get_lba (cmd), a_ref_tag, e_ref_tag, + cmd->cmnd[0 ], (u64 )scsi_get_pos (cmd), a_ref_tag, e_ref_tag, a_app_tag, e_app_tag, a_guard, e_guard);/*
@@ -2644,10 +2644,10 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) (scsi_get_prot_type(cmd) != SCSI_PROT_DIF_TYPE3 || a_ref_tag == be32_to_cpu(T10_PI_REF_ESCAPE))) {uint32_t blocks_done, resid; -sector_t lba_s =scsi_get_lba (cmd); +sector_t pos =scsi_get_pos (cmd);/* 2TB boundary case covered automatically with this */ - blocks_done = e_ref_tag - (uint32_t )lba_s +1 ; + blocks_done = e_ref_tag - (uint32_t )pos +1 ; resid =scsi_bufflen (cmd) - (blocks_done * cmd->device->sector_size);
@@ -2677,7 +2677,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)if (k != blocks_done) {ql_log (ql_log_warn, vha,0x302f ,"unexpected tag values tag:lba=%x:%llx)\n" , - e_ref_tag, (unsigned long long )lba_s); + e_ref_tag, (u64 )pos);return 1 ; }
PATCH 6/7 ufs: Fix the tracing code
In reply to Bart Van AsscheUse scsi_get_pos() instead of scsi_get_lba() since the name of the latter is confusing. Use scsi_get_pos() for all SCSI requests since all SCSI requests have a block layer request attached and hence calling scsi_get_pos() is allowed. Convert the scsi_get_pos() result from sector_t into an LBA with sectors_to_logical(). Since both READ(10) and WRITE(10) have a GROUP NUMBER field, extract the GROUP NUMBER field for both types of commands. Apply the 0x3f mask to that field since the upper two bits are reserved. Rename the 'transfer_len' variable into 'affected_bytes' since it represents the number of bytes affected on the storage medium instead of the size of the SCSI data buffer.
--- drivers/scsi/ufs/ufshcd.c | 20 +++++++------------- include/trace/events/ufs.h | 10 +++++----- 2 files changed, 12 insertions(+), 18 deletions(-)
drivers/scsi/ufs/ufshcd.c +7 -13
@@ -16,6 +16,8 @@#include <linux/bitfield.h> #include <linux/blk-pm.h> #include <linux/blkdev.h> +#include <scsi/scsi_cmnd.h> +#include "../sd.h" #include "ufshcd.h" #include "ufs_quirks.h" #include "unipro.h"
@@ -366,7 +368,7 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag,u32 intr, doorbell;struct ufshcd_lrb *lrbp = &hba->lrb[tag];struct scsi_cmnd *cmd = lrbp->cmd; -int transfer_len =-1 ; +int affected_bytes =-1 ;if (!trace_ufshcd_command_enabled ()) {/* trace UPIU W/O tracing command */
@@ -378,30 +380,22 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag,if (cmd) {/* data phase exists */ /* trace UPIU also */ ufshcd_add_cmd_upiu_trace (hba, tag, str_t); + lba =sectors_to_logical (cmd->device,scsi_get_pos (cmd)); + affected_bytes =blk_rq_bytes (cmd->request); opcode = cmd->cmnd[0 ];if ((opcode ==READ_10 ) || (opcode ==WRITE_10 )) {/* * Currently we only fully trace read(10) and write(10) * commands */ -if (cmd->request && cmd->request->bio) - lba = cmd->request->bio->bi_iter.bi_sector; - transfer_len =be32_to_cpu ( - lrbp->ucd_req_ptr->sc.exp_data_transfer_len); -if (opcode ==WRITE_10 ) - group_id = lrbp->cmd->cmnd[6 ]; - }else if (opcode ==UNMAP ) { -if (cmd->request) { - lba =scsi_get_lba (cmd); - transfer_len =blk_rq_bytes (cmd->request); - } + group_id = lrbp->cmd->cmnd[6 ] &0x3f ; } } intr =ufshcd_readl (hba,REG_INTERRUPT_STATUS ); doorbell =ufshcd_readl (hba,REG_UTP_TRANSFER_REQ_DOOR_BELL );trace_ufshcd_command (dev_name (hba->dev), str_t, tag, - doorbell, transfer_len, intr, lba, opcode, group_id); + doorbell, affected_bytes, intr, lba, opcode, group_id); }static void ufshcd_print_clk_freqs (struct ufs_hba *hba)
include/trace/events/ufs.h +5 -5
@@ -248,10 +248,10 @@ DEFINE_EVENT(ufshcd_template, ufshcd_init, TRACE_EVENT(ufshcd_command, TP_PROTO(const char *dev_name, enum ufs_trace_str_t str_t, - unsigned int tag, u32 doorbell, int transfer_len, u32 intr, + unsigned int tag, u32 doorbell, int affected_bytes, u32 intr, u64 lba, u8 opcode, u8 group_id), - TP_ARGS(dev_name, str_t, tag, doorbell, transfer_len, + TP_ARGS(dev_name, str_t, tag, doorbell, affected_bytes, intr, lba, opcode, group_id), TP_STRUCT__entry(
@@ -259,7 +259,7 @@ TRACE_EVENT(ufshcd_command, __field(enum ufs_trace_str_t, str_t) __field(unsigned int, tag) __field(u32, doorbell) - __field(int, transfer_len) + __field(int, affected_bytes) __field(u32, intr) __field(u64, lba) __field(u8, opcode)
@@ -271,7 +271,7 @@ TRACE_EVENT(ufshcd_command, __entry->str_t = str_t; __entry->tag = tag; __entry->doorbell = doorbell; - __entry->transfer_len = transfer_len; + __entry->affected_bytes = affected_bytes; __entry->intr = intr; __entry->lba = lba; __entry->opcode = opcode;
@@ -281,7 +281,7 @@ TRACE_EVENT(ufshcd_command,TP_printk ("%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x (%s), group_id: 0x%x" ,show_ufs_cmd_trace_str (__entry->str_t),__get_str (dev_name), - __entry->tag, __entry->doorbell, __entry->transfer_len, + __entry->tag, __entry->doorbell, __entry->affected_bytes, __entry->intr, __entry->lba, (u32 )__entry->opcode,str_opcode (__entry->opcode), (u32 )__entry->group_id )
PATCH 7/7 Remove scsi_get_lba()
In reply to Bart Van AsscheRemove scsi_get_lba() since all callers have been converted to scsi_get_pos().
--- include/scsi/scsi_cmnd.h | 5 ----- 1 file changed, 5 deletions(-)
include/scsi/scsi_cmnd.h +0 -5
@@ -285,11 +285,6 @@ static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd)return scmd->prot_type; } -static inline sector_t scsi_get_lba (struct scsi_cmnd *scmd) -{ -return blk_rq_pos (scmd->request); -} -static inline sector_t scsi_get_pos (struct scsi_cmnd *scmd) {return blk_rq_pos (scmd->request);