From patchwork Tue May 17 16:28:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9114261 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 9A8C0BF29F for ; Tue, 17 May 2016 16:29:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F072201B9 for ; Tue, 17 May 2016 16:29:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9FB4C202EC for ; Tue, 17 May 2016 16:29:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756199AbcEQQ3E (ORCPT ); Tue, 17 May 2016 12:29:04 -0400 Received: from mail-qg0-f65.google.com ([209.85.192.65]:35654 "EHLO mail-qg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755827AbcEQQ3C (ORCPT ); Tue, 17 May 2016 12:29:02 -0400 Received: by mail-qg0-f65.google.com with SMTP id b14so1829350qge.2 for ; Tue, 17 May 2016 09:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poochiereds-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NVHfI2m4vwevoqbnVn9iUral5RSJ7yh9Vy1+xzYH3LA=; b=F4xe+QkI6beP+I9k6q9qQ6eqSWapk3tva2Xfi6PFS0RvdcrIt8mvwk+/15JolqfNhB 9QVHUi7FQOCWSstnwuAJtAB4SoYfAJtLtwxDCWbc96KdL1UTRnlz1TYlGl2vj2EldpDK 4P4z5FOb2/wj7H3oDYg9r5jwzXpmqYmiiJCaX3BohN5vO5Oe2KW9l+sttafJ9DHUwTO+ bMrwNSGYw1PUEkguPnW35QWKf6ItFwcy4+T8SkthYTH4GM69hwYO2diWMHS2EeoZaycz Mtp1p8euJI5uPx0gBjS8QSJYevxu9Nh2/NJyqVcitbOlkE7kfo6FU9D9q85hKBeNmxFX pOAQ== 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=NVHfI2m4vwevoqbnVn9iUral5RSJ7yh9Vy1+xzYH3LA=; b=iRY86DdMNXK7SGbcjUyP2YbSrJ0hQI/ErA9znB4HVweEcVnlzRgFlIt3A4MDRuTJWt JxjqLL4ZzczXMXw/KQmUMO6Ni6VJ8EdKFN0SekqOXdSe9ORdJC0FBRhMJEvTu5A31DYl QEuuAz26wMxs5PXWlSMPt7jm7b228lON3SqfWiTgxLG+aEGvxa4T8haW49Y6FKK81inS 9HGl/DP4YX5zPO75v/T0wD6aHuCkkx3zi6Tj9cccqAz4xTmTS0tklf9YyxDaeKkhLJZe x01qGhWwTLcYo1SDSldv/sLE/GwUYBGeiXuNXundKIskjjUf/uOA6j5hToc1EDJv6yzp atkQ== X-Gm-Message-State: AOPr4FWAW0EgAPhehiwwHXMNEuz3h12TRM/pa2+FjEnDqynuI03COj5JYACyIrd9o9lxUw== X-Received: by 10.140.31.130 with SMTP id f2mr2540513qgf.69.1463502541311; Tue, 17 May 2016 09:29:01 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:4074:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id a31sm1685827qga.34.2016.05.17.09.29.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 May 2016 09:29:00 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: Trond Myklebust , Anna Schumaker Cc: Thomas Haynes , linux-nfs@vger.kernel.org, hch@lst.de Subject: [PATCH v4 06/13] pnfs: keep track of the return sequence number in pnfs_layout_hdr Date: Tue, 17 May 2016 12:28:41 -0400 Message-Id: <1463502528-11519-7-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463502528-11519-1-git-send-email-jeff.layton@primarydata.com> References: <1463502528-11519-1-git-send-email-jeff.layton@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=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 When we want to selectively do a LAYOUTRETURN, we need to specify a stateid that represents most recent layout acquisition that is to be returned. When we mark a layout stateid to be returned, we update the return sequence number in the layout header with that value, if it's newer than the existing one. Then, when we go to do a LAYOUTRETURN on layout header put, we overwrite the seqid in the stateid with the saved one, and then zero it out. Signed-off-by: Jeff Layton --- fs/nfs/pnfs.c | 11 ++++++++--- fs/nfs/pnfs.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 18b6f950e300..39432a3705b4 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -899,6 +899,7 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo) if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) return false; lo->plh_return_iomode = 0; + lo->plh_return_seq = 0; pnfs_get_layout_hdr(lo); clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); return true; @@ -969,6 +970,7 @@ static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo) 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); spin_unlock(&inode->i_lock); @@ -1747,7 +1749,8 @@ out_forget_reply: } static void -pnfs_set_plh_return_iomode(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode) +pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode, + u32 seq) { if (lo->plh_return_iomode == iomode) return; @@ -1755,6 +1758,8 @@ pnfs_set_plh_return_iomode(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode) iomode = IOMODE_ANY; lo->plh_return_iomode = iomode; set_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); + if (!lo->plh_return_seq || pnfs_seqid_is_newer(seq, lo->plh_return_seq)) + lo->plh_return_seq = seq; } /** @@ -1793,7 +1798,7 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo, continue; remaining++; set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags); - pnfs_set_plh_return_iomode(lo, return_range->iomode); + pnfs_set_plh_return_info(lo, return_range->iomode, lseg->pls_seq); } return remaining; } @@ -1811,7 +1816,7 @@ void pnfs_error_mark_layout_for_return(struct inode *inode, bool return_now = false; spin_lock(&inode->i_lock); - pnfs_set_plh_return_iomode(lo, range.iomode); + pnfs_set_plh_return_info(lo, range.iomode, lseg->pls_seq); /* * mark all matching lsegs so that we are sure to have no live * segments at hand when sending layoutreturn. See pnfs_put_lseg() diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 361fa5494aa5..3476c9850678 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -195,6 +195,7 @@ struct pnfs_layout_hdr { unsigned long plh_flags; nfs4_stateid plh_stateid; u32 plh_barrier; /* ignore lower seqids */ + u32 plh_return_seq; enum pnfs_iomode plh_return_iomode; loff_t plh_lwb; /* last write byte for layoutcommit */ struct rpc_cred *plh_lc_cred; /* layoutcommit cred */