From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wen Congyang Subject: [PATCH 10/17] tools: block-remus: fix bug in ctl_request() Date: Tue, 14 Oct 2014 10:13:58 +0800 Message-ID: <1413252845-23433-11-git-send-email-wency@cn.fujitsu.com> References: <1413252845-23433-1-git-send-email-wency@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1413252845-23433-1-git-send-email-wency@cn.fujitsu.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: xen devel Cc: Ian Campbell , Wen Congyang , Ian Jackson , Jiang Yunhong , Dong Eddie , Shriram Rajagopalan , Yang Hongyang , Lai Jiangshan List-Id: xen-devel@lists.xenproject.org ctl_request() handles the command which the users writes to ctl fifo. The user will read the response from msg fifo. This patch fixes the following bugs: 1. If the command is not "flush", we don't respond, and the user will wait the forever. 2. If the current mode is not mode_primary, we don't respond in s->queue_flush(), so call s->queue_flush() only if the mode is mode_primary. Signed-off-by: Wen Congyang Cc: Shriram Rajagopalan --- tools/blktap2/drivers/block-remus.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/blktap2/drivers/block-remus.c b/tools/blktap2/drivers/block-remus.c index 55363a3..9be47f6 100644 --- a/tools/blktap2/drivers/block-remus.c +++ b/tools/blktap2/drivers/block-remus.c @@ -1513,13 +1513,18 @@ static void ctl_request(event_id_t id, char mode, void *private) /* TODO: need to get driver somehow */ msg[rc] = '\0'; if (!strncmp(msg, "flush", 5)) { - if (s->queue_flush) + if (s->mode == mode_primary) { if ((rc = s->queue_flush(driver))) { RPRINTF("error passing flush request to backup"); ctl_respond(s, TDREMUS_FAIL); } + } else { + RPRINTF("We are not in primary mode\n"); + ctl_respond(s, TDREMUS_FAIL); + } } else { RPRINTF("unknown command: %s\n", msg); + ctl_respond(s, TDREMUS_FAIL); } } -- 1.9.3