From patchwork Mon Oct 21 17:10:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 3078981 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B6B5FBF924 for ; Mon, 21 Oct 2013 17:10:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97494203F4 for ; Mon, 21 Oct 2013 17:10:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9BE0203A8 for ; Mon, 21 Oct 2013 17:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751486Ab3JURKZ (ORCPT ); Mon, 21 Oct 2013 13:10:25 -0400 Received: from mx2.netapp.com ([216.240.18.37]:44741 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444Ab3JURKW (ORCPT ); Mon, 21 Oct 2013 13:10:22 -0400 X-IronPort-AV: E=Sophos;i="4.93,540,1378882800"; d="scan'208";a="52012623" Received: from vmwexceht01-prd.hq.netapp.com ([10.106.76.239]) by mx2-out.netapp.com with ESMTP; 21 Oct 2013 10:10:21 -0700 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCEHT01-PRD.hq.netapp.com (10.106.76.239) with Microsoft SMTP Server id 14.3.123.3; Mon, 21 Oct 2013 10:10:22 -0700 Received: from vpn2ntap-70169.vpn.netapp.com (vpn2ntap-70169.vpn.netapp.com [10.55.70.159]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id r9LHAI07029712; Mon, 21 Oct 2013 10:10:21 -0700 (PDT) From: Weston Andros Adamson To: CC: , Weston Andros Adamson Subject: [PATCH 3/5] NFSv4: clean up state ref counting in open recover Date: Mon, 21 Oct 2013 13:10:12 -0400 Message-ID: <1382375414-5854-4-git-send-email-dros@netapp.com> X-Mailer: git-send-email 1.7.12.4 (Apple Git-37) In-Reply-To: <1382375414-5854-1-git-send-email-dros@netapp.com> References: <1382375414-5854-1-git-send-email-dros@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's already a valid state (the one being recovered), so just reference it. Also clean up error paths to avoid ref leaks. Signed-off-by: Weston Andros Adamson Acked-by: Weston Andros Adamson --- fs/nfs/nfs4proc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 8140366..8ae1589 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1323,14 +1323,14 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data) goto err; } - ret = -ENOMEM; - state = nfs4_get_open_state(inode, data->owner); - if (state == NULL) + /* referenced the passed state */ + ret = -EINVAL; + if (state == NULL || !atomic_inc_not_zero(&state->count)) goto err; ret = nfs_refresh_inode(inode, &data->f_attr); if (ret) - goto err; + goto err_put; nfs_setsecurity(inode, &data->f_attr, data->f_label); @@ -1340,9 +1340,12 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data) data->o_arg.fmode); return state; + +err_put: + nfs4_put_open_state(state); + err: return ERR_PTR(ret); - } static struct nfs4_state *