Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752681AbbKYTfi (ORCPT ); Wed, 25 Nov 2015 14:35:38 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:38496 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751295AbbKYTf3 (ORCPT ); Wed, 25 Nov 2015 14:35:29 -0500 From: Konrad Rzeszutek Wilk To: roger.pau@citrix.com, jonathan.davies@citrix.com, david.vrabel@citrix.com, linux-kernel@vger.kernel.org, jgross@suse.com, xen-devel@lists.xenproject.org, bob.liu@oracle.com Cc: Konrad Rzeszutek Wilk Subject: [PATCH RFC 2/2] xen/blkback: Free resources if connect_ring failed. Date: Wed, 25 Nov 2015 14:35:11 -0500 Message-Id: <1448480111-6598-3-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1448480111-6598-1-git-send-email-konrad.wilk@oracle.com> References: <1447470739-18136-1-git-send-email-bob.liu@oracle.com> <1448480111-6598-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1435 Lines: 43 With the multi-queue support we could fail at setting up some of the rings and fail the connection. That meant that all resources tied to rings[0..n-1] (where n is the ring that failed to be setup). Eventually the frontend will switch to the states and we will call xen_blkif_disconnect. However we do not want to be at the mercy of the frontend deciding when to change states. This allows us to do the cleanup right away and freeing resources. Signed-off-by: Konrad Rzeszutek Wilk --- drivers/block/xen-blkback/xenbus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index ca3a414..c92b358 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -749,8 +749,14 @@ static void frontend_changed(struct xenbus_device *dev, } err = connect_ring(be); - if (err) + if (err) { + /* + * Clean up so that memory resources can be used by + * other devices. connect_ring reported already error. + */ + xen_blkif_disconnect(be->blkif); break; + } xen_update_blkif_status(be->blkif); break; -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/