From patchwork Sun Jul 24 21:30:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9245073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25151607FD for ; Sun, 24 Jul 2016 21:31:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18D392522B for ; Sun, 24 Jul 2016 21:31:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D34126224; Sun, 24 Jul 2016 21:31:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A04D12522B for ; Sun, 24 Jul 2016 21:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752531AbcGXVbk (ORCPT ); Sun, 24 Jul 2016 17:31:40 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:35247 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbcGXVbj (ORCPT ); Sun, 24 Jul 2016 17:31:39 -0400 Received: by mail-io0-f193.google.com with SMTP id q83so10786652iod.2 for ; Sun, 24 Jul 2016 14:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=Rgcec59Tawc5qRxqK5FFpJw0cgWLxkVfARZv6wiaJtQ=; b=w2JvjPcEyanLtNkV0Y5lxGRHQFoSZTQvUOL7S3C7Ly0m14tLAArxNer27kTKjbdAij de98WDKU9Z7ccE2BEEF4zLTRq3uBZBU44EkOg1YpMqRadx+jxUjaKaK0Jix8j/n2NfBw 2Av6xD/NQNwhi4D+hmPGrOwWA9d/ms6srg8ugV73D6veu0MgELuRY7/lLKV/bjPu14Sw IUXEMTy3jj74M8FOMUghVpNc0gUqab6IVu9v+cQuv190w7c+r2nclH2yd+Zr9RzAWPWA XERsupV86K8Z0ZqOOv6SeITD667XixrJ9Haq8WwFOxhfIRbcGN2hn1Zp3WSLrb3pnPMn LVaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=Rgcec59Tawc5qRxqK5FFpJw0cgWLxkVfARZv6wiaJtQ=; b=DljGxyp30OChgIVYRjbMtHg/9DvaoxaPGco6HSZYABAcgiVJ9Z7Rd2Yt2JwxWTG0// AgvX4xSUlc3pv6JCgGgo9HkXVa0Og/Sd8BqRGMlvwmPS2YiGkBA9Rcu+P+pOEZABvcNW U14JktFaXPWNzLwL2PFGd0aGqqO8IblMYGCkR5GgUjQuu6G86wn3Dc/PdnMKPT3Z6Cd8 LLPOtvqj1xpzpACNT8tF/ae/sS+tP/j7OCwjauAUO2MYwo5V+pTR80nMQqmHEa8KFjII GqE0bxN/h0jIT4IEzTiShiQIMDwpgCrVAv4ySSVdxpnbCq6LBJ46rBgYlyxqvsFiBy4Q vqkw== X-Gm-Message-State: AEkoouvpLtGLRPaZplZ1YxD5IWM7T911hEBcTS0dXYp1oA8K8JgFzK7zRABaarb/rOzCIA== X-Received: by 10.107.20.82 with SMTP id 79mr16577748iou.108.1469395898738; Sun, 24 Jul 2016 14:31:38 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id r128sm8100341ita.6.2016.07.24.14.31.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jul 2016 14:31:38 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v3 06/14] pNFS: Ensure layoutreturn acts as a completion for layout callbacks Date: Sun, 24 Jul 2016 17:30:51 -0400 Message-Id: <1469395859-83194-7-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469395859-83194-6-git-send-email-trond.myklebust@primarydata.com> References: <1469395859-83194-1-git-send-email-trond.myklebust@primarydata.com> <1469395859-83194-2-git-send-email-trond.myklebust@primarydata.com> <1469395859-83194-3-git-send-email-trond.myklebust@primarydata.com> <1469395859-83194-4-git-send-email-trond.myklebust@primarydata.com> <1469395859-83194-5-git-send-email-trond.myklebust@primarydata.com> <1469395859-83194-6-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-Virus-Scanned: ClamAV using ClamSMTP When we return NFS_OK to the CB_LAYOUTRECALL, we are required to send a layoutreturn that "completes" that layout recall request, using the correct stateid. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 85c3e7b47ddb..878dc4b7085a 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -883,12 +883,28 @@ pnfs_clear_layoutreturn_info(struct pnfs_layout_hdr *lo) } static bool -pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo) +pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo, + nfs4_stateid *stateid, + enum pnfs_iomode *iomode) { if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) return false; pnfs_get_layout_hdr(lo); - pnfs_clear_layoutreturn_info(lo); + if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) { + if (stateid != NULL) { + nfs4_stateid_copy(stateid, &lo->plh_stateid); + if (lo->plh_return_seq != 0) + stateid->seqid = cpu_to_be32(lo->plh_return_seq); + } + if (iomode != NULL) + *iomode = lo->plh_return_iomode; + pnfs_clear_layoutreturn_info(lo); + return true; + } + if (stateid != NULL) + nfs4_stateid_copy(stateid, &lo->plh_stateid); + if (iomode != NULL) + *iomode = IOMODE_ANY; return true; } @@ -956,10 +972,7 @@ static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo) enum pnfs_iomode iomode; bool send; - nfs4_stateid_copy(&stateid, &lo->plh_stateid); - stateid.seqid = cpu_to_be32(lo->plh_return_seq); - iomode = lo->plh_return_iomode; - send = pnfs_prepare_layoutreturn(lo); + send = pnfs_prepare_layoutreturn(lo, &stateid, &iomode); spin_unlock(&inode->i_lock); if (send) { /* Send an async layoutreturn so we dont deadlock */ @@ -996,7 +1009,6 @@ _pnfs_return_layout(struct inode *ino) dprintk("NFS: %s no layout to return\n", __func__); goto out; } - nfs4_stateid_copy(&stateid, &nfsi->layout->plh_stateid); /* Reference matched in nfs4_layoutreturn_release */ pnfs_get_layout_hdr(lo); empty = list_empty(&lo->plh_segs); @@ -1020,7 +1032,7 @@ _pnfs_return_layout(struct inode *ino) } set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); - send = pnfs_prepare_layoutreturn(lo); + send = pnfs_prepare_layoutreturn(lo, &stateid, NULL); spin_unlock(&ino->i_lock); pnfs_free_lseg_list(&tmp_list); if (send) @@ -1087,11 +1099,10 @@ bool pnfs_roc(struct inode *ino) goto out_noroc; } - nfs4_stateid_copy(&stateid, &lo->plh_stateid); /* always send layoutreturn if being marked so */ - if (test_and_clear_bit(NFS_LAYOUT_RETURN_REQUESTED, - &lo->plh_flags)) - layoutreturn = pnfs_prepare_layoutreturn(lo); + if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) + layoutreturn = pnfs_prepare_layoutreturn(lo, + &stateid, NULL); list_for_each_entry_safe(lseg, tmp, &lo->plh_segs, pls_list) /* If we are sending layoutreturn, invalidate all valid lsegs */ @@ -1874,10 +1885,9 @@ void pnfs_error_mark_layout_for_return(struct inode *inode, if (!pnfs_mark_matching_lsegs_return(lo, &free_me, &range, lseg->pls_seq)) { nfs4_stateid stateid; - enum pnfs_iomode iomode = lo->plh_return_iomode; + enum pnfs_iomode iomode; - nfs4_stateid_copy(&stateid, &lo->plh_stateid); - return_now = pnfs_prepare_layoutreturn(lo); + return_now = pnfs_prepare_layoutreturn(lo, &stateid, &iomode); spin_unlock(&inode->i_lock); if (return_now) pnfs_send_layoutreturn(lo, &stateid, iomode, false);