@@ -5497,6 +5497,8 @@ static void block_unblock_all_queues(bool block)
54975497 int j ;
54985498 struct sdebug_queue * sqp ;
54995499
5500+ lockdep_assert_held (& sdebug_host_list_mutex );
5501+
55005502 for (j = 0 , sqp = sdebug_q_arr ; j < submit_queues ; ++ j , ++ sqp )
55015503 atomic_set (& sqp -> blocked , (int )block );
55025504}
@@ -5511,10 +5513,13 @@ static void tweak_cmnd_count(void)
55115513 modulo = abs (sdebug_every_nth );
55125514 if (modulo < 2 )
55135515 return ;
5516+
5517+ mutex_lock (& sdebug_host_list_mutex );
55145518 block_unblock_all_queues (true);
55155519 count = atomic_read (& sdebug_cmnd_count );
55165520 atomic_set (& sdebug_cmnd_count , (count / modulo ) * modulo );
55175521 block_unblock_all_queues (false);
5522+ mutex_unlock (& sdebug_host_list_mutex );
55185523}
55195524
55205525static void clear_queue_stats (void )
@@ -6036,6 +6041,7 @@ static ssize_t delay_store(struct device_driver *ddp, const char *buf,
60366041 int j , k ;
60376042 struct sdebug_queue * sqp ;
60386043
6044+ mutex_lock (& sdebug_host_list_mutex );
60396045 block_unblock_all_queues (true);
60406046 for (j = 0 , sqp = sdebug_q_arr ; j < submit_queues ;
60416047 ++ j , ++ sqp ) {
@@ -6051,6 +6057,7 @@ static ssize_t delay_store(struct device_driver *ddp, const char *buf,
60516057 sdebug_ndelay = 0 ;
60526058 }
60536059 block_unblock_all_queues (false);
6060+ mutex_unlock (& sdebug_host_list_mutex );
60546061 }
60556062 return res ;
60566063 }
@@ -6076,6 +6083,7 @@ static ssize_t ndelay_store(struct device_driver *ddp, const char *buf,
60766083 int j , k ;
60776084 struct sdebug_queue * sqp ;
60786085
6086+ mutex_lock (& sdebug_host_list_mutex );
60796087 block_unblock_all_queues (true);
60806088 for (j = 0 , sqp = sdebug_q_arr ; j < submit_queues ;
60816089 ++ j , ++ sqp ) {
@@ -6092,6 +6100,7 @@ static ssize_t ndelay_store(struct device_driver *ddp, const char *buf,
60926100 : DEF_JDELAY ;
60936101 }
60946102 block_unblock_all_queues (false);
6103+ mutex_unlock (& sdebug_host_list_mutex );
60956104 }
60966105 return res ;
60976106 }
@@ -6405,6 +6414,7 @@ static ssize_t max_queue_store(struct device_driver *ddp, const char *buf,
64056414 if ((count > 0 ) && (1 == sscanf (buf , "%d" , & n )) && (n > 0 ) &&
64066415 (n <= SDEBUG_CANQUEUE ) &&
64076416 (sdebug_host_max_queue == 0 )) {
6417+ mutex_lock (& sdebug_host_list_mutex );
64086418 block_unblock_all_queues (true);
64096419 k = 0 ;
64106420 for (j = 0 , sqp = sdebug_q_arr ; j < submit_queues ;
@@ -6421,6 +6431,7 @@ static ssize_t max_queue_store(struct device_driver *ddp, const char *buf,
64216431 else
64226432 atomic_set (& retired_max_queue , 0 );
64236433 block_unblock_all_queues (false);
6434+ mutex_unlock (& sdebug_host_list_mutex );
64246435 return count ;
64256436 }
64266437 return - EINVAL ;
@@ -7352,7 +7363,9 @@ static int sdebug_change_qdepth(struct scsi_device *sdev, int qdepth)
73527363 if (!devip )
73537364 return - ENODEV ;
73547365
7366+ mutex_lock (& sdebug_host_list_mutex );
73557367 block_unblock_all_queues (true);
7368+
73567369 if (qdepth > SDEBUG_CANQUEUE ) {
73577370 qdepth = SDEBUG_CANQUEUE ;
73587371 pr_warn ("%s: requested qdepth [%d] exceeds canqueue [%d], trim\n" , __func__ ,
@@ -7363,9 +7376,12 @@ static int sdebug_change_qdepth(struct scsi_device *sdev, int qdepth)
73637376 if (qdepth != sdev -> queue_depth )
73647377 scsi_change_queue_depth (sdev , qdepth );
73657378
7379+ block_unblock_all_queues (false);
7380+ mutex_unlock (& sdebug_host_list_mutex );
7381+
73667382 if (SDEBUG_OPT_Q_NOISE & sdebug_opts )
73677383 sdev_printk (KERN_INFO , sdev , "%s: qdepth=%d\n" , __func__ , qdepth );
7368- block_unblock_all_queues (false);
7384+
73697385 return sdev -> queue_depth ;
73707386}
73717387
0 commit comments