lkml.org 
[lkml]   [2008]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: nbd: fix locking in case of error
Pavel Machek wrote:
> This cleans up error handling some more, and prevents return with lock
> held from nbd_handle_req when nbd_send_req() fails. It also switches

> static struct request *nbd_find_request(struct nbd_device *lo,
> @@ -467,10 +467,9 @@ static void nbd_handle_req(struct nbd_de
>
> mutex_lock(&lo->tx_lock);
> if (unlikely(!lo->sock)) {
> - mutex_unlock(&lo->tx_lock);
> printk(KERN_ERR "%s: Attempted send on closed socket\n",
> lo->disk->disk_name);
> - goto error_out;
> + goto error_out_unlock;
> }
>
> lo->active_req = req;
> @@ -478,7 +477,7 @@ static void nbd_handle_req(struct nbd_de
> if (nbd_send_req(lo, req) != 0) {
> printk(KERN_ERR "%s: Request send failed\n",
> lo->disk->disk_name);
> - goto error_out;
> + goto error_out_unlock;
> } else {
> spin_lock(&lo->queue_lock);
> list_add(&req->queuelist, &lo->queue_head);
> @@ -491,6 +490,8 @@ static void nbd_handle_req(struct nbd_de
>
> return;
>
> +error_out_unlock:
> + mutex_unlock(&lo->tx_lock);
> error_out:
> req->errors++;
> nbd_end_request(req);

Not sure I see the problem. tx_lock is unlocked in every return path
AFAICS. You introduced the tx_lock problem with the previous patch,
where the second error_out was not correct.

--
Paul


\
 
 \ /
  Last update: 2008-12-18 20:35    [W:0.761 / U:0.740 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site