From patchwork Wed Nov 25 18:43:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7702321 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 5BB2DBF90C for ; Wed, 25 Nov 2015 18:43:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6899A20877 for ; Wed, 25 Nov 2015 18:43:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FE3C20867 for ; Wed, 25 Nov 2015 18:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751065AbbKYSnX (ORCPT ); Wed, 25 Nov 2015 13:43:23 -0500 Received: from mail-qg0-f47.google.com ([209.85.192.47]:35415 "EHLO mail-qg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbbKYSnW (ORCPT ); Wed, 25 Nov 2015 13:43:22 -0500 Received: by qgec40 with SMTP id c40so38555887qge.2 for ; Wed, 25 Nov 2015 10:43:21 -0800 (PST) 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; bh=j2ntIm7p424/b/OvZV0f8bIk2Gs5KpyHLn6wBHka5nE=; b=mHmMzU4/WjXWi2RsQiyIAk8H6P+ys74GNK6V56XGtl+TArrEoGvf056LlRxVOuemZ+ CKi6MNcJQDzmnxoSCTNcVq7eQvaFdYAjJfn+PrzCT22ijRftG8GHXOZL5MdvhuZdhNT/ acVfSAQxrQqFZvfVyZD+Qm9ac7egg4saPH4SdVReKhc8W4QVLuP3sWheoOTUqYoLMlMY +ljj1H4HNC2s3HRxIa0aWFlXxKzWy3VsqrH8RGr85o0Zn65x5d3F7/32uPJgKFHR+ewl 314F4qMZ770sDgFBkgGfGnEFhE0hmaG6uuX8c6ZAIIg8zgtdEuJ6cj0865CPvcHHfh+p BF1g== 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; bh=j2ntIm7p424/b/OvZV0f8bIk2Gs5KpyHLn6wBHka5nE=; b=OMn89uVV3JalmtHorudyGEvJKF1drgIbuASgnaSShYFK5GDjRwz/1h9QCkjdlNIDD6 JoPqY2kH4WmufX1qsFMWCT1bT6sCdfugvTHXDEYW6k/esNlY55NzMLZPPfMzN5ho5NG1 4jIJgXsqzHNCogS3JvR3eU5Lt15akaF39gX5OZKnSQrBO2hFmLGy52HKDX/41OwhMf7p HH6z/2KJXHrWS32WipZ0y+DBqmDlCegDjnMjigFyj/rWaucfOd79LqgU5rfLmawyPw5H MKHEVcruw6WDPFKWIfXkP+acqFWUUNX/l29lNm1Z+V8qnWbjQbCBfN/2l65+7tPsnOqp kybw== X-Gm-Message-State: ALoCoQnsWS4FC/ijXrWAdJoZm03yko68isDhTChyWWDjbB0iEBkB0mPdLIOo4hF8LknNiUXCUgvK X-Received: by 10.140.84.202 with SMTP id l68mr40585851qgd.21.1448477001267; Wed, 25 Nov 2015 10:43:21 -0800 (PST) Received: from tlielax.poochiereds.net ([2606:a000:1125:4075::d5a]) by smtp.googlemail.com with ESMTPSA id c80sm5894406qkj.4.2015.11.25.10.43.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Nov 2015 10:43:19 -0800 (PST) From: Jeff Layton X-Google-Original-From: Jeff Layton To: trond.myklebust@Primarydata.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfs4: resend LAYOUTGET when there is a race that changes the seqid Date: Wed, 25 Nov 2015 13:43:14 -0500 Message-Id: <1448476994-17047-1-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 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 pnfs_layout_process will check the returned layout stateid against what the kernel has in-core. If it turns out that the stateid we received is older, then we should resend the LAYOUTGET instead of falling back to MDS I/O. Signed-off-by: Jeff Layton --- fs/nfs/pnfs.c | 58 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 49e1489563b7..3688189ac2b2 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -872,33 +872,38 @@ send_layoutget(struct pnfs_layout_hdr *lo, dprintk("--> %s\n", __func__); - lgp = kzalloc(sizeof(*lgp), gfp_flags); - if (lgp == NULL) - return NULL; - - i_size = i_size_read(ino); - - lgp->args.minlength = PAGE_CACHE_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; - 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; - - /* Synchronously retrieve layout information from server and - * store in lseg. + /* + * Synchronously retrieve layout information from server and + * store in lseg. If we race with a concurrent seqid morphing + * op, then re-send the LAYOUTGET. */ - lseg = nfs4_proc_layoutget(lgp, gfp_flags); + do { + lgp = kzalloc(sizeof(*lgp), gfp_flags); + if (lgp == NULL) + return NULL; + + i_size = i_size_read(ino); + + lgp->args.minlength = PAGE_CACHE_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; + 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; + + lseg = nfs4_proc_layoutget(lgp, gfp_flags); + } while (lseg == ERR_PTR(-EAGAIN)); + if (IS_ERR(lseg)) { switch (PTR_ERR(lseg)) { case -ENOMEM: @@ -1713,6 +1718,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) /* existing state ID, make sure the sequence number matches. */ if (pnfs_layout_stateid_blocked(lo, &res->stateid)) { dprintk("%s forget reply due to sequence\n", __func__); + status = -EAGAIN; goto out_forget_reply; } pnfs_set_layout_stateid(lo, &res->stateid, false);