scsi: scsi_dh_alua: prevent duplicate pg info print in alua_rtpg()
PATCH 1/1 scsi: scsi_dh_alua: prevent duplicate pg info print in alua_rtpg()
Due to the frequency that alua_rtpg() is called, the path group info print within can print the same info multiple times in the logs, subsequent prints adding no new information or value.
To reproduce:
# modprobe scsi_debug vpd_use_hostno=0
# systemctl start multipathd.serviceTo fix, check stored values, only printing at alua attach/activate and if any of the values change.
--- drivers/scsi/device_handler/scsi_dh_alua.c | 30 ++++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +19 -11
@@ -515,6 +515,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)struct scsi_sense_hdr sense_hdr;struct alua_port_group *tmp_pg;int len, k, off, bufflen =ALUA_RTPG_SIZE ; +int group_id_old, state_old, pref_old, valid_states_old;unsigned char *desc, *buff;unsigned err, retval;unsigned int tpg_desc_tbl_off;
@@ -522,6 +523,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)unsigned long flags;bool transitioning_sense = false; + group_id_old = pg->group_id; + state_old = pg->state; + pref_old = pg->pref; + valid_states_old = pg->valid_states; +if (!pg->expiry) {unsigned long transition_tmo =ALUA_FAILOVER_TIMEOUT *HZ ;
@@ -686,17 +692,19 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)if (transitioning_sense) pg->state =SCSI_ACCESS_STATE_TRANSITIONING ; -sdev_printk (KERN_INFO , sdev, -"%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n" , -ALUA_DH_NAME , pg->group_id,print_alua_state (pg->state), - pg->pref ?"preferred" :"non-preferred" , - pg->valid_states&TPGS_SUPPORT_TRANSITION ?'T' :'t' , - pg->valid_states&TPGS_SUPPORT_OFFLINE ?'O' :'o' , - pg->valid_states&TPGS_SUPPORT_LBA_DEPENDENT ?'L' :'l' , - pg->valid_states&TPGS_SUPPORT_UNAVAILABLE ?'U' :'u' , - pg->valid_states&TPGS_SUPPORT_STANDBY ?'S' :'s' , - pg->valid_states&TPGS_SUPPORT_NONOPTIMIZED ?'N' :'n' , - pg->valid_states&TPGS_SUPPORT_OPTIMIZED ?'A' :'a' ); +if (group_id_old != pg->group_id || state_old != pg->state || + pref_old != pg->pref || valid_states_old != pg->valid_states) +sdev_printk (KERN_INFO , sdev, +"%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n" , +ALUA_DH_NAME , pg->group_id,print_alua_state (pg->state), + pg->pref ?"preferred" :"non-preferred" , + pg->valid_states&TPGS_SUPPORT_TRANSITION ?'T' :'t' , + pg->valid_states&TPGS_SUPPORT_OFFLINE ?'O' :'o' , + pg->valid_states&TPGS_SUPPORT_LBA_DEPENDENT ?'L' :'l' , + pg->valid_states&TPGS_SUPPORT_UNAVAILABLE ?'U' :'u' , + pg->valid_states&TPGS_SUPPORT_STANDBY ?'S' :'s' , + pg->valid_states&TPGS_SUPPORT_NONOPTIMIZED ?'N' :'n' , + pg->valid_states&TPGS_SUPPORT_OPTIMIZED ?'A' :'a' );switch (pg->state) {case SCSI_ACCESS_STATE_TRANSITIONING :
Signature · 1 line
2.17.2
Quoted 88 lines · John Pittman
Due to the frequency that
alua_rtpg()is called, the path group info print within can print the same info multiple times in the logs, subsequent prints adding no new information or value.To reproduce:
# modprobe scsi_debug vpd_use_hostno=0 # systemctl start multipathd.serviceTo fix, check stored values, only printing at alua attach/activate and if any of the values change.
Signed-off-by John Pittman <[email protected]>Reviewed-by David Jeffery <[email protected]>--- drivers/scsi/device_handler/scsi_dh_alua.c | 30 ++++++++++++++---- ---- 1 file changed, 19 insertions(+), 11 deletions(-)drivers/scsi/device_handler/scsi_dh_alua.c +1
-0@@ -515,6 +515,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)struct scsi_sense_hdr sense_hdr;struct alua_port_group *tmp_pg;int len, k, off, bufflen =ALUA_RTPG_SIZE ; +int group_id_old, state_old, pref_old, valid_states_old;unsigned char *desc, *buff;unsigned err, retval;drivers/scsi/device_handler/scsi_dh_alua.c +5
-0unsigned int tpg_desc_tbl_off;@@ -522,6 +523,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)unsigned long flags;bool transitioning_sense = false; + group_id_old = pg->group_id; + state_old = pg->state; + pref_old = pg->pref; + valid_states_old = pg->valid_states; +if (!pg->expiry) { unsigned long transition_tmo = ALUA_FAILOVER_TIMEOUT *HZ;
drivers/scsi/device_handler/scsi_dh_alua.c +2
-11@@ -686,17 +692,19 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)if (transitioning_sense) pg->state =SCSI_ACCESS_STATE_TRANSITIONING ; -sdev_printk (KERN_INFO , sdev, - "%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n", - ALUA_DH_NAME, pg->group_id, print_alua_state(pg- >state), - pg->pref ?"preferred" :"non-preferred" , - pg->valid_states&TPGS_SUPPORT_TRANSITION ?'T' :'t' , - pg->valid_states&TPGS_SUPPORT_OFFLINE ?'O' :'o' , - pg- >valid_states&TPGS_SUPPORT_LBA_DEPENDENT?'L':'l', - pg->valid_states&TPGS_SUPPORT_UNAVAILABLE ?'U' :'u' , - pg->valid_states&TPGS_SUPPORT_STANDBY ?'S' :'s' , - pg->valid_states&TPGS_SUPPORT_NONOPTIMIZED ?'N' :'n' , - pg->valid_states&TPGS_SUPPORT_OPTIMIZED ?'A' :'a' ); + if (group_id_old != pg->group_id || state_old != pg->state || + pref_old != pg->pref || valid_states_old != pg-Quoted 1 line
valid_states)drivers/scsi/device_handler/scsi_dh_alua.c +2
-0+ sdev_printk(KERN_INFO, sdev, + "%s: port group %02x state %c %s supports%c%c%c%c%c%c%c\n",
drivers/scsi/device_handler/scsi_dh_alua.c +1
-0+ ALUA_DH_NAME, pg->group_id,
print_alua_state(pg->state),drivers/scsi/device_handler/scsi_dh_alua.c +2
-0+ pg->pref ?"preferred" :"non-preferred" , + pg-Quoted 1 line
valid_states&TPGS_SUPPORT_TRANSITION?'T':'t',
drivers/scsi/device_handler/scsi_dh_alua.c +2
-0+ pg->valid_states&TPGS_SUPPORT_OFFLINE ?'O' :'o' , + pg-Quoted 1 line
valid_states&TPGS_SUPPORT_LBA_DEPENDENT?'L':'l',
drivers/scsi/device_handler/scsi_dh_alua.c +1
-0+ pg-Quoted 1 line
valid_states&TPGS_SUPPORT_UNAVAILABLE?'U':'u',
drivers/scsi/device_handler/scsi_dh_alua.c +2
-0+ pg->valid_states&TPGS_SUPPORT_STANDBY ?'S' :'s' , + pg-Quoted 1 line
valid_states&TPGS_SUPPORT_NONOPTIMIZED?'N':'n',
drivers/scsi/device_handler/scsi_dh_alua.c +1
-0+ pg-Quoted 1 line
valid_states&TPGS_SUPPORT_OPTIMIZED?'A':'a');
drivers/scsi/device_handler/scsi_dh_alua.c static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) · line 710
Quoted 2 lines
drivers/scsi/device_handler/scsi_dh_alua.c +0
-0switch (pg->state) {case SCSI_ACCESS_STATE_TRANSITIONING :
Thanks John
I am still trying to find a way to quiet the SCSI discovery in an acceptable way but every bit helps.
Martin K. Petersen
AppliedQuoted 10 lines · John Pittman
Due to the frequency that
alua_rtpg()is called, the path group info print within can print the same info multiple times in the logs, subsequent prints adding no new information or value.To reproduce:
# modprobe scsi_debug vpd_use_hostno=0 # systemctl start multipathd.service[...]
Applied to 5.13/scsi-queue, thanks!
[1/1] scsi: scsi_dh_alua: prevent duplicate pg info print in alua_rtpg()
https://git.kernel.org/mkp/scsi/c/22ec513e7057
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering