From patchwork Tue Mar 4 17:31:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 3764301 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 7D514BF13A for ; Tue, 4 Mar 2014 17:31:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1AD820394 for ; Tue, 4 Mar 2014 17:31:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8BB420374 for ; Tue, 4 Mar 2014 17:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753536AbaCDRbV (ORCPT ); Tue, 4 Mar 2014 12:31:21 -0500 Received: from mx11.netapp.com ([216.240.18.76]:39593 "EHLO mx11.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbaCDRbU (ORCPT ); Tue, 4 Mar 2014 12:31:20 -0500 X-IronPort-AV: E=Sophos;i="4.97,586,1389772800"; d="scan'208";a="106535027" Received: from vmwexceht02-prd.hq.netapp.com ([10.106.76.240]) by mx11-out.netapp.com with ESMTP; 04 Mar 2014 09:31:20 -0800 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCEHT02-PRD.hq.netapp.com (10.106.76.240) with Microsoft SMTP Server id 14.3.123.3; Tue, 4 Mar 2014 09:31:19 -0800 Received: from netapp42.cthon.org (vpn2ntap-29457.vpn.netapp.com [10.55.72.152]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id s24HVEFJ017405; Tue, 4 Mar 2014 09:31:19 -0800 (PST) From: To: CC: , Andy Adamson Subject: [PATCH 3/4] NFSv4 _nfs4_do_setattr use zero stateid on lost lock Date: Tue, 4 Mar 2014 12:31:08 -0500 Message-ID: <1393954269-3974-4-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1393954269-3974-1-git-send-email-andros@netapp.com> References: <1393954269-3974-1-git-send-email-andros@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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Andy Adamson Use the zero stateid if nfs4_select_rw_stateid indicates a lost lock (-EIO) Signed-off-by: Andy Adamson --- fs/nfs/nfs4proc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index de8e7f5..efe940c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2458,18 +2458,22 @@ static int _nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, truncate = (sattr->ia_valid & ATTR_SIZE) ? true : false; fmode = truncate ? FMODE_WRITE : FMODE_READ; - if (nfs4_copy_delegation_stateid(&arg.stateid, inode, fmode)) { - /* Use that stateid */ - } else if (truncate && state != NULL && nfs4_valid_open_stateid(state)) { + if (nfs4_copy_delegation_stateid(&arg.stateid, inode, fmode)) + /* Use delegation stateid */ + goto do_call; + if (truncate && state != NULL && nfs4_valid_open_stateid(state)) { struct nfs_lockowner lockowner = { .l_owner = current->files, .l_pid = current->tgid, }; - nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE, - &lockowner); - } else - nfs4_stateid_copy(&arg.stateid, &zero_stateid); + /* Use zero stateid if lock is lost (-EIO fall through) */ + if (nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE, + &lockowner) != -EIO) + goto do_call; + } + nfs4_stateid_copy(&arg.stateid, &zero_stateid); +do_call: status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); if (status == 0 && state != NULL) renew_lease(server, timestamp);