Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1010748ybe; Wed, 4 Sep 2019 11:06:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLaWfNzPjKmlon+MOVup22nWPQplmPpk2sHiiiC+AskVxyJPXO5aHuEt/5YWlaZ23oqASB X-Received: by 2002:a17:90a:2ecb:: with SMTP id h11mr6166677pjs.108.1567620393747; Wed, 04 Sep 2019 11:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620393; cv=none; d=google.com; s=arc-20160816; b=rNWSXJfBbXlZhIdSUvlVRCTyd4pMzYqiIyE8sWFA6cvmz5QCMRRcvJe8evKuf3gT4V YZKLLJKoBDTC0ZuGinCA7TduZC6vJvQ5MKPtXA2QoyllKH4Wisso5X9j9VXTj5MX6hwB Dz9xp3DZayUiPu9sJlf/KJh/jVW/A4NknDEMT37u5JPm1JWi3/qEi1W1LHf0Z0x7kfFf zj8WGnrlQVC6diG+PnReWQr4QeehNzuoKEjwtrEHJu+CnHGfgCsiGY3KVjf+Z2RZbQna FvBb+6FAD2CrQzzwAqvmnRWSWEVMZjTAFefmP06LKRYpKgIXOlTp9I2qA3jz+E2DHKve l+xA== 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=+mt0gAWmZ6lOc0O39nm9+UPSpn1dg8XBNKZnnYtRcTs=; b=BguHhR4r3pGki2hoVnawwcrw5g1iyVISRNGCnOew3QtNqAZwVWYj7iINLznMfB8Los J3xNcDFsuEC2sUZ+5rEc9aouIUrt2iVSi2x49E/SKmlSgKqLn+c05YjkAoOXQCUkK1rD heVwtr08N6211nPnYc8FfdMz08YxHzv3plHnGNVsGpMMzlrP851ZuzRvzIaqsXV8zI5e tCHj01v5rr53HZWtjWaN/aA2naYI90gHuVzoz+nR2W1yune4dmEcKMizmFQfolqWis8O fG4SI7v5Zwpa5aD2iy/L3772hDFRqBoTN5Glw8P4jHGq+bF605xNSR6hPZmS1A/4Xp7d eQxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z1oy6HCu; 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 s18si2796033pjq.43.2019.09.04.11.06.13; Wed, 04 Sep 2019 11:06:33 -0700 (PDT) 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=z1oy6HCu; 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 S2389109AbfIDSEg (ORCPT + 99 others); Wed, 4 Sep 2019 14:04:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:45634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388779AbfIDSEe (ORCPT ); Wed, 4 Sep 2019 14:04:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 D16672339E; Wed, 4 Sep 2019 18:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620273; bh=tP8I2ZaoMloWQlVziD5FUF5Ro94e9196WHs3Dd3Fk6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z1oy6HCu/OWT6IK6kWxtATn1Vsc2YF7ZbUsH+knmZtYOBzdXkE4Jv3sZQs9tYX51L GTMd2x9wHOwP5rY1A3hxQA/7xIRwBSHhkHnrdfS3grOOFPvk2vHY8wBq2GICnuD/mb I5E+/eu+EWpot40wvsjlZ+sU6qkby4ZTWdiLeaR0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 4.14 55/57] NFS: Ensure O_DIRECT reports an error if the bytes read/written is 0 Date: Wed, 4 Sep 2019 19:54:23 +0200 Message-Id: <20190904175307.283207287@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175301.777414715@linuxfoundation.org> References: <20190904175301.777414715@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 [ Upstream commit eb2c50da9e256dbbb3ff27694440e4c1900cfef8 ] If the attempt to resend the I/O results in no bytes being read/written, we must ensure that we report the error. Signed-off-by: Trond Myklebust Fixes: 0a00b77b331a ("nfs: mirroring support for direct io") Cc: stable@vger.kernel.org # v3.20+ Signed-off-by: Sasha Levin --- fs/nfs/direct.c | 27 ++++++++++++++++++--------- fs/nfs/pagelist.c | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 2256ea4394d3a..614ce1f8b4ac5 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -400,15 +400,21 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) unsigned long bytes = 0; struct nfs_direct_req *dreq = hdr->dreq; - if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) - goto out_put; - spin_lock(&dreq->lock); - if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) && (hdr->good_bytes == 0)) + if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error = hdr->error; - else + + if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { + spin_unlock(&dreq->lock); + goto out_put; + } + + if (hdr->good_bytes != 0) nfs_direct_good_bytes(dreq, hdr); + if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) + dreq->error = 0; + spin_unlock(&dreq->lock); while (!list_empty(&hdr->pages)) { @@ -774,16 +780,19 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) bool request_commit = false; struct nfs_page *req = nfs_list_entry(hdr->pages.next); - if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) - goto out_put; - nfs_init_cinfo_from_dreq(&cinfo, dreq); spin_lock(&dreq->lock); if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error = hdr->error; - if (dreq->error == 0) { + + if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { + spin_unlock(&dreq->lock); + goto out_put; + } + + if (hdr->good_bytes != 0) { nfs_direct_good_bytes(dreq, hdr); if (nfs_write_need_commit(hdr)) { if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 16d7f9068c7ae..132e568524dff 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1247,6 +1247,7 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, if (!list_empty(&pages)) { int err = desc->pg_error < 0 ? desc->pg_error : -EIO; hdr->completion_ops->error_cleanup(&pages, err); + nfs_set_pgio_error(hdr, err, hdr->io_start); return err; } return 0; -- 2.20.1