From patchwork Wed May 30 18:05:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10439529 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 1595D601E9 for ; Wed, 30 May 2018 18:06:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0409F290F0 for ; Wed, 30 May 2018 18:06:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECC34291AD; Wed, 30 May 2018 18:06:31 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 896F9291B7 for ; Wed, 30 May 2018 18:06:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753718AbeE3SGa (ORCPT ); Wed, 30 May 2018 14:06:30 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:36214 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932091AbeE3SGZ (ORCPT ); Wed, 30 May 2018 14:06:25 -0400 Received: by mail-io0-f194.google.com with SMTP id d73-v6so22697071iog.3 for ; Wed, 30 May 2018 11:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vhw2pkfOlPGNPr2zx7sh0HF0Di0752EZgNYekO5OuSc=; b=ssItbVii9imIvLcDiWURu90IrklR0ouJ7MGqXM5cKON6BJEu7N2MoxePAE6h+K5mSq OCV/4nS5fMQy8NUuPeYwQwy7Imlqzzl4mgcoKcChw2E0TrnhZ5FfQCstpRyIjnIJYWpD VVnh8TYhKUkSaxUQef7CqeVRh7cI9sE30ld7E+Eg0d7gAPYiD5m1Wd6Oa9bhJ/t0o0Si bCocoKXenEx8u+2r/We+Oznl5hD38bQza2on2rbZ45yDtkcTRcDIPwWZSiRbeSDAKMGJ cdZJVQv7hPny9XKEe0VDcQcmJmKj37ZqSudaZZiPArfWX6JHCqZ4kVa2aVFuACYYlPOY iy4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vhw2pkfOlPGNPr2zx7sh0HF0Di0752EZgNYekO5OuSc=; b=cZt/jQH2EnOAr2+l5nRFX3iJ+ItbLImSKrXjvLNeX9sDgt1wW1H0MakXsnOFXm9hSq K6ouLiMpcISpQwtlumdEZWDrMeZKWYeByWkQdCO5IZJKvKz8rCLUx1b3jbvdt3RI4NLt VQX8X6SKus8HWe9i7/6hp91qLeb3GRCms1O+Au0B4FV0HnFDQGR4iJ57YGjXg8T/yA64 SlZGuu20rAStewnpXd1Gqe2tJSKQEP+JzoEQVIXOs0HZ9b00aSyFkHvxsDjefH4XZHMP AfNIb6wohBePJukOUlGaX2pfYq9QS8yUmE3jZdlwZtkM6kD4Vme6ytIIxbjydr/MJYMo xD6A== X-Gm-Message-State: ALKqPwf34tgnkL2v5xZbEuFgHrxETG2VpohGxFSnY6jY7ZewNl9PYqo1 FjDoqwQ4pquYI/UMT5uMNgxX6Us= X-Google-Smtp-Source: ADUXVKJmJ97ogSaQCutS6Pc8GyCeySo87ym18nYppWB9JZuvpd8Wf6g8QI8F7CLUIxTf7M34IG/+wA== X-Received: by 2002:a6b:c6c9:: with SMTP id w192-v6mr3138847iof.131.1527703584725; Wed, 30 May 2018 11:06:24 -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 i201-v6sm8589368ite.33.2018.05.30.11.06.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 May 2018 11:06:24 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 09/19] pnfs: Change pnfs_alloc_init_layoutget_args call signature Date: Wed, 30 May 2018 14:05:43 -0400 Message-Id: <20180530180553.38769-10-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530180553.38769-9-trond.myklebust@hammerspace.com> References: <20180530180553.38769-1-trond.myklebust@hammerspace.com> <20180530180553.38769-2-trond.myklebust@hammerspace.com> <20180530180553.38769-3-trond.myklebust@hammerspace.com> <20180530180553.38769-4-trond.myklebust@hammerspace.com> <20180530180553.38769-5-trond.myklebust@hammerspace.com> <20180530180553.38769-6-trond.myklebust@hammerspace.com> <20180530180553.38769-7-trond.myklebust@hammerspace.com> <20180530180553.38769-8-trond.myklebust@hammerspace.com> <20180530180553.38769-9-trond.myklebust@hammerspace.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-Virus-Scanned: ClamAV using ClamSMTP From: Fred Isaman Don't send in a layout, instead use the (possibly NULL) inode. This is needed for LAYOUTGET attached to an OPEN where the inode is not yet set. Signed-off-by: Fred Isaman Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 11148414b9b6..07f1bbd9100c 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -916,18 +916,31 @@ pnfs_layoutgets_blocked(const struct pnfs_layout_hdr *lo) test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); } +static struct nfs_server * +pnfs_find_server(struct inode *inode, struct nfs_open_context *ctx) +{ + struct nfs_server *server; + + if (inode) + server = NFS_SERVER(inode); + else { + struct dentry *parent_dir = dget_parent(ctx->dentry); + server = NFS_SERVER(parent_dir->d_inode); + dput(parent_dir); + } + return server; +} + static struct nfs4_layoutget * -pnfs_alloc_init_layoutget_args(struct pnfs_layout_hdr *lo, +pnfs_alloc_init_layoutget_args(struct inode *ino, struct nfs_open_context *ctx, nfs4_stateid *stateid, const struct pnfs_layout_range *range, gfp_t gfp_flags) { - struct inode *ino = lo->plh_inode; - struct nfs_server *server = NFS_SERVER(ino); + struct nfs_server *server = pnfs_find_server(ino, ctx); size_t max_pages = max_response_pages(server); struct nfs4_layoutget *lgp; - loff_t i_size; dprintk("--> %s\n", __func__); @@ -944,16 +957,19 @@ pnfs_alloc_init_layoutget_args(struct pnfs_layout_hdr *lo, lgp->res.layoutp = &lgp->args.layout; - 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; + if (ino) { + loff_t i_size = i_size_read(ino); + + 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); @@ -962,7 +978,7 @@ pnfs_alloc_init_layoutget_args(struct pnfs_layout_hdr *lo, lgp->args.ctx = get_nfs_open_context(ctx); nfs4_stateid_copy(&lgp->args.stateid, stateid); lgp->gfp_flags = gfp_flags; - lgp->cred = lo->plh_lc_cred; + lgp->cred = ctx->cred; return lgp; } @@ -1838,7 +1854,7 @@ pnfs_update_layout(struct inode *ino, if (arg.length != NFS4_MAX_UINT64) arg.length = PAGE_ALIGN(arg.length); - lgp = pnfs_alloc_init_layoutget_args(lo, ctx, &stateid, &arg, gfp_flags); + lgp = pnfs_alloc_init_layoutget_args(ino, ctx, &stateid, &arg, gfp_flags); if (!lgp) { trace_pnfs_update_layout(ino, pos, count, iomode, lo, NULL, PNFS_UPDATE_LAYOUT_NOMEM);