Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3295639ybp; Sun, 6 Oct 2019 08:51:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3ExdLiv85OELlfjYk730FbFyX471MpVcospr2KkS9GXbVrT3yZc6csfLIBqzzf/pnRZZp X-Received: by 2002:a50:b501:: with SMTP id y1mr24874361edd.167.1570377090840; Sun, 06 Oct 2019 08:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570377090; cv=none; d=google.com; s=arc-20160816; b=NeKGTGTa4dR8RB5utVYoA49iACMiPq2AdpWo9oxsdjT4yuSvttVr8gR9sq8TKt8Y7e tlNPP/9FAn74Rt6jUpIHrWKj7if77tjnvU99cVIdVBkd7RGZbWhLGbSYtdGD+YDXN0Ct SmkDq3dz23o3C3t6jlPHXZDW2JXKncsae1S9MhJfBOlM9vtbqvXMqlMwGeRzv50fZMtM rlJHuwBNAL7escm4+qSkIyWn10Wujnm+3KF8U8xE6A/rOl1Gy8EY88w5BE1GgZ36slX9 aCJk56H1S3V4yoO9IKa88uBmunJfpT3DLCEY+6/t4dnFzCzVh+Yt93Pzy8QBgLZru1Oq jvUA== 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=kskppOSJpC2+f0PmdqX+/uMUoW32qU3S5s1t8sYooIg=; b=Vh/Cg4uJRmSw8v9Rw1CL0rlzx6bxl6VK1YwHFAIZTae4Vi+m0WWpGEu1SEsnBElyvh dHjPW/l+SDsWBB3bZ1GeA/p9Nco+uTEBDv8VuuHsb5pIllwUAUEqY4cH2rFZpcEf0tBn mGEnxaaJhgb7pQOp9ABpjZAfgqDCmFaGjxMwyJ3N6KeJ4DTzHo+rh1GLLV2J8SnKPIPk qHqMsVmY8gk5f3uCx/SFGp2FGuGu+eX2b0FSngaLlBEL4nqyPWY6dE2wuCXFG4hgqqBy gCf71At8CTj2Lf+dWnydXe2Zly3mQGwgz35jYxpwQ1nPjksHgyx2QiARh6AWvCOOGua5 G3xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sh0xOcNa; 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 r17si5718799ejz.381.2019.10.06.08.51.07; Sun, 06 Oct 2019 08:51:30 -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=sh0xOcNa; 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 S1727084AbfJFPtT (ORCPT + 99 others); Sun, 6 Oct 2019 11:49:19 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:53522 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbfJFPsh (ORCPT ); Sun, 6 Oct 2019 11:48:37 -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=kskppOSJpC2+f0PmdqX+/uMUoW32qU3S5s1t8sYooIg=; b=sh0xOcNalQDTSNtUETgvlgbZDw C3SlA4ApX7FUjGPPqX5AHNLuuxcCLQwWbCl5RJi0VwpKeyqdXTatRtAfnVKNF2XMwKg3q3cJzE1/D Gwl63mIoQcbLzze9FxPDio0Y+jZ2VM76zadCCNdQsQtbVvMORQZmff+4cDDnbHW2hmECgI9G1BnXY NDKz7iizDUZeqXrBHwcynlm9udXvrBA3hJSG8R0rXyXMfr6sSxs48TRpjdY6F0UD/fTOVN1Fd/ovV wmAG7+gd8XGcqcu5Ek39umaOpK2VfOJJwhNAhkPNC1oZVdCY6jQ2bYRJa7xaYcnRIfzpZirl6nzCk 7/RVeYMQ==; Received: from [2001:4bb8:18c:4d4a:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1iH8lv-0008Sy-8y; Sun, 06 Oct 2019 15:48:35 +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 05/11] iomap: zero newly allocated mapped blocks Date: Sun, 6 Oct 2019 17:46:02 +0200 Message-Id: <20191006154608.24738-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191006154608.24738-1-hch@lst.de> References: <20191006154608.24738-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 Signed-off-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 23cc308f971d..4132c0cccb0a 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -207,6 +207,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) @@ -230,7 +238,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; @@ -544,7 +552,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