From patchwork Thu Feb 5 22:37:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 5787441 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 741A0BF440 for ; Thu, 5 Feb 2015 22:37:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82DB420253 for ; Thu, 5 Feb 2015 22:37:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7DFB20222 for ; Thu, 5 Feb 2015 22:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbbBEWhQ (ORCPT ); Thu, 5 Feb 2015 17:37:16 -0500 Received: from mail-ig0-f177.google.com ([209.85.213.177]:37312 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbbBEWhP (ORCPT ); Thu, 5 Feb 2015 17:37:15 -0500 Received: by mail-ig0-f177.google.com with SMTP id z20so2352514igj.4 for ; Thu, 05 Feb 2015 14:37:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3tBu3AlwRIgnbLDPcjOsZSNedU0ERHj0Z4pRQ0Fmtxc=; b=Vbjf79Z7z20/A3wtw78akyW8V0p48F/V4ZM4itG+goYGKAo36guoDheZIR7epwsifh 7HWMebcC3iJOYT1KU0fhEl7+tC81Awjtc5KaghpbLu0BUook8PDUBxzJOPOkU4j2Il1S kqY2qBwvDYUM4ZYA6JA3rj+8xgQHzIExuC/mYARgEUAB2VSS2i+89YBRfl9KIBGl60J7 rX63NgTCSE7REq0l6VLsA2HTLixRW428zpADerU891Wg7UYstvhLpa15psn/MN49GzG3 FDb18HBNmLBV70UQP5jB/tV2GJMDgzhZ8Kc1BaE4TL0CnVu/xv5hQFCsgo5xchhGYfKz 0bzQ== X-Gm-Message-State: ALoCoQlshJ9+juMZUegWUje/zHN1l+IjveL6txGcoRLlw0w3e8W7yMfy76PkoVmlUWa0Pmkoc9pl X-Received: by 10.50.234.194 with SMTP id ug2mr949411igc.39.1423175834429; Thu, 05 Feb 2015 14:37:14 -0800 (PST) Received: from leira.trondhjem.org.localdomain (c-68-40-185-14.hsd1.mi.comcast.net. [68.40.185.14]) by mx.google.com with ESMTPSA id mi3sm239604igb.13.2015.02.05.14.37.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 14:37:13 -0800 (PST) From: Trond Myklebust To: linux-nfs@vger.kernel.org Cc: Peng Tao Subject: [PATCH 1/5] NFSv4: Ensure we reference the inode for return-on-close in delegreturn Date: Thu, 5 Feb 2015 17:37:07 -0500 Message-Id: <1423175831-54558-1-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 If we have to do a return-on-close in the delegreturn code, then we must ensure that the inode and super block remain referenced. Cc: Peng Tao Cc: stable@vger.kernel.org # 3.17.x Signed-off-by: Trond Myklebust Reviewed-by: Peng Tao --- fs/nfs/nfs4proc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index cd4295d84d54..b803c1d363e7 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5175,9 +5175,16 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) static void nfs4_delegreturn_release(void *calldata) { struct nfs4_delegreturndata *data = calldata; + struct inode *inode = data->inode; + + if (inode) { + struct super_block *sb = inode->i_sb; - if (data->roc) - pnfs_roc_release(data->inode); + if (data->roc) + pnfs_roc_release(inode); + iput(inode); + nfs_sb_deactive(sb); + } kfree(calldata); } @@ -5234,9 +5241,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co nfs_fattr_init(data->res.fattr); data->timestamp = jiffies; data->rpc_status = 0; - data->inode = inode; - data->roc = list_empty(&NFS_I(inode)->open_files) ? - pnfs_roc(inode) : false; + data->inode = igrab(inode); + if (data->inode) { + nfs_sb_active(inode->i_sb); + data->roc = nfs4_roc(inode); + } task_setup_data.callback_data = data; msg.rpc_argp = &data->args;