From patchwork Sat Dec 3 02:59:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 29207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1177746wrr; Fri, 2 Dec 2022 18:42:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5maOpgViLwY8OTwKElNvjoHGCyf/rohxamEBJjEMZY7ICWEYr/Ws6TSgfuSnxuGANUu0ik X-Received: by 2002:a17:903:3052:b0:189:651c:f023 with SMTP id u18-20020a170903305200b00189651cf023mr40216550pla.78.1670035360282; Fri, 02 Dec 2022 18:42:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670035360; cv=none; d=google.com; s=arc-20160816; b=nb+Y7lo03s5RC0dNwp1srsbnLKTQmzYI1zUk6TR9d0ffL3BkbV6kG0TzU8zTWpWOQg lv8Defq6kmRiOKB3M99g1LRh+ionZO7KhSzWC1hC0ZS5QIXJJoz9jvKlfqKkaLarJJkm lsdBeqe/HqkbpAXeGRvpkEx2O4jCB28fAL72NmC2Di3uUCpeoosVdmUSp2vKkOXtAKVt 0GBA9qk8Qe3ZIyai1HToKW/VaXC69um/XwQMqBtDnUv/csU2bqY0zmOcwj7r5KltzshV 2nBUU5+QHtu9c8N4ilXV/Ln5pGfPA2EDRwx9ws5206hZJqyTskqQgX3F97lhD2XZHAHF bJYQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QwLVCnorOx9RTIPk9aJh0KkTp4DaqH8NSA/oA68UZCM=; b=uVuRZ9cd6M8SgxrtkDJH7b0WMl/QWOyK9ywyB6zRXkGZ02DfdPT2UHFiLl6SuPcU+s 17vX4Svrt1sBjLmcM8AB2jE+AG1Qv2RsVrtQHVi4NLYnzHOHZ2lVHKKUFI788IWsfglE lQhyoR72ohzQBEuCLCnop26XXVc5b6HWUGvC7fw7VK+GEkcbZ5ov+UsBrFwF3wg3RGd7 6jsA7BiUS2ZAX2XsZZc/Jl9EvprTmJgxeaLRm+Z1OIE7Nz7YnLy6HtOQh6XCSoIKUY7b OLsvFdRQjyZTaVtJo4nHElCnuog+3F/hrPpnj65aRDFiZAzgC5t0vH9UfwGgORugjFRw SBnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p6-20020a170902ebc600b00187085e0aacsi8450366plg.549.2022.12.02.18.42.27; Fri, 02 Dec 2022 18:42:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235235AbiLCCiv (ORCPT + 99 others); Fri, 2 Dec 2022 21:38:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235190AbiLCCip (ORCPT ); Fri, 2 Dec 2022 21:38:45 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 374CDEC096; Fri, 2 Dec 2022 18:38:44 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NPDWy3QBcz4f3p15; Sat, 3 Dec 2022 10:38:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgDXSNavtopjXug+Bg--.58501S5; Sat, 03 Dec 2022 10:38:41 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin , syzbot+05a0f0ccab4a25626e38@syzkaller.appspotmail.com Subject: [PATCH v3 1/3] ext4: fix incorrect calculate 'reserved' in '__es_remove_extent' when enable bigalloc feature Date: Sat, 3 Dec 2022 10:59:39 +0800 Message-Id: <20221203025941.2661302-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221203025941.2661302-1-yebin@huaweicloud.com> References: <20221203025941.2661302-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDXSNavtopjXug+Bg--.58501S5 X-Coremail-Antispam: 1UD129KBjvJXoWxJF1UXr1rXF4UJF45CryrCrg_yoW5Jr45p3 y8Ar4UWryfuw1UW3yftw1j9rn29a4UCr47WFs3t343uFy5A3sagr10kFs0vFWYqrWIgw4D XFWrtw12q3WUGaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUzl1vUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751158998433488962?= X-GMAIL-MSGID: =?utf-8?q?1751158998433488962?= From: Ye Bin Syzbot report issue as follows: EXT4-fs error (device loop0): ext4_validate_block_bitmap:398: comm rep: bg 0: block 5: invalid block bitmap EXT4-fs (loop0): Delayed block allocation failed for inode 18 at logical offset 0 with max blocks 32 with error 28 EXT4-fs (loop0): This should not happen!! Data will be lost EXT4-fs (loop0): Total free blocks count 0 EXT4-fs (loop0): Free/Dirty block details EXT4-fs (loop0): free_blocks=0 EXT4-fs (loop0): dirty_blocks=32 EXT4-fs (loop0): Block reservation details EXT4-fs (loop0): i_reserved_data_blocks=2 EXT4-fs (loop0): Inode 18 (00000000845cd634): i_reserved_data_blocks (1) not cleared! Above issue happens as follows: Assume: sbi->s_cluster_ratio = 16 Step1: Insert delay block [0, 31] -> ei->i_reserved_data_blocks=2 Step2: ext4_writepages mpage_map_and_submit_extent -> return failed mpage_release_unused_pages -> to release [0, 30] ext4_es_remove_extent -> remove lblk=0 end=30 __es_remove_extent -> len1=0 len2=31-30=1 __es_remove_extent: ... if (len2 > 0) { ... if (len1 > 0) { ... } else { es->es_lblk = end + 1; es->es_len = len2; ... } if (count_reserved) count_rsvd(inode, lblk, orig_es.es_len - len1 - len2, &orig_es, &rc); goto out; -> will return but didn't calculate 'reserved' ... Step3: ext4_destroy_inode -> trigger "i_reserved_data_blocks (1) not cleared!" To solve above issue if 'len2>0' call 'get_rsvd()' before goto out. Reported-by: syzbot+05a0f0ccab4a25626e38@syzkaller.appspotmail.com Fixes: 8fcc3a580651 ("ext4: rework reserved cluster accounting when invalidating pages") Signed-off-by: Ye Bin Reviewed-by: Eric Whitney --- fs/ext4/extents_status.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index cd0a861853e3..7ada374ff27d 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c @@ -1371,7 +1371,7 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, if (count_reserved) count_rsvd(inode, lblk, orig_es.es_len - len1 - len2, &orig_es, &rc); - goto out; + goto out_get_reserved; } if (len1 > 0) { @@ -1413,6 +1413,7 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, } } +out_get_reserved: if (count_reserved) *reserved = get_rsvd(inode, end, es, &rc); out: From patchwork Sat Dec 3 02:59:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 29205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1177441wrr; Fri, 2 Dec 2022 18:41:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6qDrh1uCUAMq5LcWDcyt8fDtqb+14BUKNzoCRs9krN9slYiWb3VHNNjTiN31wiBskJ2I2p X-Received: by 2002:a63:5517:0:b0:42f:e191:2d35 with SMTP id j23-20020a635517000000b0042fe1912d35mr66737911pgb.1.1670035284736; Fri, 02 Dec 2022 18:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670035284; cv=none; d=google.com; s=arc-20160816; b=cO18dO02v7nF8OD2r5jHDdGLGDQfkUTF9MYlt1bCQ7gSz6M18qpMwWHPv0oQl+lbrD CGNKDuJRgexZgJX0BqEh9lW8D2yvu0m9xvMgN2KcIuLA+Ttf7PxcW7zw+JxZWDN2qMA2 pOu1oYdhF8VojOnJ5V2fdjRkya5gQE7uhBE5fz6XdCL2//LifUrdStfWSXV2YjgUq9nU ettddPWn4aBlamQaeGhicRAuEaJyk2aiPQCwB/BG42/BfhurP5HYRBj7YhkPifW4DyFY A5eFJ+/TdpI9VZu0vk7WsBe585m3UUby8XWdvBP1kBA/EGapBISwBEFgoj80VBFSNCvi jvww== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9G36o5uhkNdsh1Nk5gHzavXKrZOSTqff138oxLNw6bI=; b=RjYRuV6s1q5T6UJbr4+pbtbAVSpfFx+39TyKOZZxrVBBjcz7iU7Eu/ucqYQfK/JvJq yQl43p1OH8KZ0nONRhxVEUsPGwsVKBs9Mw6+lIwCA/gAriOmuTdUarM5azxcXuRB6Ga9 OqkWqhPNLsBTvXMLyFPyNk1OJ8bWwjjOIcgQ6Khw7s2Lpio/uRrTMWQg3qjMdHLv0K+x dNZuEHGQ4DWAhkAWxEPXyTcvSIwjyxOP97t9jLJfyHK6XaYqH7eav2ROjZg0TyFJlleZ xqN7ZOQu8ECLbQ7+j68wVUQVo9zGjpcb02Kw3jHclbEO5C1SZja/bxkminjdIgcr6GEs 4Oyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf6-20020a170902b90600b00177fd8409b7si8002855plb.73.2022.12.02.18.41.10; Fri, 02 Dec 2022 18:41:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235247AbiLCCiy (ORCPT + 99 others); Fri, 2 Dec 2022 21:38:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235194AbiLCCip (ORCPT ); Fri, 2 Dec 2022 21:38:45 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69A11EC09E; Fri, 2 Dec 2022 18:38:44 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NPDWy5TLjz4f3k5x; Sat, 3 Dec 2022 10:38:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgDXSNavtopjXug+Bg--.58501S6; Sat, 03 Dec 2022 10:38:41 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH v3 2/3] ext4: record error when detect abnormal 'i_reserved_data_blocks' Date: Sat, 3 Dec 2022 10:59:40 +0800 Message-Id: <20221203025941.2661302-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221203025941.2661302-1-yebin@huaweicloud.com> References: <20221203025941.2661302-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDXSNavtopjXug+Bg--.58501S6 X-Coremail-Antispam: 1UD129KBjvdXoW7GF1DXr1UJFW8Zr17uF13XFb_yoWkGrgEqw 40yF10v3yfZw4Igan5Gr13JFZYkF4kCr18Gw1rKF15Zr1YvF4DCw4DAry3Arn5Way8Grn0 9rWrJry3JrWrWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8YFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r15M2 8IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x07jeWlkUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751158918797368790?= X-GMAIL-MSGID: =?utf-8?q?1751158918797368790?= From: Ye Bin If 'i_reserved_data_blocks' is not cleared which mean something wrong with code, free space accounting is likely wrong, according to Jan Kara's advice use ext4_error() to record this abnormal let fsck to repair and also we can capture this issue. Signed-off-by: Ye Bin Reviewed-by: Eric Whitney --- fs/ext4/super.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 840e0a614959..41413338c05b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1387,10 +1387,10 @@ static void ext4_destroy_inode(struct inode *inode) } if (EXT4_I(inode)->i_reserved_data_blocks) - ext4_msg(inode->i_sb, KERN_ERR, - "Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!", - inode->i_ino, EXT4_I(inode), - EXT4_I(inode)->i_reserved_data_blocks); + ext4_error(inode->i_sb, + "Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!", + inode->i_ino, EXT4_I(inode), + EXT4_I(inode)->i_reserved_data_blocks); } static void init_once(void *foo) From patchwork Sat Dec 3 02:59:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 29206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1177616wrr; Fri, 2 Dec 2022 18:42:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/bT9BBKk9JV2I2M0WWwpiPtZ8OjDR4sgHCR5loJYph8dg8KnXoR6DAqBcZ9JDhUZaUTID X-Received: by 2002:a17:902:b611:b0:189:b4ed:56b0 with SMTP id b17-20020a170902b61100b00189b4ed56b0mr6831129pls.99.1670035328292; Fri, 02 Dec 2022 18:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670035328; cv=none; d=google.com; s=arc-20160816; b=CPWsEAvJ5063OfgU3sImdit72ukXMUCppP72GPfi+JRcNgcY8A8swNQJP6gHiIOpVZ YjpJp4/7y4XyE8P/6ifWykDGVIAEgkTzDEkApKxBz34IMcLsR37vjSrI5Ey4bN/1F0Ob i7y+xhsDT2u59wXLMjXUjPpsqvgA7YFBcob0TvnY0usswUc77gV9vGMXxYs9UHKL0V/O IUyYgijVWCk7uOovZiv36oxDXAZ5bqwFd/rSQ5yYXa0nSn8ueX0BZ2kg3BOv2pNA8RSv XpKKbheE2gfembG2pI4IZwKtb0Vtqc/sSKV5nJqkgXGzb/1f4GB4NMRJ4iOQ5bQcvnp3 LlYQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=68BtkofH5JgT1qTCMLS3QKY54uAutI7QDIndqeMqrhc=; b=Wire9eF/sQxJA+jPlj2aSnZtjZDj/7q8JGZGLSxP5asGqFY8wRfmzJigTGvO1KBbbk tx9KvBIdgqjMXN8HHk2Q/Pj02PT8yKL2+PGcPLAMeMlzZ14fH1Qa4VMp9q1S7T7WgQ01 /ddgi9URoq1HNxpCSiEMpGzeDVyLCkoItigEMMfJvzVLXsuZQNXUvaH0ZJJUZyTsb5wn QP/p72lF7pX/JP1sayRPRJQAeLyooMdM5XS9qhH763Rp6xnU3x2EwZRhh9eMnJvgWJ6u tvTh+8nyUH5Qw9/ZmOxNQRc7fSaKZUjW5Lj5h+yEFg7TaLf4dWh4xAjW67LzU97CnsLO cVWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t203-20020a635fd4000000b0047882a136fbsi3701283pgb.737.2022.12.02.18.41.55; Fri, 02 Dec 2022 18:42:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235253AbiLCCi5 (ORCPT + 99 others); Fri, 2 Dec 2022 21:38:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235205AbiLCCiq (ORCPT ); Fri, 2 Dec 2022 21:38:46 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F00BEC091; Fri, 2 Dec 2022 18:38:45 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4NPDWz4GBzz4f3v7B; Sat, 3 Dec 2022 10:38:39 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgDXSNavtopjXug+Bg--.58501S7; Sat, 03 Dec 2022 10:38:42 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin , syzbot+05a0f0ccab4a25626e38@syzkaller.appspotmail.com Subject: [PATCH v3 3/3] ext4: add check pending tree when evict inode Date: Sat, 3 Dec 2022 10:59:41 +0800 Message-Id: <20221203025941.2661302-4-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221203025941.2661302-1-yebin@huaweicloud.com> References: <20221203025941.2661302-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDXSNavtopjXug+Bg--.58501S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr1xtryUGF48Zr45ZF18Xwb_yoW5JFW7p3 45Gw15Gr4kur1DCF43tF15Jr13Wa1vkFWUJrWrKr1jqFy8Ja4xtFnrtr1agF4UJrZxCr1Y qF18Cr9Yqry8J3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2PEfUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751158964179566582?= X-GMAIL-MSGID: =?utf-8?q?1751158964179566582?= From: Ye Bin Syzbot found the following issue: BUG: memory leak unreferenced object 0xffff8881bde17420 (size 32): comm "rep", pid 2327, jiffies 4295381963 (age 32.265s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000ac6d38f8>] __insert_pending+0x13c/0x2d0 [<00000000d717de3b>] ext4_es_insert_delayed_block+0x399/0x4e0 [<000000004be03913>] ext4_da_map_blocks.constprop.0+0x739/0xfa0 [<00000000885a832a>] ext4_da_get_block_prep+0x10c/0x440 [<0000000029b7f8ef>] __block_write_begin_int+0x28d/0x860 [<00000000e182ebc3>] ext4_da_write_inline_data_begin+0x2d1/0xf30 [<00000000ced0c8a2>] ext4_da_write_begin+0x612/0x860 [<000000008d5f27fa>] generic_perform_write+0x215/0x4d0 [<00000000552c1cde>] ext4_buffered_write_iter+0x101/0x3b0 [<0000000052177ae8>] do_iter_readv_writev+0x19f/0x340 [<000000004b9de834>] do_iter_write+0x13b/0x650 [<00000000e2401b9b>] iter_file_splice_write+0x5a5/0xab0 [<0000000023aa5d90>] direct_splice_actor+0x103/0x1e0 [<0000000089e00fc1>] splice_direct_to_actor+0x2c9/0x7b0 [<000000004386851e>] do_splice_direct+0x159/0x280 [<00000000b567e609>] do_sendfile+0x932/0x1200 Above issue fixed by 1b8f787ef547 "ext4: fix warning in 'ext4_da_release_space'" in this scene. To make things better add check pending tree when evit inode. According to Eric Whitney's suggestion, bigalloc + inline is still in development so we just add test for this situation, there isn't need to add code to free pending tree entry. Reported-by: syzbot+05a0f0ccab4a25626e38@syzkaller.appspotmail.com Signed-off-by: Ye Bin --- fs/ext4/super.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 41413338c05b..2e2fbc4a832c 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1391,6 +1391,11 @@ static void ext4_destroy_inode(struct inode *inode) "Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!", inode->i_ino, EXT4_I(inode), EXT4_I(inode)->i_reserved_data_blocks); + + if (!RB_EMPTY_ROOT(&EXT4_I(inode)->i_pending_tree.root)) + ext4_error(inode->i_sb, + "Inode %lu (%p): i_pending_tree not empty!", + inode->i_ino, EXT4_I(inode)); } static void init_once(void *foo)