Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1283080ybg; Fri, 18 Oct 2019 15:11:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwje5oPHid5CX1CF0CpVgCdvqSTCJnN6+SIEbO/m9N6BzQB5kWZVb7102ZUnZLmBwDc0vws X-Received: by 2002:a05:6402:3c5:: with SMTP id t5mr11958367edw.125.1571436676469; Fri, 18 Oct 2019 15:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571436676; cv=none; d=google.com; s=arc-20160816; b=Arr+71aWxEI7iLp6sdGpG10YtSpYY6rhXDCCSQMXW3pOfnDegPxGt2nlwV1x7p1wZp 7TV3vQ5ZRpbAvhdFti7KVQqUwpJ7V2o/unFt9MxmIkqOL833IumE3JWrjm6l5NXthyPh CmEDUIpxg2TY+6JE7wHt/urDgF6nVde07SsKJhglpvAKsORaWiXWHByrnzdXh2VZQaT2 /DPZpnRZ2Q7jfkEL7rSRM4H+sG3RVlm3eDhX/WlCfmlGTS14PShw56bSW/C6DyS/3vvn nquLg5G1pFK1vGbiApg1qnbJue1qlURpimO55k7vYy46v+Gc/q8NK1buSJSy2ymvreHw 1luA== 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=xa2gfAqianHfXMXDC3EAxZSCqzWwbZtbxVA7gYTExh4=; b=ZAc+O1ojhjsmWdUz0OhoFkBlJTsF9hlUfVIRoCS4EIpi6JvkmsjcoI8TJF1YWUAU3X /OYEXgKbJRXmFJkzGZXXi521SnLCiQ7GSSd30F3baOKSMlyL+6cuAdcX+ZxUQD4Fh0Ao Ay7QqMgOZxvz0NT/THII9ATszVqHCpCweKVGef+NwOWPfOFo3XZLOQgGCDSalnYRIwXH 9M9n1W2xbtmKZUTOhJ4A5Y7mqRyFu+bbOKygL07IdkX3Ft37GDC/lbC/thmKfDnoh1x2 zf7LL+NsdIddWc9WfrWdM5Wadz/pzFQCZfjm2Kbixia6kvj7B0DcAAqepkuIEnFIwKys Ye4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=BWVQUr6+; 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 p22si4242499ejf.278.2019.10.18.15.10.53; Fri, 18 Oct 2019 15:11:16 -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=BWVQUr6+; 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 S2394974AbfJQR4y (ORCPT + 99 others); Thu, 17 Oct 2019 13:56:54 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48428 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440825AbfJQR4x (ORCPT ); Thu, 17 Oct 2019 13:56:53 -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=xa2gfAqianHfXMXDC3EAxZSCqzWwbZtbxVA7gYTExh4=; b=BWVQUr6+bJxXtJKuyiy1lkWTPQ HObnCKuf3QevYGMJiRYezmwsHFzKK5ZqJKW1l9CYiACFl9GaUZti0rzAfxCpS/j9DDa8QgUl8LxRy v9j1E39jlj14SCV3CdbxTn+f+vB9PPv8MLtD6P+QfT9XEhYqe3RB47PbFemWr2fFd7sawhoPc03wa zn2SiNTICWthrR8qAMxgFv7ewjJVkdOGNcJJxsjfULqSwzT3ci2rKTkFagoGBpy6gt0rUO6PiY7w8 GYMtcIo5Gd0G5lTf/swekAejuCmQNiMETTUB8W7IMIdbNXmgSP86fYF0vbv0IaidV8LcX98U5XFgE zWGt0bUA==; 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 1iLA13-000128-BX; Thu, 17 Oct 2019 17:56:49 +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, Dave Chinner Subject: [PATCH 08/14] iomap: zero newly allocated mapped blocks Date: Thu, 17 Oct 2019 19:56:18 +0200 Message-Id: <20191017175624.30305-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017175624.30305-1-hch@lst.de> References: <20191017175624.30305-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: Dave Chinner 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