Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp828877imu; Tue, 11 Dec 2018 08:11:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vq8G6EhUiEG2dyANBOwgtxbdUuxpqKPOEIngSg84Di+7F7v5HYlHbUyeOvJsg2ZvTbF2q5 X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr15798529plh.302.1544544711939; Tue, 11 Dec 2018 08:11:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544544711; cv=none; d=google.com; s=arc-20160816; b=dN8MsNXzI5Q8WmmGdQHad1wdhYf/IHJoUOJPrtsa6FfwzrhtbolMwV5opfAtdUAllF hQcQ02bd6zX7l2Gg8p1FNmA6zrFhPbe0MttloDzI2n2cwJzxfXpG4eoWEGhZpvT9RgUq tF6EfPaMr+1XqebnQPyLI6Ojb6i2H1n4lgEh0bQcjSpJsvUNLKqLi5wax0iuym2iTyTK HyN0OiXtNDwV16/nkeH7584JMTRClSTHEg5U2fZYThZlT7+BwBTV59WZtWyOOYPrEGSz fJomEjRjNUUsVcJRP9xxZcKrtcZ4yvWwnJDs/H1XIP3p7utKLTt/6C10fhXRKPRi8KAs gEbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IwGUkEJKcu+IyhGK9dcW7TH8b+5u10x/Oq6qvXluNSY=; b=x2XaMnh0YmU3x9WY5kt1aIbW7rxVCd3oGS0kkYb1C0utfZGxprRAHY6gYoR60yBwKr aSWS0NiFs2ZxSJ9j3bECUsTiJCVgRPl0MmdlZFy+n5P30lhdyzBEYCKl1bTxvIMc73O1 jVZU9eanKsKcV4Y4b50vVqqlCB0ypAKT9vByfQjoiyT9C+xtX/BWdQXWOeH/SVu2wCSV V1VEa1fXwAJcp2bYFdK4vnxXj4vXHcaBja9/ArCNc7p5h1LP6BBFw7yRu83lfjggS5/p GNTBkE6g4+UJagh9lUR1MUYXn2OkMAV9zRt1FG19fgg4wV/9AG9PtGa214z/Ic2R1EZ7 PphA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PIU7t4Pr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si12557493pll.271.2018.12.11.08.11.36; Tue, 11 Dec 2018 08:11:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PIU7t4Pr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729620AbeLKPv5 (ORCPT + 99 others); Tue, 11 Dec 2018 10:51:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:40554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729605AbeLKPvx (ORCPT ); Tue, 11 Dec 2018 10:51:53 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA23520880; Tue, 11 Dec 2018 15:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543512; bh=7uSbKjd1y5//7PZ2oF7ahL0Iy92SW6xo1X+neNll30M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PIU7t4PrhvE8+26id/8P0cdo1T4pnJ9s6NyYnHDJ4zkCCNEIUfr14bJ1/JKrLtOGV DC2cH8pX1ns+fL6MkPZnFlbkVaqjGS3ELg2xbNH1CwrGBFlDU9mOiyeLLGeItkNBqt Om+C5T3vJPbwOeH6Rn1EyabOjvvcMXKNTMoi/uqs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tigran Mkrtchyan , Rick Macklem , Trond Myklebust , Sasha Levin Subject: [PATCH 4.14 26/67] flexfiles: use per-mirror specified stateid for IO Date: Tue, 11 Dec 2018 16:41:26 +0100 Message-Id: <20181211151631.719148510@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151630.378216233@linuxfoundation.org> References: <20181211151630.378216233@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit bb21ce0ad227b69ec0f83279297ee44232105d96 ] rfc8435 says: For tight coupling, ffds_stateid provides the stateid to be used by the client to access the file. However current implementation replaces per-mirror provided stateid with by open or lock stateid. Ensure that per-mirror stateid is used by ff_layout_write_prepare_v4 and nfs4_ff_layout_prepare_ds. Signed-off-by: Tigran Mkrtchyan Signed-off-by: Rick Macklem Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/flexfilelayout/flexfilelayout.c | 21 +++++++++------------ fs/nfs/flexfilelayout/flexfilelayout.h | 4 ++++ fs/nfs/flexfilelayout/flexfilelayoutdev.c | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index b0fa83a60754..13612a848378 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -1365,12 +1365,7 @@ static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data) task)) return; - if (ff_layout_read_prepare_common(task, hdr)) - return; - - if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, - hdr->args.lock_context, FMODE_READ) == -EIO) - rpc_exit(task, -EIO); /* lost lock, terminate I/O */ + ff_layout_read_prepare_common(task, hdr); } static void ff_layout_read_call_done(struct rpc_task *task, void *data) @@ -1539,12 +1534,7 @@ static void ff_layout_write_prepare_v4(struct rpc_task *task, void *data) task)) return; - if (ff_layout_write_prepare_common(task, hdr)) - return; - - if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, - hdr->args.lock_context, FMODE_WRITE) == -EIO) - rpc_exit(task, -EIO); /* lost lock, terminate I/O */ + ff_layout_write_prepare_common(task, hdr); } static void ff_layout_write_call_done(struct rpc_task *task, void *data) @@ -1734,6 +1724,10 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr) fh = nfs4_ff_layout_select_ds_fh(lseg, idx); if (fh) hdr->args.fh = fh; + + if (!nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid)) + goto out_failed; + /* * Note that if we ever decide to split across DSes, * then we may need to handle dense-like offsets. @@ -1796,6 +1790,9 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync) if (fh) hdr->args.fh = fh; + if (!nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid)) + goto out_failed; + /* * Note that if we ever decide to split across DSes, * then we may need to handle dense-like offsets. diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h index 679cb087ef3f..d6515f1584f3 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.h +++ b/fs/nfs/flexfilelayout/flexfilelayout.h @@ -214,6 +214,10 @@ unsigned int ff_layout_fetch_ds_ioerr(struct pnfs_layout_hdr *lo, unsigned int maxnum); struct nfs_fh * nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx); +int +nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg, + u32 mirror_idx, + nfs4_stateid *stateid); struct nfs4_pnfs_ds * nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index d62279d3fc5d..9f69e83810ca 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c @@ -369,6 +369,25 @@ out: return fh; } +int +nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg, + u32 mirror_idx, + nfs4_stateid *stateid) +{ + struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, mirror_idx); + + if (!ff_layout_mirror_valid(lseg, mirror, false)) { + pr_err_ratelimited("NFS: %s: No data server for mirror offset index %d\n", + __func__, mirror_idx); + goto out; + } + + nfs4_stateid_copy(stateid, &mirror->stateid); + return 1; +out: + return 0; +} + /** * nfs4_ff_layout_prepare_ds - prepare a DS connection for an RPC call * @lseg: the layout segment we're operating on -- 2.19.1