From patchwork Sun May 15 01:06:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9095821 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 047139F441 for ; Sun, 15 May 2016 01:07:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03CC62025A for ; Sun, 15 May 2016 01:07:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3E1220263 for ; Sun, 15 May 2016 01:07:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754018AbcEOBHI (ORCPT ); Sat, 14 May 2016 21:07:08 -0400 Received: from mail-qg0-f67.google.com ([209.85.192.67]:35664 "EHLO mail-qg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932368AbcEOBHD (ORCPT ); Sat, 14 May 2016 21:07:03 -0400 Received: by mail-qg0-f67.google.com with SMTP id b14so10260641qge.2 for ; Sat, 14 May 2016 18:07:03 -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=k0VUJ7VxonDLluYAgLvsEkm3BSWkPLNpz6Sz6ntm7Tk=; b=glNb7vM0sSxTa9TjkpnBlVFrbQHFr21l2Ec9J9ZtD7g/W+Ab8TURQ1ELJGo9fg4bVF C/QQ9YeK5ARWFvXY5mFX/cH9WsMm7yTwRejcSxJ/p6bmJ+ubHNphhCZZfWth2DloPjyo yyF8wIdQZDlP8bLQQ5sJCt2YVKGo2171znTor9AloLXhfpkHBLrBhm1fM4GeSloBX8YM qKaXQJg59Xsff8b4KW9p2wQduc7u1VL/0WmOj6+Vcu9jrQSIztp3GnlS/rq/ySw+IY6N NxfeuyceE7I7DgJJq7a5SjsN2v70qUJxe8c6oU/iQe7qZvpHRpNNr5S95EkETbY8I6bi YKEw== 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=k0VUJ7VxonDLluYAgLvsEkm3BSWkPLNpz6Sz6ntm7Tk=; b=RFsmj2B5e1NGM96DDlm96b0kLG/Snn8Ob8jl/6uFBremFsFJQbPqiXEjb5SW8BzCPA nVdO5xDRsuAhqSm9fv8oehv/Xnw4vqXYFN0vcrRwf/XL3JJ6E6b7MJI7QZwEn+RdZW2z UjiCVXpDmHGXVxV/aFOywYLz0+6C6LmKv0x3gvGlg2cnuTHN0UbK+7fjNLxSspr01sOx KXnMOImb9wJjrFYu4ViC9BY/XfIiW0WgkU+zXo3npNjyPm6iMIXFnzBmVrVsMOdVpxnt tHuRnF9FxLBMu7A07bEs77S0pEX/Z1+TTN10/ORU30P6B7sxoAmd3al5xJPGZtQf0N6X /ZDg== X-Gm-Message-State: AOPr4FV68hSUikZiLZWa6nDEnKkYqI8fk6sVSivcbi+lGbBXSUz3SiP/HXeVOO22LOawlw== X-Received: by 10.140.46.11 with SMTP id j11mr5379214qga.96.1463274422829; Sat, 14 May 2016 18:07:02 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:4074:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id d12sm11520330qhd.13.2016.05.14.18.07.01 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 14 May 2016 18:07:02 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, hch@infradead.org Subject: [PATCH v3 11/13] pnfs: lift retry logic from send_layoutget to pnfs_update_layout Date: Sat, 14 May 2016 21:06:40 -0400 Message-Id: <1463274402-17746-12-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463274402-17746-1-git-send-email-jeff.layton@primarydata.com> References: <1463274402-17746-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 If we get back something like NFS4ERR_OLD_STATEID, that will be translated into -EAGAIN, and the do/while loop in send_layoutget will drive the call again. This is not quite what we want, I think. An error like that is a sign that something has changed. That something could have been a concurrent LAYOUTGET that would give us a usable lseg. Lift the retry logic into pnfs_update_layout instead. That allows us to redo the layout search, and may spare us from having to issue an RPC. Signed-off-by: Jeff Layton --- fs/nfs/pnfs.c | 67 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 5f6ed295acb5..5a8c19c57f16 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -839,7 +839,6 @@ send_layoutget(struct pnfs_layout_hdr *lo, struct inode *ino = lo->plh_inode; struct nfs_server *server = NFS_SERVER(ino); struct nfs4_layoutget *lgp; - struct pnfs_layout_segment *lseg; loff_t i_size; dprintk("--> %s\n", __func__); @@ -849,42 +848,30 @@ send_layoutget(struct pnfs_layout_hdr *lo, * store in lseg. If we race with a concurrent seqid morphing * op, then re-send the LAYOUTGET. */ - do { - lgp = kzalloc(sizeof(*lgp), gfp_flags); - if (lgp == NULL) - return NULL; - - i_size = i_size_read(ino); - - lgp->args.minlength = PAGE_SIZE; - if (lgp->args.minlength > range->length) - lgp->args.minlength = range->length; - if (range->iomode == IOMODE_READ) { - if (range->offset >= i_size) - lgp->args.minlength = 0; - else if (i_size - range->offset < lgp->args.minlength) - lgp->args.minlength = i_size - range->offset; - } - lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE; - pnfs_copy_range(&lgp->args.range, range); - lgp->args.type = server->pnfs_curr_ld->id; - lgp->args.inode = ino; - lgp->args.ctx = get_nfs_open_context(ctx); - lgp->gfp_flags = gfp_flags; - lgp->cred = lo->plh_lc_cred; + lgp = kzalloc(sizeof(*lgp), gfp_flags); + if (lgp == NULL) + return ERR_PTR(-ENOMEM); - lseg = nfs4_proc_layoutget(lgp, gfp_flags); - } while (lseg == ERR_PTR(-EAGAIN)); + i_size = i_size_read(ino); - if (IS_ERR(lseg)) { - if (!nfs_error_is_fatal(PTR_ERR(lseg))) - lseg = NULL; - } else { - pnfs_layout_clear_fail_bit(lo, - pnfs_iomode_to_fail_bit(range->iomode)); + lgp->args.minlength = PAGE_SIZE; + if (lgp->args.minlength > range->length) + lgp->args.minlength = range->length; + if (range->iomode == IOMODE_READ) { + if (range->offset >= i_size) + lgp->args.minlength = 0; + else if (i_size - range->offset < lgp->args.minlength) + lgp->args.minlength = i_size - range->offset; } + lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE; + pnfs_copy_range(&lgp->args.range, range); + lgp->args.type = server->pnfs_curr_ld->id; + lgp->args.inode = ino; + lgp->args.ctx = get_nfs_open_context(ctx); + lgp->gfp_flags = gfp_flags; + lgp->cred = lo->plh_lc_cred; - return lseg; + return nfs4_proc_layoutget(lgp, gfp_flags); } static void pnfs_clear_layoutcommit(struct inode *inode, @@ -1646,6 +1633,20 @@ lookup_again: arg.length = PAGE_ALIGN(arg.length); lseg = send_layoutget(lo, ctx, &arg, gfp_flags); + if (IS_ERR(lseg)) { + if (lseg == ERR_PTR(-EAGAIN)) { + if (first) + pnfs_clear_first_layoutget(lo); + pnfs_put_layout_hdr(lo); + goto lookup_again; + } + + if (!nfs_error_is_fatal(PTR_ERR(lseg))) + lseg = NULL; + } else { + pnfs_layout_clear_fail_bit(lo, pnfs_iomode_to_fail_bit(iomode)); + } + atomic_dec(&lo->plh_outstanding); trace_pnfs_update_layout(ino, pos, count, iomode, lo, PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);