From patchwork Fri Feb 6 04:45:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 5788361 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0813D9F30C for ; Fri, 6 Feb 2015 04:45:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F60220219 for ; Fri, 6 Feb 2015 04:45:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43B0220222 for ; Fri, 6 Feb 2015 04:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753700AbbBFEpL (ORCPT ); Thu, 5 Feb 2015 23:45:11 -0500 Received: from mail-ig0-f180.google.com ([209.85.213.180]:63421 "EHLO mail-ig0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753747AbbBFEpL (ORCPT ); Thu, 5 Feb 2015 23:45:11 -0500 Received: by mail-ig0-f180.google.com with SMTP id b16so5441213igk.1 for ; Thu, 05 Feb 2015 20:45:10 -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:in-reply-to :references; bh=HqZt8CYC/xQ8+mdcWpMab0wi4/iNGETwMWWxKJ2zuG8=; b=m8Wig32aCMDZhY/FXk9XUTVegJzk1xkZg2MeK/5uFatzVxJ7/GuPe8uT4GOz8sHqmp Ub2Rk425vcDNnRyggXkSpbf1lpehnZU8SUg/FJIoHtECkymEfgB4ALi9ZnKLHu7mAO97 BXvC9nrSDaTpK1QLlC7/OYD/yRitTs5TfOFBGmVgtr4cJN4EDzIhD1Uq7fSmU/R80w6l cfwQCAswRRdqA/KGY9IAhF+t/1++VyImcAeeMiSfvn5M7UcfPxauBE/SMltYJQGtH6RS nOsmxnYCIBo1aJhnldLXe5DQMJO/4wHjuym1mBJnOxVwft11K3dD+SgHJY6njE/AxHbJ ipOQ== X-Gm-Message-State: ALoCoQmK8ZKDutS7A85j2PERv0qgXBk4Q4mZnwMFtlzCxAVojPz4FU86kJymTunD3PAOtQIfAT59 X-Received: by 10.42.79.76 with SMTP id q12mr10897460ick.16.1423197910396; Thu, 05 Feb 2015 20:45:10 -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 g11sm699830iod.28.2015.02.05.20.45.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 20:45:09 -0800 (PST) From: Trond Myklebust To: linux-nfs@vger.kernel.org Cc: Peng Tao Subject: [PATCH v3 2/5] NFSv4.1: Pin the inode and super block in asynchronous layoutcommit Date: Thu, 5 Feb 2015 23:45:04 -0500 Message-Id: <1423197907-75541-2-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423197907-75541-1-git-send-email-trond.myklebust@primarydata.com> References: <1423197907-75541-1-git-send-email-trond.myklebust@primarydata.com> 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're sending an asynchronous layoutcommit, then we need to ensure that the inode and the super block remain pinned. Signed-off-by: Trond Myklebust Reviewed-by: Peng Tao --- fs/nfs/nfs4proc.c | 19 +++++++++++-------- include/linux/nfs_xdr.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index dd892a4e7eb3..e092b8540e2e 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7989,6 +7989,7 @@ static void nfs4_layoutcommit_release(void *calldata) nfs_post_op_update_inode_force_wcc(data->args.inode, data->res.fattr); put_rpccred(data->cred); + nfs_iput_and_deactive(data->inode); kfree(data); } @@ -8013,7 +8014,6 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync) .rpc_message = &msg, .callback_ops = &nfs4_layoutcommit_ops, .callback_data = data, - .flags = RPC_TASK_ASYNC, }; struct rpc_task *task; int status = 0; @@ -8024,18 +8024,21 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync) data->args.lastbytewritten, data->args.inode->i_ino); + if (!sync) { + data->inode = nfs_igrab_and_active(data->args.inode); + if (data->inode == NULL) { + nfs4_layoutcommit_release(data); + return -EAGAIN; + } + task_setup_data.flags = RPC_TASK_ASYNC; + } nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); task = rpc_run_task(&task_setup_data); if (IS_ERR(task)) return PTR_ERR(task); - if (sync == false) - goto out; - status = nfs4_wait_for_completion_rpc_task(task); - if (status != 0) - goto out; - status = task->tk_status; + if (sync) + status = task->tk_status; trace_nfs4_layoutcommit(data->args.inode, status); -out: dprintk("%s: status %d\n", __func__, status); rpc_put_task(task); return status; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 2c35e2affa6f..bb0d56f737e0 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -285,6 +285,7 @@ struct nfs4_layoutcommit_data { struct nfs_fattr fattr; struct list_head lseg_list; struct rpc_cred *cred; + struct inode *inode; struct nfs4_layoutcommit_args args; struct nfs4_layoutcommit_res res; };