Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp683830ybv; Thu, 13 Feb 2020 07:43:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyvfHWQkqE8CuqbQDJVjUGYITb+RmoHsqJY3YLetKrI+SXqqrr8qEztEZL16spMFGzewGm9 X-Received: by 2002:a05:6830:1e64:: with SMTP id m4mr14427901otr.244.1581608594900; Thu, 13 Feb 2020 07:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608594; cv=none; d=google.com; s=arc-20160816; b=n0eR595Rev2HXJNV7qTAglb3thuXKM2LV5xoorp1XeWwYaoDWXH7NpbxQjE178sWHs jWV7Pj8V8oM4f7NoBHq08flTfwc4/E8mFqhw9HnFQhtU49rce4b/M8veXr4kEd9ju1Kt yjuHvht8ebXnzJo26ZeEVNjIj9IIIGZZvHa4kppkVgITnYiKuj9TavN7URKPfA5AL7+o ue9N7136Pr0+VTskqXj8HnJex5NvsULHuR2M8LyeMr2cPpkvHF9MmsgrOnABqL58sLGU 7IJXe38Mkt9rc0+AylDncJtn51GU6Kb0xMWUZa7/kuy4einJ6G5GX57Nj0X7AwqyXeh4 DvAw== 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=QEGpdRpzN2Pwo1t2gYbSlGlVuO9YS44AKEqYVvohUv0=; b=FANsZUNWVKp+gMLx6rQsNOozrVdBR9Y6clJhmPYAPsB6r3XwJ5zBS2uh47EdEXXjmf 2ui8Lg5jztPsEDdhMLYSkDqntjwqY2rYjc8znwimuQghd4J9IonHlHT1LFWWchg/9HWq 39IJ5Z8QxJrlQLJ3+XPaC1FYgkD86i/qQx6Oi8AqnOLaApwoDy/LYI7glnSCEG9fsAqf GJaGSrNOgWrJ6GaUGI+AwL2Wu9/6tojAGszaUqfjROg8xoX864PT84SgECEWr1oH8Xy7 kkeYNriifduiIFN5ADFP7GFIUuH5yXOwwV8FVfZDXD3bBLeEUATpCeNXamMUK7iTuPmJ 0Zbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nnADpDze; 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 d6si1307577ote.72.2020.02.13.07.43.01; Thu, 13 Feb 2020 07:43:14 -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=nnADpDze; 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 S1729839AbgBMPmb (ORCPT + 99 others); Thu, 13 Feb 2020 10:42:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:54792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728802AbgBMP2M (ORCPT ); Thu, 13 Feb 2020 10:28:12 -0500 Received: from localhost (unknown [104.132.1.104]) (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 AAA1A222C2; Thu, 13 Feb 2020 15:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607691; bh=dBjMwYiib9tdGRpo7RTRVgn9LZnKD9lqcHjCVdNjL9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nnADpDzebvLstqUVpNEa+gryVahNDh+C1GNkOH7LRST70CiSHSLMRKviUIU4l+2o8 dET5gXRBVDUE/zkdL3/536+OXAvTY2KHJuMlh4cdlpLyuGjMMbdLTvFkB2Jo1eJ/VE JxYi811IorB7QS8wB3CXh+4YP21oav9uQy8JWeDI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Anna Schumaker Subject: [PATCH 5.5 030/120] NFS/pnfs: Fix pnfs_generic_prepare_to_resend_writes() Date: Thu, 13 Feb 2020 07:20:26 -0800 Message-Id: <20200213151912.218866135@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151901.039700531@linuxfoundation.org> References: <20200213151901.039700531@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Trond Myklebust commit 221203ce6406273cf00e5c6397257d986c003ee6 upstream. Instead of making assumptions about the commit verifier contents, change the commit code to ensure we always check that the verifier was set by the XDR code. Fixes: f54bcf2ecee9 ("pnfs: Prepare for flexfiles by pulling out common code") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- fs/nfs/direct.c | 4 ++-- fs/nfs/nfs3xdr.c | 5 ++++- fs/nfs/nfs4xdr.c | 5 ++++- fs/nfs/pnfs_nfs.c | 7 +++---- fs/nfs/write.c | 4 +++- 5 files changed, 16 insertions(+), 9 deletions(-) --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -245,10 +245,10 @@ static int nfs_direct_cmp_commit_data_ve data->ds_commit_index); /* verifier not set so always fail */ - if (verfp->committed < 0) + if (verfp->committed < 0 || data->res.verf->committed <= NFS_UNSTABLE) return 1; - return nfs_direct_cmp_verf(verfp, &data->verf); + return nfs_direct_cmp_verf(verfp, data->res.verf); } /** --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c @@ -2334,6 +2334,7 @@ static int nfs3_xdr_dec_commit3res(struc void *data) { struct nfs_commitres *result = data; + struct nfs_writeverf *verf = result->verf; enum nfs_stat status; int error; @@ -2346,7 +2347,9 @@ static int nfs3_xdr_dec_commit3res(struc result->op_status = status; if (status != NFS3_OK) goto out_status; - error = decode_writeverf3(xdr, &result->verf->verifier); + error = decode_writeverf3(xdr, &verf->verifier); + if (!error) + verf->committed = NFS_FILE_SYNC; out: return error; out_status: --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -4313,11 +4313,14 @@ static int decode_write_verifier(struct static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) { + struct nfs_writeverf *verf = res->verf; int status; status = decode_op_hdr(xdr, OP_COMMIT); if (!status) - status = decode_write_verifier(xdr, &res->verf->verifier); + status = decode_write_verifier(xdr, &verf->verifier); + if (!status) + verf->committed = NFS_FILE_SYNC; return status; } --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c @@ -31,12 +31,11 @@ EXPORT_SYMBOL_GPL(pnfs_generic_rw_releas /* Fake up some data that will cause nfs_commit_release to retry the writes. */ void pnfs_generic_prepare_to_resend_writes(struct nfs_commit_data *data) { - struct nfs_page *first = nfs_list_entry(data->pages.next); + struct nfs_writeverf *verf = data->res.verf; data->task.tk_status = 0; - memcpy(&data->verf.verifier, &first->wb_verf, - sizeof(data->verf.verifier)); - data->verf.verifier.data[0]++; /* ensure verifier mismatch */ + memset(&verf->verifier, 0, sizeof(verf->verifier)); + verf->committed = NFS_UNSTABLE; } EXPORT_SYMBOL_GPL(pnfs_generic_prepare_to_resend_writes); --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1837,6 +1837,7 @@ static void nfs_commit_done(struct rpc_t static void nfs_commit_release_pages(struct nfs_commit_data *data) { + const struct nfs_writeverf *verf = data->res.verf; struct nfs_page *req; int status = data->task.tk_status; struct nfs_commit_info cinfo; @@ -1864,7 +1865,8 @@ static void nfs_commit_release_pages(str /* Okay, COMMIT succeeded, apparently. Check the verifier * returned by the server against all stored verfs. */ - if (!nfs_write_verifier_cmp(&req->wb_verf, &data->verf.verifier)) { + if (verf->committed > NFS_UNSTABLE && + !nfs_write_verifier_cmp(&req->wb_verf, &verf->verifier)) { /* We have a match */ if (req->wb_page) nfs_inode_remove_request(req);