Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3685416pxb; Mon, 24 Jan 2022 15:19:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzhT8BiXm0Mq0d19RCOffeUMxi4Zgb7aZP9XXNdFNCFDtvQeRcmZkbP5r+iNZXJD9X90tz X-Received: by 2002:a17:90b:1c88:: with SMTP id oo8mr573778pjb.218.1643066346305; Mon, 24 Jan 2022 15:19:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066346; cv=none; d=google.com; s=arc-20160816; b=FvUed9Cn9v35YEWqumItTf/5AozNfn7CyN7ReCysC4M5xZGESDK2Cna/qU2I6mk6w9 Ac0rKrEC5uzg0m7JRKrkD/9/v3a8K/W3H7e1oiszrs9WTfZfbS6mkA79GipjX8CcTKEc hu/l5w9vgr0Ru6xWl9lPAysd88rzq+x6HG4XxDgY1JIzFJFmUvV8JaATU3/xtKVW4p7E NQPkfqHuWnwoKUFKjod0Dq+5LGSj0RDJ8lRE6XdVf1j9enyuVeYBBRnRF+9lHVg6n8TT vkNPAtrnYH7Rq1Rv1CPoWZGodMLTf8R2nCqsNl+D77ThsUuJIk62FHb3jr0DXsumUZdI QIaQ== 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=4dFyZL+foY5CFagZBqYGlXadFaahlx+O7pYVXKRco70=; b=uqpWHUAQj4yn3RFtQQHcofuceX8UnRH/MiuPdv620zuUw3PCTX4IvY7QkRQKCXwys9 Oq7RK9qZsQnjWng8HBZLTR2qlRojmqQsCsSa7IksiJtLg7IUhKscAVH5aj0kMdw6cTSk QeA1/nEh9Vs9UXRbJju3B54RIWq48MPc5yRcz/ZEAzMgVKvTuurfEfxE6FnXssjIt5RA o/mKrGUsz5EPSmPABTbQm9CdrtXHZ+LFNcfFt0oytcCcBeXoj1na59Ohl5Adoij5Ibbr f8C1slzUmT8d5xXQSMadFyapQpADLR0wC+4yVdhewk+id7MLDQytdFQyk/CKcR+v1pFX tyDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QRr3wzd7; 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 i186si6777916pge.299.2022.01.24.15.18.54; Mon, 24 Jan 2022 15:19:06 -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=QRr3wzd7; 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 S1846763AbiAXXQ6 (ORCPT + 99 others); Mon, 24 Jan 2022 18:16:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1583211AbiAXWR1 (ORCPT ); Mon, 24 Jan 2022 17:17:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97D6AC0617A7; Mon, 24 Jan 2022 12:47:41 -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 ams.source.kernel.org (Postfix) with ESMTPS id 54D6AB810A8; Mon, 24 Jan 2022 20:47:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FA43C340E5; Mon, 24 Jan 2022 20:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057259; bh=54vNzbIe3xiPqHoas9N4QpQw4TKCVTWNdCB3VyhU3Ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QRr3wzd7XL1sx30tyMbseYgLrscDnXZMNxL1f6L0bdXFvfO6tfeWlMZJSodwvc4NB xWYho5yTOAPrxgdESKdpDLx8qyqQXhInTjo5BILix/+b24UCOS0MBRdugDh8A0FF1i 1t+oXK7GgyjpJ803rdTaR+suHqG5pXjlIWXIb4sY= 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 720/846] ext4: use ext4_ext_remove_space() for fast commit replay delete range Date: Mon, 24 Jan 2022 19:43:57 +0100 Message-Id: <20220124184125.855685791@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 0b5b5a62b945a141e64011b2f90ee7e46f14be98 upstream. For now ,we use ext4_punch_hole() during fast commit replay delete range procedure. But it will be affected by inode->i_size, which may not correct during fast commit replay procedure. The following test will failed. -create & write foo (len 1000K) -falloc FALLOC_FL_ZERO_RANGE foo (range 400K - 600K) -create & fsync bar -falloc FALLOC_FL_PUNCH_HOLE foo (range 300K-500K) -fsync foo -crash before a full commit After the fast_commit reply procedure, the range 400K-500K will not be removed. Because in this case, when calling ext4_punch_hole() the inode->i_size is 0, and it just retruns with doing nothing. Change to use ext4_ext_remove_space() instead of ext4_punch_hole() to remove blocks of inode directly. Signed-off-by: Xin Yin Reviewed-by: Harshad Shirwadkar Link: https://lore.kernel.org/r/20211223032337.5198-2-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/fast_commit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1809,11 +1809,14 @@ ext4_fc_replay_del_range(struct super_bl } } - ret = ext4_punch_hole(inode, - le32_to_cpu(lrange.fc_lblk) << sb->s_blocksize_bits, - le32_to_cpu(lrange.fc_len) << sb->s_blocksize_bits); - if (ret) - jbd_debug(1, "ext4_punch_hole returned %d", ret); + down_write(&EXT4_I(inode)->i_data_sem); + ret = ext4_ext_remove_space(inode, lrange.fc_lblk, + lrange.fc_lblk + lrange.fc_len - 1); + up_write(&EXT4_I(inode)->i_data_sem); + if (ret) { + iput(inode); + return 0; + } ext4_ext_replay_shrink_inode(inode, i_size_read(inode) >> sb->s_blocksize_bits); ext4_mark_inode_dirty(NULL, inode);