Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp219884pxx; Wed, 28 Oct 2020 03:12:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLoi45dcWswhnDgCU0nHG2Lw4/PmPMLh4V6tM7pWwyZR+7ojShPReaedXXvI0BVzSa0J8P X-Received: by 2002:aa7:c3c8:: with SMTP id l8mr6901877edr.189.1603879926985; Wed, 28 Oct 2020 03:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603879926; cv=none; d=google.com; s=arc-20160816; b=vk5D7tFLQsYFCUhrOtlvMKoRx1NO0Gr8SDm3v/erOpktDVQmJP72du9jTGfRU0y8p5 TtDltLa+W6Idmk1S81ExBW2Slr8GOlbfVCUfq9XL72QDahTr5oXmatB3a3GfCqwq4H60 VwbwTRXd6FJl9rqcEg/UsJpkHfqEmtt5LE3JZN8jMVcEnSnRUQ8JH0xTyID4EyCcbp4O 0/TxLtiWgbOGQn6vevyoAQkSr3wdm6TgMpxpUxQ+YwvpzXX/h5IEMUxyHLCL92UXNpOa 73l+czxT1jibq3bKzjFO1WBXD+fjlc1HDA4RDp5ysxXGOoCItj+5kj23lfdVU+ab36a6 Y+Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sZ0lhMpdZ/YUX0A8aLcgCmhy1nHnSeAWyl/aa5M7Geg=; b=y6WcaqVFYSOQ2mKpf0IovjVN1KcCV8F5ChMqfoCrQvG5VtISIujjRZVo9KfhGrHr2t BwCtdCnsQp7a4sZGycIP8vRhCTxuIISVzw2WBdNg/EZI30Rw6ThRQUcu05q36zq5ZoyB 0dabP6qk0jdtUKyUWoHjVJ93n6Leu0XBsC16pVoZy9nrpoOV1cSXJnUyQNwAbBoPvi2j BCsDzu6nn2TOeQ6BVDtJS8GHi362QHNNXOwxGuI+KYAf1RVFRbUPTjFV3X2UGVneGb4m gd+z7GY56uoC9ddUybZIFCG4eJvmTHbanBZQ5nZMkn+6Ez7j1lbKjaJgq2f/O6TEe9wq 4sHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u6RezP6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si2654785ede.591.2020.10.28.03.11.44; Wed, 28 Oct 2020 03:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u6RezP6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760635AbgJ0Ofg (ORCPT + 99 others); Tue, 27 Oct 2020 10:35:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:33610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760418AbgJ0Oet (ORCPT ); Tue, 27 Oct 2020 10:34:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BF0ED2222C; Tue, 27 Oct 2020 14:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809287; bh=RbVpIclLUTesCsYKE9TAReEUwRspILDj7f9EGIco0dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u6RezP6L198VLchLaSdfRF8GdLivi7n9Lf1e/jzZp2Fhf8pXCjdG5hOld+pm/vJYS HPcwrV639+cD27N29f3lr92zqCoNCWUiPrXKjrmVigthglE3YL8mBRzfdW/0lY1vDI DZ/25MWofc6rFPdBQKcN/xqHuI6FtQb3dNTKCZ5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Matthew Wilcox (Oracle)" , "Darrick J. Wong" , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.4 142/408] iomap: Clear page error before beginning a write Date: Tue, 27 Oct 2020 14:51:20 +0100 Message-Id: <20201027135501.684781130@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox (Oracle) [ Upstream commit e6e7ca92623a43156100306861272e04d46385fc ] If we find a page in write_begin which is !Uptodate, we need to clear any error on the page before starting to read data into it. This matches how filemap_fault(), do_read_cache_page() and generic_file_buffered_read() handle PageError on !Uptodate pages. When calling iomap_set_range_uptodate() in __iomap_write_begin(), blocks were not being marked as uptodate. This was found with generic/127 and a specially modified kernel which would fail (some) readahead I/Os. The test read some bytes in a prior page which caused readahead to extend into page 0x34. There was a subsequent write to page 0x34, followed by a read to page 0x34. Because the blocks were still marked as !Uptodate, the read caused all blocks to be re-read, overwriting the write. With this change, and the next one, the bytes which were written are marked as being Uptodate, so even though the page is still marked as !Uptodate, the blocks containing the written data are not re-read from storage. Fixes: 9dc55f1389f9 ("iomap: add support for sub-pagesize buffered I/O without buffer heads") Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Sasha Levin --- fs/iomap/buffered-io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index a30ea7ecb790a..80867a1a94f26 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -559,6 +559,7 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, if (PageUptodate(page)) return 0; + ClearPageError(page); do { iomap_adjust_read_range(inode, iop, &block_start, -- 2.25.1