diff options
Diffstat (limited to 'drivers/nvme/host/tcp.c')
| -rw-r--r-- | drivers/nvme/host/tcp.c | 18 | 
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 979ee31b8dd1..881d28eb15e9 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -76,6 +76,7 @@ struct nvme_tcp_queue {  	struct work_struct	io_work;  	int			io_cpu; +	struct mutex		queue_lock;  	struct mutex		send_mutex;  	struct llist_head	req_list;  	struct list_head	send_list; @@ -201,7 +202,7 @@ static inline size_t nvme_tcp_req_cur_offset(struct nvme_tcp_request *req)  static inline size_t nvme_tcp_req_cur_length(struct nvme_tcp_request *req)  { -	return min_t(size_t, req->iter.bvec->bv_len - req->iter.iov_offset, +	return min_t(size_t, iov_iter_single_seg_count(&req->iter),  			req->pdu_len - req->pdu_sent);  } @@ -286,7 +287,7 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,  	 * directly, otherwise queue io_work. Also, only do that if we  	 * are on the same cpu, so we don't introduce contention.  	 */ -	if (queue->io_cpu == smp_processor_id() && +	if (queue->io_cpu == __smp_processor_id() &&  	    sync && empty && mutex_trylock(&queue->send_mutex)) {  		queue->more_requests = !last;  		nvme_tcp_send_all(queue); @@ -1219,6 +1220,7 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)  	sock_release(queue->sock);  	kfree(queue->pdu); +	mutex_destroy(&queue->queue_lock);  }  static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) @@ -1380,6 +1382,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl,  	struct nvme_tcp_queue *queue = &ctrl->queues[qid];  	int ret, rcv_pdu_size; +	mutex_init(&queue->queue_lock);  	queue->ctrl = ctrl;  	init_llist_head(&queue->req_list);  	INIT_LIST_HEAD(&queue->send_list); @@ -1398,7 +1401,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl,  	if (ret) {  		dev_err(nctrl->device,  			"failed to create socket: %d\n", ret); -		return ret; +		goto err_destroy_mutex;  	}  	/* Single syn retry */ @@ -1507,6 +1510,8 @@ err_crypto:  err_sock:  	sock_release(queue->sock);  	queue->sock = NULL; +err_destroy_mutex: +	mutex_destroy(&queue->queue_lock);  	return ret;  } @@ -1534,9 +1539,10 @@ static void nvme_tcp_stop_queue(struct nvme_ctrl *nctrl, int qid)  	struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl);  	struct nvme_tcp_queue *queue = &ctrl->queues[qid]; -	if (!test_and_clear_bit(NVME_TCP_Q_LIVE, &queue->flags)) -		return; -	__nvme_tcp_stop_queue(queue); +	mutex_lock(&queue->queue_lock); +	if (test_and_clear_bit(NVME_TCP_Q_LIVE, &queue->flags)) +		__nvme_tcp_stop_queue(queue); +	mutex_unlock(&queue->queue_lock);  }  static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx)  | 
