@@ -1508,8 +1508,8 @@ static int pqi_get_raid_map(struct pqi_ctrl_info *ctrl_info,
15081508 if (rc )
15091509 goto error ;
15101510
1511- device -> raid_bypass_cnt = alloc_percpu (u64 );
1512- if (!device -> raid_bypass_cnt ) {
1511+ device -> raid_io_stats = alloc_percpu (struct pqi_raid_io_stats );
1512+ if (!device -> raid_io_stats ) {
15131513 rc = - ENOMEM ;
15141514 goto error ;
15151515 }
@@ -2105,9 +2105,9 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
21052105 /* To prevent this from being freed later. */
21062106 new_device -> raid_map = NULL ;
21072107 }
2108- if (new_device -> raid_bypass_enabled && existing_device -> raid_bypass_cnt == NULL ) {
2109- existing_device -> raid_bypass_cnt = new_device -> raid_bypass_cnt ;
2110- new_device -> raid_bypass_cnt = NULL ;
2108+ if (new_device -> raid_bypass_enabled && existing_device -> raid_io_stats == NULL ) {
2109+ existing_device -> raid_io_stats = new_device -> raid_io_stats ;
2110+ new_device -> raid_io_stats = NULL ;
21112111 }
21122112 existing_device -> raid_bypass_configured = new_device -> raid_bypass_configured ;
21132113 existing_device -> raid_bypass_enabled = new_device -> raid_bypass_enabled ;
@@ -2131,7 +2131,7 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
21312131static inline void pqi_free_device (struct pqi_scsi_dev * device )
21322132{
21332133 if (device ) {
2134- free_percpu (device -> raid_bypass_cnt );
2134+ free_percpu (device -> raid_io_stats );
21352135 kfree (device -> raid_map );
21362136 kfree (device );
21372137 }
@@ -5984,6 +5984,7 @@ static bool pqi_is_parity_write_stream(struct pqi_ctrl_info *ctrl_info,
59845984 pqi_stream_data -> next_lba = rmd .first_block +
59855985 rmd .block_cnt ;
59865986 pqi_stream_data -> last_accessed = jiffies ;
5987+ per_cpu_ptr (device -> raid_io_stats , smp_processor_id ())-> write_stream_cnt ++ ;
59875988 return true;
59885989 }
59895990
@@ -6016,7 +6017,6 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scm
60166017 u16 hw_queue ;
60176018 struct pqi_queue_group * queue_group ;
60186019 bool raid_bypassed ;
6019- u64 * raid_bypass_cnt ;
60206020 u8 lun ;
60216021
60226022 scmd -> host_scribble = PQI_NO_COMPLETION ;
@@ -6063,8 +6063,7 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scm
60636063 rc = pqi_raid_bypass_submit_scsi_cmd (ctrl_info , device , scmd , queue_group );
60646064 if (rc == 0 || rc == SCSI_MLQUEUE_HOST_BUSY ) {
60656065 raid_bypassed = true;
6066- raid_bypass_cnt = per_cpu_ptr (device -> raid_bypass_cnt , smp_processor_id ());
6067- (* raid_bypass_cnt )++ ;
6066+ per_cpu_ptr (device -> raid_io_stats , smp_processor_id ())-> raid_bypass_cnt ++ ;
60686067 }
60696068 }
60706069 if (!raid_bypassed )
@@ -7363,7 +7362,6 @@ static ssize_t pqi_raid_bypass_cnt_show(struct device *dev,
73637362 unsigned long flags ;
73647363 u64 raid_bypass_cnt ;
73657364 int cpu ;
7366- u64 * per_cpu_bypass_cnt_ptr ;
73677365
73687366 sdev = to_scsi_device (dev );
73697367 ctrl_info = shost_to_hba (sdev -> host );
@@ -7381,10 +7379,9 @@ static ssize_t pqi_raid_bypass_cnt_show(struct device *dev,
73817379
73827380 raid_bypass_cnt = 0 ;
73837381
7384- if (device -> raid_bypass_cnt ) {
7382+ if (device -> raid_io_stats ) {
73857383 for_each_online_cpu (cpu ) {
7386- per_cpu_bypass_cnt_ptr = per_cpu_ptr (device -> raid_bypass_cnt , cpu );
7387- raid_bypass_cnt += * per_cpu_bypass_cnt_ptr ;
7384+ raid_bypass_cnt += per_cpu_ptr (device -> raid_io_stats , cpu )-> raid_bypass_cnt ;
73887385 }
73897386 }
73907387
@@ -7472,6 +7469,43 @@ static ssize_t pqi_numa_node_show(struct device *dev,
74727469 return scnprintf (buffer , PAGE_SIZE , "%d\n" , ctrl_info -> numa_node );
74737470}
74747471
7472+ static ssize_t pqi_write_stream_cnt_show (struct device * dev ,
7473+ struct device_attribute * attr , char * buffer )
7474+ {
7475+ struct pqi_ctrl_info * ctrl_info ;
7476+ struct scsi_device * sdev ;
7477+ struct pqi_scsi_dev * device ;
7478+ unsigned long flags ;
7479+ u64 write_stream_cnt ;
7480+ int cpu ;
7481+
7482+ sdev = to_scsi_device (dev );
7483+ ctrl_info = shost_to_hba (sdev -> host );
7484+
7485+ if (pqi_ctrl_offline (ctrl_info ))
7486+ return - ENODEV ;
7487+
7488+ spin_lock_irqsave (& ctrl_info -> scsi_device_list_lock , flags );
7489+
7490+ device = sdev -> hostdata ;
7491+ if (!device ) {
7492+ spin_unlock_irqrestore (& ctrl_info -> scsi_device_list_lock , flags );
7493+ return - ENODEV ;
7494+ }
7495+
7496+ write_stream_cnt = 0 ;
7497+
7498+ if (device -> raid_io_stats ) {
7499+ for_each_online_cpu (cpu ) {
7500+ write_stream_cnt += per_cpu_ptr (device -> raid_io_stats , cpu )-> write_stream_cnt ;
7501+ }
7502+ }
7503+
7504+ spin_unlock_irqrestore (& ctrl_info -> scsi_device_list_lock , flags );
7505+
7506+ return scnprintf (buffer , PAGE_SIZE , "0x%llx\n" , write_stream_cnt );
7507+ }
7508+
74757509static DEVICE_ATTR (lunid , 0444 , pqi_lunid_show , NULL) ;
74767510static DEVICE_ATTR (unique_id , 0444 , pqi_unique_id_show , NULL) ;
74777511static DEVICE_ATTR (path_info , 0444 , pqi_path_info_show , NULL) ;
@@ -7482,6 +7516,7 @@ static DEVICE_ATTR(raid_bypass_cnt, 0444, pqi_raid_bypass_cnt_show, NULL);
74827516static DEVICE_ATTR (sas_ncq_prio_enable , 0644 ,
74837517 pqi_sas_ncq_prio_enable_show , pqi_sas_ncq_prio_enable_store ) ;
74847518static DEVICE_ATTR (numa_node , 0444 , pqi_numa_node_show , NULL) ;
7519+ static DEVICE_ATTR (write_stream_cnt , 0444 , pqi_write_stream_cnt_show , NULL) ;
74857520
74867521static struct attribute * pqi_sdev_attrs [] = {
74877522 & dev_attr_lunid .attr ,
@@ -7493,6 +7528,7 @@ static struct attribute *pqi_sdev_attrs[] = {
74937528 & dev_attr_raid_bypass_cnt .attr ,
74947529 & dev_attr_sas_ncq_prio_enable .attr ,
74957530 & dev_attr_numa_node .attr ,
7531+ & dev_attr_write_stream_cnt .attr ,
74967532 NULL
74977533};
74987534
0 commit comments