From patchwork Mon Feb 1 13:52:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jackm X-Patchwork-Id: 76072 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 o11DoAMd010278 for ; Mon, 1 Feb 2010 13:50:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754135Ab0BANuJ (ORCPT ); Mon, 1 Feb 2010 08:50:09 -0500 Received: from mail-vw0-f46.google.com ([209.85.212.46]:59804 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753149Ab0BANuI (ORCPT ); Mon, 1 Feb 2010 08:50:08 -0500 Received: by vws12 with SMTP id 12so1327464vws.19 for ; Mon, 01 Feb 2010 05:50:07 -0800 (PST) Received: by 10.220.127.90 with SMTP id f26mr5700170vcs.41.1265032207135; Mon, 01 Feb 2010 05:50:07 -0800 (PST) Received: from mtldesk006.lab.mtl.com ([212.179.152.71]) by mx.google.com with ESMTPS id 29sm59284073vws.3.2010.02.01.05.50.03 (version=SSLv3 cipher=RC4-MD5); Mon, 01 Feb 2010 05:50:04 -0800 (PST) From: Jack Morgenstein Organization: Mellanox To: Roland Dreier Subject: Re: [PATCH 4/4] IB/uverbs: Support for associating XRC domains to inodes Date: Mon, 1 Feb 2010 15:52:24 +0200 User-Agent: KMail/1.9.1 Cc: linux-rdma@vger.kernel.org, Tziporet Koren References: <1264446094-4460-1-git-send-email-rolandd@cisco.com> <1264446094-4460-5-git-send-email-rolandd@cisco.com> In-Reply-To: <1264446094-4460-5-git-send-email-rolandd@cisco.com> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201002011552.24904.jackm@dev.mellanox.co.il> 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 13:50:10 +0000 (UTC) ========================================================================================= diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 3db78cb..98c4ded 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1382,6 +1382,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, struct ib_uobject *uobj; struct ib_qp *qp; struct ib_uqp_object *obj; + struct ib_xrcd *xrcd; int ret = -EINVAL; if (copy_from_user(&cmd, buf, sizeof cmd)) @@ -1400,6 +1401,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, return -EBUSY; } + xrcd = qp->xrcd; ret = ib_destroy_qp(qp); if (!ret) uobj->live = 0; @@ -1409,7 +1411,8 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, if (ret) return ret; - atomic_dec(&obj->uxrcd->refcnt); + if (xrcd) + atomic_dec(&obj->uxrcd->refcnt); idr_remove_uobj(&ib_uverbs_qp_idr, uobj); @@ -2294,6 +2297,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, struct ib_uobject *uobj; struct ib_srq *srq; struct ib_usrq_object *obj; + struct ib_xrcd *xrcd; int ret = -EINVAL; if (copy_from_user(&cmd, buf, sizeof cmd)) @@ -2305,6 +2309,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, srq = uobj->object; obj = container_of(uobj, struct ib_usrq_object, uevent.uobject); + xrcd = srq->xrcd; ret = ib_destroy_srq(srq); if (!ret) uobj->live = 0; @@ -2314,7 +2319,8 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, if (ret) return ret; - atomic_dec(&obj->uxrcd->refcnt); + if (xrcd) + atomic_dec(&obj->uxrcd->refcnt); idr_remove_uobj(&ib_uverbs_srq_idr, uobj); @@ -2604,12 +2610,9 @@ ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file, live = uobj->live; - if (inode && ret) - atomic_inc(&xrcd->usecnt); - put_uobj_write(uobj); - if (ret) + if (ret && !inode) goto out; if (inode && !live) @@ -2637,15 +2640,10 @@ void ib_uverbs_dealloc_xrcd(struct ib_uverbs_device *dev, int ret = 0; inode = xrcd->inode; - if (inode && !atomic_dec_and_test(&xrcd->usecnt)) - return; + if (inode) + atomic_dec(&xrcd->usecnt); ret = ib_dealloc_xrcd(xrcd); - - if (inode) { - if (!ret) - xrcd_table_delete(dev, inode); - else - atomic_inc(&xrcd->usecnt); - } + if (!ret && inode) + xrcd_table_delete(dev, inode); }