From: Chen Gang Subject: [PATCH 4/4] drivers/xen/xenbus/xenbus_client.c: Improve the failure processing for __xenbus_switch_state() Date: Sun, 14 Sep 2014 18:52:45 +0800 Message-ID: <5415737D.2030209__47677.5486175486$1410692064$gmane$org@gmail.com> References: <54157282.40402@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XT7QB-00032x-HR for xen-devel@lists.xenproject.org; Sun, 14 Sep 2014 10:52:43 +0000 Received: by mail-pd0-f175.google.com with SMTP id z10so4366696pdj.6 for ; Sun, 14 Sep 2014 03:52:39 -0700 (PDT) In-Reply-To: <54157282.40402@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, David Vrabel , stefano.stabellini@eu.citrix.com, mukesh.rathor@oracle.com Cc: xen-devel@lists.xenproject.org, "linux-kernel@vger.kernel.org" List-Id: xen-devel@lists.xenproject.org When failure occurs, need return failure code instead of 0, or the upper caller will misunderstand. Also when retry for EAGAIN reason, better to schedule out for a while, so can let others have chance to continue their tasks (especially, their tasks are related EAGAIN under UP kernel). Signed-off-by: Chen Gang --- drivers/xen/xenbus/xenbus_client.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 620ffd2..fc8699b 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -196,7 +197,7 @@ again: err = xenbus_transaction_start(&xbt); if (err) { xenbus_switch_fatal(dev, depth, err, "starting transaction"); - return 0; + return err; } err = xenbus_scanf(xbt, dev->nodename, "state", "%d", ¤t_state); @@ -213,13 +214,15 @@ again: abort: err = xenbus_transaction_end(xbt, abort); if (err) { - if (err == -EAGAIN && !abort) + if (err == -EAGAIN && !abort) { + msleep(20); goto again; + } xenbus_switch_fatal(dev, depth, err, "ending transaction"); } else dev->state = state; - return 0; + return err; } /** -- 1.9.3