Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1962400rwe; Sat, 27 Aug 2022 23:48:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4CIkeE+vHaYG8pX8gJ5g3wqUHFX4nG3nAC9eZYb9Y0AFeGRYld6s/CEF60PglMOYX0ExPu X-Received: by 2002:a05:6402:42d3:b0:435:2c49:313d with SMTP id i19-20020a05640242d300b004352c49313dmr12308876edc.86.1661669306826; Sat, 27 Aug 2022 23:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661669306; cv=none; d=google.com; s=arc-20160816; b=HSLAgfyZ81OxK1kaGXMmEqj3yJUXKGmMzbjdZyJYt++FpaeUQ6k02Op4bLrwrj8eB+ pm5P0K/i2x5thF/TLy0bjHsj+OiXRqa6rfa9N1LvwPSUwsbPPnXqC7btmW3Zj9+1kcor pg/HIeVSY796MExBe7RbbCU67/A5ZCyJIc+hijYsLuwzZW8dthOlLWSWrwZ3mSWAIXVl v/IfnUx/vO3Ap1pR2ldaIwxNhhS0JjS/SosxVnYSpItvLUqCaIeVdat4sUBZcDym+0+z a82n5n2MK7kiwSeT6ncbNPORwev7TybOPbhgS8k5fqkHRo9jtTjNkrSBcPAWDJXeGT4Q a7nQ== 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 :dkim-signature; bh=QAqVSjYgsXGrqqtAFs0ZKGY/UxWTvDFBseVq00fUSVA=; b=hPMOcB5hyxcrindvkIob/t0N7KNIRl7OE1v36Q2256BDGPrQ/zDWyXydUnGLRzZ9g6 //INxQgVjkF36BGFQdTkZ3Y15FXwXw6F6y1PYPMPI/IV2h+Q/xyv1MJU7YKCk5BS3RXU pSb2lL7nUuHG+qw7Y+XY19Te4G7pKdGDphJkvTPXRbht49Z3E78xaPMgeOWC1K1juvyA ob1pp+GpI9xDg0+DnDTZIl8/gXfrkqvx7qbcw/4ZYaS4gl6erzF7hjCLiSxexGR4/00x M4Bxhexi9TFlFZr1awdE9bg5UpkN1DYnnCzo1ZV279oZJyU+84T2XHHwCE4rCC2XBEKu /UOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hgBbNYrA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a170906268d00b007317733951dsi3958803ejc.56.2022.08.27.23.48.03; Sat, 27 Aug 2022 23:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hgBbNYrA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232255AbiH1Gqz (ORCPT + 99 others); Sun, 28 Aug 2022 02:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbiH1Gqv (ORCPT ); Sun, 28 Aug 2022 02:46:51 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C99F4B0D4; Sat, 27 Aug 2022 23:46:48 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27S5V6s7016431; Sun, 28 Aug 2022 06:46:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=QAqVSjYgsXGrqqtAFs0ZKGY/UxWTvDFBseVq00fUSVA=; b=hgBbNYrARmcCrlzuuvodkKaifCarFV9YItR9ic4+kUhgEH+EC0ectiuws2K8qkEZaRBD R2f9pSrRiW40Net5jze4vv2rgMeOf80psHlHsazenTAjJ7R/9ZDfIFYNudTyW+NGrwwC KnrH7FdY8nLfe7oW8z6XqNOt5KES4g4dpiG+MLc9r1/2XIUs6pOc+NXyu0n+Vxv4YQpN vP9yclm/xD2yXDK9n3drE/nInATwp5TB9UTmlB+Us4PoAl3nlH5L5YPTF36TX9byn2L+ tt9kwdeTkWlYcDJJIstcfs1XB7Acan2dE94WwVx4PAV+cS+DWeaI+H2/KSKnRJa/3jiC /g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j829kh8gu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Aug 2022 06:46:46 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27S6gpaM008709; Sun, 28 Aug 2022 06:46:45 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j829kh8g4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Aug 2022 06:46:45 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27S6ZSxv000713; Sun, 28 Aug 2022 06:46:43 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3j7ahj11nq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Aug 2022 06:46:43 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27S6ke6421299694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 28 Aug 2022 06:46:40 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE3E952052; Sun, 28 Aug 2022 06:46:40 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com (unknown [9.43.118.96]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id A64BF52051; Sun, 28 Aug 2022 06:46:38 +0000 (GMT) From: Ojaswin Mujoo To: linux-ext4@vger.kernel.org Cc: "Theodore Ts'o" , Ritesh Harjani , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Dilger , Ritesh Harjani Subject: [RFC 4/8] ext4: Move overlap assert logic into a separate function Date: Sun, 28 Aug 2022 12:16:17 +0530 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 8XI6EKDk_5B8rtz8tizDF8HGxLxPoq2E X-Proofpoint-GUID: qnQbuqQPiCrtETp6ykOee6TY3qP7XTlU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-27_10,2022-08-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 adultscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208280025 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org Abstract out the logic to double check for overlaps in normalize_pa to a separate function. Since there has been no reports in past where we have seen any overlaps which hits this bug_on(), in future we can consider calling this function under "#ifdef AGGRESSIVE_CHECK" only. There are no functional changes in this patch Signed-off-by: Ojaswin Mujoo Reviewed-by: Ritesh Harjani (IBM) --- fs/ext4/mballoc.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index ddb4c72c7f60..8f5aaff892d4 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -4020,6 +4020,29 @@ static void ext4_mb_normalize_group_request(struct ext4_allocation_context *ac) mb_debug(sb, "goal %u blocks for locality group\n", ac->ac_g_ex.fe_len); } +static inline void +ext4_mb_pa_assert_overlap(struct ext4_allocation_context *ac, + ext4_lblk_t start, ext4_lblk_t end) +{ + struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); + struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); + struct ext4_prealloc_space *tmp_pa; + ext4_lblk_t tmp_pa_start, tmp_pa_end; + + rcu_read_lock(); + list_for_each_entry_rcu(tmp_pa, &ei->i_prealloc_list, pa_inode_list) { + spin_lock(&tmp_pa->pa_lock); + if (tmp_pa->pa_deleted == 0) { + tmp_pa_start = tmp_pa->pa_lstart; + tmp_pa_end = tmp_pa->pa_lstart + EXT4_C2B(sbi, tmp_pa->pa_len); + + BUG_ON(!(start >= tmp_pa_end || end <= tmp_pa_start)); + } + spin_unlock(&tmp_pa->pa_lock); + } + rcu_read_unlock(); +} + /* * Normalization means making request better in terms of * size and alignment @@ -4176,18 +4199,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, size = end - start; /* XXX: extra loop to check we really don't overlap preallocations */ - rcu_read_lock(); - list_for_each_entry_rcu(tmp_pa, &ei->i_prealloc_list, pa_inode_list) { - spin_lock(&tmp_pa->pa_lock); - if (tmp_pa->pa_deleted == 0) { - tmp_pa_start = tmp_pa->pa_lstart; - tmp_pa_end = tmp_pa->pa_lstart + EXT4_C2B(sbi, tmp_pa->pa_len); - - BUG_ON(!(start >= tmp_pa_end || end <= tmp_pa_start)); - } - spin_unlock(&tmp_pa->pa_lock); - } - rcu_read_unlock(); + ext4_mb_pa_assert_overlap(ac, start, end); /* * In this function "start" and "size" are normalized for better -- 2.31.1