[sheepdog] [PATCH] When network is broken, unblock all I/O requests.

Liu Yuan namei.unix at gmail.com
Tue Mar 3 10:51:13 CET 2015


On Tue, Mar 03, 2015 at 04:34:13PM +0800, Xu Yifeng wrote:
> Current sbd code does not reconnect network, the change does not try
> to fix this, but instead, drain all I/O requests. This makes application
> killable, otherwise an application can be blocked forever.
> 
> Signed-off-by: Xu Yifeng <skypexu at gmail.com>
> ---
>  sbd/sheep.c | 24 +++++++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/sbd/sheep.c b/sbd/sheep.c
> index 746f0ea..b8d3a18 100644
> --- a/sbd/sheep.c
> +++ b/sbd/sheep.c
> @@ -279,7 +279,7 @@ static int submit_sheep_request(struct sheep_request *req)
>  {
>  	struct sd_req hdr = {};
>  	struct sbd_device *dev = sheep_request_to_device(req);
> -	int ret;
> +	int ret = 0;
>  
>  	hdr.id = req->seq_num;
>  	hdr.data_length = req->length;
> @@ -316,9 +316,8 @@ static int submit_sheep_request(struct sheep_request *req)
>  	}
>  	sbd_debug("add oid %llx off %d, len %d, seq %u, type %d\n", req->oid,
>  		  req->offset, req->length, req->seq_num, req->type);
> -	wake_up(&dev->reaper_wq);
> -	return 0;
>  err:
> +	wake_up(&dev->reaper_wq);
>  	return ret;
>  }
>  
> @@ -611,6 +610,20 @@ out:
>  	return req;
>  }
>  
> +static struct sheep_request *fetch_first_inflight_request(struct sbd_device *dev)
> +{
> +	struct sheep_request *req;
> +
> +	write_lock(&dev->inflight_lock);
> +	if (!list_empty(&dev->inflight_head)) {
> +		req = list_first_entry(&dev->inflight_head, struct sheep_request, list);
> +		list_del_init(&req->list);
> +	} else
> +		req = NULL;
> +	write_unlock(&dev->inflight_lock);
> +	return req;
> +}
> +
>  static void submit_blocking_sheep_request(struct sbd_device *dev, uint64_t oid)
>  {
>  	struct sheep_request *req, *t;
> @@ -637,6 +650,11 @@ int sheep_handle_reply(struct sbd_device *dev)
>  	ret = socket_read(dev->sock, (char *)&rsp, sizeof(rsp));
>  	if (ret < 0) {
>  		pr_err("failed to read reply header %d\n", ret);
> +		req = fetch_first_inflight_request(dev);
> +		if (req != NULL) {
> +			req->aiocb->ret = EIO;
> +			goto end_request;
> +		}
>  		goto err;
>  	}
>  

Please fix following style problem found by our ./script/checkpath.pl

WARNING: line over 80 characters
#41: FILE: sbd/sheep.c:613:
+static struct sheep_request *fetch_first_inflight_request(struct sbd_device *dev)

WARNING: line over 80 characters
#47: FILE: sbd/sheep.c:619:
+		req = list_first_entry(&dev->inflight_head, struct sheep_request, list);

total: 0 errors, 2 warnings, 49 lines checked

Your patch has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

====================================================

Also, would be great if you can add "sbd: xxx" to your patch subject header.

Other parts looks good to me.

Thanks,
Yuan



More information about the sheepdog mailing list