From patchwork Mon Feb 1 05:58:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Vainman X-Patchwork-Id: 76038 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o115vmCO030500 for ; Mon, 1 Feb 2010 05:58:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754189Ab0BAF6F (ORCPT ); Mon, 1 Feb 2010 00:58:05 -0500 Received: from fwil.voltaire.com ([193.47.165.2]:28429 "EHLO exil.voltaire.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754187Ab0BAF6D (ORCPT ); Mon, 1 Feb 2010 00:58:03 -0500 Received: from [127.0.0.1] ([172.25.5.22]) by exil.voltaire.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 07:58:01 +0200 Message-ID: <4B666D68.8010103@gmail.com> Date: Mon, 01 Feb 2010 07:58:00 +0200 From: Alex Vainman Reply-To: alexv@voltaire.com User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: roland , Roland Dreier , linux-rdma@vger.kernel.org, alexr@voltaire.com Subject: [PATCH v2 2/4] libibverbs: Undo changes in memory range tree when madvise() fails X-OriginalArrivalTime: 01 Feb 2010 05:58:01.0871 (UTC) FILETIME=[836DA1F0:01CAA303] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 01 Feb 2010 05:58:05 +0000 (UTC) diff --git a/src/memory.c b/src/memory.c index 51839e2..6a3305f 100644 --- a/src/memory.c +++ b/src/memory.c @@ -521,10 +521,8 @@ static int ibv_madvise_range(void *base, size_t size, int advice) } } - node->refcnt += inc; - - if ((inc == -1 && node->refcnt == 0) || - (inc == 1 && node->refcnt == 1)) { + if ((inc == -1 && node->refcnt == 1) || + (inc == 1 && node->refcnt == 0)) { /* * If this is the first time through the loop, * and we merged this node with the previous @@ -547,6 +545,7 @@ static int ibv_madvise_range(void *base, size_t size, int advice) goto out; } + node->refcnt += inc; node = __mm_next(node); }