Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6041175ybp; Tue, 15 Oct 2019 08:45:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9h73vNwlviCG6apE97hfGbwuTJANRoVfHFcrvWEs7aV+GzucGJykLvjO5I37lWickA6GB X-Received: by 2002:a17:906:cc90:: with SMTP id oq16mr34361194ejb.322.1571154314205; Tue, 15 Oct 2019 08:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571154314; cv=none; d=google.com; s=arc-20160816; b=JQEhBc4FAqt9izFA6NmDLK2eVdjIwuDEWcTMc1lxAChZ39+u+Gm5OWVdC3sm45bsNy D7X2SR+6CRJ/22ChTOUsigrd/ccacP+My6YJpTpUPJx6weOOXjiiuXqe76PF7PxpnRdG NEfR6sBSyiY6oSQLYZd9crpGRzfB+JLJG22XSBxfirMSF7G0PWPKFv559mS+TTwEAu/n 9SxuVa3Zm8VKtNdQkWouInVpIYjzTdsNs6jy1IpiSG0HJKlcjPsd4+z0dGWbkY5V/CJu m44532kRTKd7KFst0XcK8/+qGg+WggHPUzq9wRR3SClPN0jFCTk3QCsjjByHpINyWaBh L6vQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QuyT4qjP/N5LExRTgGT+wH3VMTfJMNLEgqsgddzXeSA=; b=Ri0lZ/1vpKD1CrM9a2ewg/dckXOF5b51XvX1ruukUS2svSSX0kRM3ywSnGB3sMDcjP X9IM0XZvz1UTIDAsBfPPcfRj4+643qmrquEs8K0bZOa1Fym+Xq7KUonk4BODeagK584v ZTbBVJyiGU13BKb3dR8BjalIEkdbskb3Ua4WaLJSpBn+3OAn0/i6me5YjMM0ogzqJVdW ymhbYGE5OuYtm4sVZ8zMgVEDgWtaqayUs0ebvO0nt/v49DrNEJfPc1hBQ8JW1B3013kG 1ES27U3FJd0X1B/hjbbtPRCITpSXLM6ykfJ0qhJ15wArDUF55/cFfRv7tZsQPg1kLs6g Rimg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bmG8Jlij; 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 n9si14324513ejs.94.2019.10.15.08.44.50; Tue, 15 Oct 2019 08:45:14 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bmG8Jlij; 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 S2387664AbfJOPoS (ORCPT + 99 others); Tue, 15 Oct 2019 11:44:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48094 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387623AbfJOPoQ (ORCPT ); Tue, 15 Oct 2019 11:44:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QuyT4qjP/N5LExRTgGT+wH3VMTfJMNLEgqsgddzXeSA=; b=bmG8Jlij7ZAtkwQ/XZmiWS7PjN FL9rEFngG6SQy6IFwCylqNZlOwfMt8f/TrluhqoPLWFq/uINHCy/eCJBFlkI8a7/HeC2E0scYaJxw UrqYfkGbi1T6sEt93NoGQ9k0mMxjAJ/Vh4kP6d+Be9/CJhacYtDO2UwmXSlnZG/I+vLBwDX5lyprG IxJhzBKMIxiVTC+ksyTeulnt4hQCXthuEk7VNeejSWhzMrLCNKnsP7lKVikWruxFAuwj9/Jrk8WrJ 44GMyji4s2JQIP+vGBB/AyAnbzUO0L5DNMfbW2PpYZQipsWkTZJd5mySoAWy6LGx9iqtVX0VyOJs+ SHpyOTtQ==; Received: from [2001:4bb8:18c:d7b:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iKOzb-0007x2-Az; Tue, 15 Oct 2019 15:44:11 +0000 From: Christoph Hellwig To: "Darrick J . Wong" Cc: Damien Le Moal , Andreas Gruenbacher , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/12] iomap: zero newly allocated mapped blocks Date: Tue, 15 Oct 2019 17:43:40 +0200 Message-Id: <20191015154345.13052-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191015154345.13052-1-hch@lst.de> References: <20191015154345.13052-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org File systems like gfs2 don't support delayed allocations or unwritten extents and thus allocate normal mapped blocks to fill holes. To cover the case of such file systems allocating new blocks to fill holes also zero out mapped blocks with the new flag. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/iomap/buffered-io.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index e25901ae3ff4..181ee8477aad 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -203,6 +203,14 @@ iomap_read_inline_data(struct inode *inode, struct page *page, SetPageUptodate(page); } +static inline bool iomap_block_needs_zeroing(struct inode *inode, + struct iomap *iomap, loff_t pos) +{ + return iomap->type != IOMAP_MAPPED || + (iomap->flags & IOMAP_F_NEW) || + pos >= i_size_read(inode); +} + static loff_t iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, struct iomap *iomap) @@ -226,7 +234,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, if (plen == 0) goto done; - if (iomap->type != IOMAP_MAPPED || pos >= i_size_read(inode)) { + if (iomap_block_needs_zeroing(inode, iomap, pos)) { zero_user(page, poff, plen); iomap_set_range_uptodate(page, poff, plen); goto done; @@ -532,7 +540,7 @@ iomap_read_page_sync(struct inode *inode, loff_t block_start, struct page *page, struct bio_vec bvec; struct bio bio; - if (iomap->type != IOMAP_MAPPED || block_start >= i_size_read(inode)) { + if (iomap_block_needs_zeroing(inode, iomap, block_start)) { zero_user_segments(page, poff, from, to, poff + plen); iomap_set_range_uptodate(page, poff, plen); return 0; -- 2.20.1