Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3686209pxb; Mon, 24 Jan 2022 15:20:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlNadRC/22kPWAapQUOsOEcmBx/HE0daSgwR/SIwKJP7CAineJDpRd4xcZIm8+X+GtpR+t X-Received: by 2002:a05:6a00:c88:b0:4c8:cc0d:6da with SMTP id a8-20020a056a000c8800b004c8cc0d06damr8157941pfv.36.1643066333890; Mon, 24 Jan 2022 15:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066333; cv=none; d=google.com; s=arc-20160816; b=rwopqDbnLFXCZbgPCIE515FiJ5O4amwFjdWU2W8uerOODOndI9TKFjiU03ibCi5Pvz 9JVSUOlL8RitgUET+PN4xU8PFSXg2G0Un8jOxdoxg/drQ1VQsyAkrxuqTfs0MXasnU2V suiP/1llCQ/yn+2MqqIhVTzR0yTMrbDPQidnFLYHxdvFenA6BNIooIWvi0C5kX3r5LjO MdB+e/5jBvMDw9UGdsIz7SzNJsFIUetcb2c4XPgD29UuZ3zY2jeXUiKIEADZrAHVmUT9 T0fT/SdiHTzEOB8vl5lntsyaSZxPaBni/d24YFuuBxflUSc/B1aVjRhKDboR5osrNTpc 4JuQ== 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=BbpPRRhvsmY23SYApNUZkHQfDQIQjh0vivpUhHCU1sw=; b=xT+v7dexLlUIWOgQhAxfnkARRbtgpeeWTzLbAit1mrm0bRRXB1LY4F4h9SyLVGiW/w EcZuM4RCuXnqt478ZgsjSY5m6lJAVIEIUN9rng4gc9CerRxaZmO2mof16Kcmtrdq6w1v hgne49bt5w5j9nEHS7xeygT7hibLYtgfiXu0GmSMFitjxpz5h6Rc+/KtQMp9G8vsr7pK xPWdq0vlhLJgJAD4fYDesaqzG+WXIBpSpdvdWLS50/+TbYKQTxPKUjj8a1ToDnkSkvUg VNSY4QUoAw1Im2cB3IAFbaehk2fH3ddkiGcTG1wPBBrXYUFk57duLcgpcDzSGfdzYVll +Bqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e9fQLygi; 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=pass (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 oc10si659817pjb.183.2022.01.24.15.18.42; Mon, 24 Jan 2022 15:18:53 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=e9fQLygi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1846590AbiAXXQ0 (ORCPT + 99 others); Mon, 24 Jan 2022 18:16:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355736AbiAXWRZ (ORCPT ); Mon, 24 Jan 2022 17:17:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B072C04A2E7; Mon, 24 Jan 2022 12:46:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AD8B260C19; Mon, 24 Jan 2022 20:46:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 741BAC340E5; Mon, 24 Jan 2022 20:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057170; bh=XW8EBVukJqabCDHUK9SB0/ExquUtJR3sz0r9yhX2yWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e9fQLygi4I1piEJsSzh4GS1bBQ0CFQAy70dd+qX0KSu6KeSSeZ7t68woQ72n18IXs L32ZhtqZmqY2KosWqjSMT+ir9qeSszgUElfjHJC1nV4+q0c6OabKPOk7JF6gHnCL9f 3rfLFni3zdY88x0l+3pgVWN3/kV2zlnjsG/gkVs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Yin , Harshad Shirwadkar , Theodore Tso , stable@kernel.org Subject: [PATCH 5.15 717/846] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE Date: Mon, 24 Jan 2022 19:43:54 +0100 Message-Id: <20220124184125.755716147@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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: Xin Yin commit 5e4d0eba1ccaf19f93222abdeda5a368be141785 upstream. when call falloc with FALLOC_FL_ZERO_RANGE, to set an range to unwritten, which has been already initialized. If the range is align to blocksize, fast commit will not track range for this change. Also track range for unwritten range in ext4_map_blocks(). Signed-off-by: Xin Yin Reviewed-by: Harshad Shirwadkar Link: https://lore.kernel.org/r/20211221022839.374606-1-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/extents.c | 2 -- fs/ext4/inode.c | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4645,8 +4645,6 @@ static long ext4_zero_range(struct file ret = ext4_mark_inode_dirty(handle, inode); if (unlikely(ret)) goto out_handle; - ext4_fc_track_range(handle, inode, offset >> inode->i_sb->s_blocksize_bits, - (offset + len - 1) >> inode->i_sb->s_blocksize_bits); /* Zero out partial block at the edges of the range */ ret = ext4_zero_partial_blocks(handle, inode, offset, len); if (ret >= 0) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -741,10 +741,11 @@ out_sem: if (ret) return ret; } - ext4_fc_track_range(handle, inode, map->m_lblk, - map->m_lblk + map->m_len - 1); } - + if (retval > 0 && (map->m_flags & EXT4_MAP_UNWRITTEN || + map->m_flags & EXT4_MAP_MAPPED)) + ext4_fc_track_range(handle, inode, map->m_lblk, + map->m_lblk + map->m_len - 1); if (retval < 0) ext_debug(inode, "failed with err %d\n", retval); return retval;