From nobody Wed Jul 1 09:56:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1959CC433EF for ; Thu, 23 Dec 2021 03:24:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346187AbhLWDYR (ORCPT ); Wed, 22 Dec 2021 22:24:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346175AbhLWDYQ (ORCPT ); Wed, 22 Dec 2021 22:24:16 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C32C061401 for ; Wed, 22 Dec 2021 19:24:16 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id co15so3891816pjb.2 for ; Wed, 22 Dec 2021 19:24:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YNW6lb4D68Pjevtpm3ZBWVUTAD4SEQ7ZKtiDMVWrDCI=; b=0nbdoVOPXc8d7yDEQMj31ca4y+VsD8Zr74dFkqt0tILPyobQuP/KPmuhGDeWzyoBs5 iBv+vk9hkY4gMoTHOt9Z1cCVhAZtb4CtpNT9LyS6kpqb4TehecSGFsw/IEKoflTFYZ+j VIgPxb+UOq83Q6LIDh+ccanFztTNMwFF9TrFWIIGDYrR6m2GAAnyGvge1ltrkb2UlsX1 hZL/tBXXmF7EBQ6+SKD1VGYB1orN1NreisdpgSC+faOhfLnPQFEStE7XBtNyQxGv01Hi VIJHLJHanMdL87S/A4xdHbWtB5zNIJ6jL2HZxY8JRrR0+TDhHRiKoyszvjGR/Hm/uoku CbVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YNW6lb4D68Pjevtpm3ZBWVUTAD4SEQ7ZKtiDMVWrDCI=; b=Bm/Vq+1XBQPGFY7rpuK91s6YmzwQHETvTYdmZoV6cGg0SmKNmlIdLbhfBk8zly8o+r BHDhcSWsSAYxlNT8FdAisIxhC6C/ovm4+FznkWNKTL99NgukD+6vp2WTFTinKG5vVZSi EOFN2/9yk0h46eqimnW82CyKhFzyyDpWPzBTGr15ePtyPXoUYLLte8z0K4fgNPb/oGSm p+k2lykIDjh/RaajzWP6ntDCsRfopAeyWf5FRVRrcSFTrXiCXX+VqXwzt+fWSSUHs3aU s8eSsTf5ij/3/TrfpfdZ45F4LVcS+rhAl/AO2SxzlHYg/6opD1UlW9DtooOrfxOusDqT qC7A== X-Gm-Message-State: AOAM530M0KylO3wbZ4WREmblUcMFrmQZLxjJOwIrBN/M7aQRkwc1SaqN b2oc7nVe8ViJlOZKlslMcE+n6A== X-Google-Smtp-Source: ABdhPJxMnqx4rKQLL0WdVz6bouEu/bw24Io/+zKRIxBd0P+OqOOHu0fBj/L5CBhjPoPTQ9Qptka/yA== X-Received: by 2002:a17:903:1210:b0:143:a088:7932 with SMTP id l16-20020a170903121000b00143a0887932mr509343plh.11.1640229856148; Wed, 22 Dec 2021 19:24:16 -0800 (PST) Received: from yinxin.bytedance.net ([139.177.225.235]) by smtp.gmail.com with ESMTPSA id d3sm4348622pfv.192.2021.12.22.19.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 19:24:15 -0800 (PST) From: Xin Yin To: harshadshirwadkar@gmail.com, tytso@mit.edu, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Xin Yin Subject: [PATCH 1/2] ext4: use ext4_ext_remove_space() for fast commit replay delete range Date: Thu, 23 Dec 2021 11:23:36 +0800 Message-Id: <20211223032337.5198-2-yinxin.x@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223032337.5198-1-yinxin.x@bytedance.com> References: <20211223032337.5198-1-yinxin.x@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- fs/ext4/fast_commit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index aa05b23f9c14..3deb97b22ca4 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1708,11 +1708,14 @@ ext4_fc_replay_del_range(struct super_block *sb, st= ruct ext4_fc_tl *tl, } } =20 - ret =3D 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 =3D 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); --=20 2.20.1 From nobody Wed Jul 1 09:56:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28544C433EF for ; Thu, 23 Dec 2021 03:24:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346223AbhLWDY0 (ORCPT ); Wed, 22 Dec 2021 22:24:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346189AbhLWDYX (ORCPT ); Wed, 22 Dec 2021 22:24:23 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF1AC061574 for ; Wed, 22 Dec 2021 19:24:23 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id k4so3714910pgb.8 for ; Wed, 22 Dec 2021 19:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=48R3Uu/IbHX0iXPv/VGTpOehS2HTlBUJ2clVFeFdtfY=; b=eSlXCNp+XryuMDR1fxU5CfDwvjweikVdL6NlLdCOesb2DtOUNcWcZmXXGEeCk+oqyx DztCikPrfKLRs3iOLFHiX6BB7Alw3EsPuQh9U2TEvN+kV5W+Rkq0JevjOoQI0IqBKg95 AmLzLrpfs7zlazX0D133ldNxr0+ibMpVnWDQyGXfPEW4Nw/s3OZRlRjRoPqeh7GXGU+s BiCYkvkWgtKh+v4S1iSS6+ZsVUuuXThb25FsPOmgQ1TTsMdp7FQ+KFNupB2bAO+GZWbd ur6uvHWzc65jhnHImcph6k+YQZYs0pR9QEQXBHqyxTpNi2ZtJpHTMvvYV2ATdCBLzusq CBQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=48R3Uu/IbHX0iXPv/VGTpOehS2HTlBUJ2clVFeFdtfY=; b=1CgOF0GI5uT+yGBdTdZ0yxwKHAjmrTbGYWmdEYsGmqvYuVydQ3vPteYahH+1DUBWiv GtSLOsGVS7ftU8bciOzv0DoujT3XhHfnhfJZv20tTqCWzkx2uhsbXa5OKHvCrb/FzLqM YlVCZekYTZeeLR0US3sCQ7FnD97Yfh9y6L5RkMgz+j3BcOEggcnBCoT8rO8SyQZEXvc6 WhQl7xM9JWVaGzN73xApEjvjUSbiRXxSU1/zayaJma5qblCRDaT8ID+6ooHNPTihYkf0 QC1tgTR2HAMv6J1x5mrLZMmDruYIe090FZM4Vgus3C2ENpm+a+bmLkEkM1KP+VyeNpNw xsAg== X-Gm-Message-State: AOAM532t5V7fmahJ/lne8g76En2QYaEj7VaRnoFUHNkcWqEWXGkW735n NHOi2GHMtGMG0HooesDb+LdEY7Ab5CJDuA== X-Google-Smtp-Source: ABdhPJxx9Woht889dMPfw8FsF9cSeIOB0xddNj66SXlGSng82of4xDAVY6o1nbRgranplD3U1d2TJA== X-Received: by 2002:a05:6a00:2356:b0:4ba:f28c:63da with SMTP id j22-20020a056a00235600b004baf28c63damr688932pfj.50.1640229863304; Wed, 22 Dec 2021 19:24:23 -0800 (PST) Received: from yinxin.bytedance.net ([139.177.225.235]) by smtp.gmail.com with ESMTPSA id d3sm4348622pfv.192.2021.12.22.19.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 19:24:23 -0800 (PST) From: Xin Yin To: harshadshirwadkar@gmail.com, tytso@mit.edu, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Xin Yin Subject: [PATCH 2/2] ext4: fast commit may miss tracking unwritten range during ftruncate Date: Thu, 23 Dec 2021 11:23:37 +0800 Message-Id: <20211223032337.5198-3-yinxin.x@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223032337.5198-1-yinxin.x@bytedance.com> References: <20211223032337.5198-1-yinxin.x@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If use FALLOC_FL_KEEP_SIZE to alloc unwritten range at bottom, the inode->i_size will not include the unwritten range. When call ftruncate with fast commit enabled, it will miss to track the unwritten range. Change to trace the full range during ftruncate. Signed-off-by: Xin Yin Reviewed-by: Harshad Shirwadkar --- fs/ext4/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 82f555d26980..1d2ba63874ad 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5423,8 +5423,7 @@ int ext4_setattr(struct user_namespace *mnt_userns, s= truct dentry *dentry, ext4_fc_track_range(handle, inode, (attr->ia_size > 0 ? attr->ia_size - 1 : 0) >> inode->i_sb->s_blocksize_bits, - (oldsize > 0 ? oldsize - 1 : 0) >> - inode->i_sb->s_blocksize_bits); + EXT_MAX_BLOCKS - 1); else ext4_fc_track_range( handle, inode, --=20 2.20.1