Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp421342rwb; Mon, 26 Sep 2022 00:08:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4+YlzPoywBhvqa/Qxa3ai7VDvBTDvPk/fBUBh0WnDv/HSKKr2MG1NJB6oL4D33I5FLm0B0 X-Received: by 2002:a05:6402:26d4:b0:451:280d:3533 with SMTP id x20-20020a05640226d400b00451280d3533mr20853718edd.316.1664176100230; Mon, 26 Sep 2022 00:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664176100; cv=none; d=google.com; s=arc-20160816; b=xA5/pJsp8gbd8vVobY5voYmZhd0+9Wpq+BtWKAhHH4oTtS7LRN+Ygvywdz1eWLpfwq do6z9QfhzBxZCG0GMEYgEDyBWgttwPII1SMw5jmUdRNIWxE6wmSRa331l6DFTviwZrui ++0fwge/jyJ7dbBBiXcIl+rU0+0ppc4PWf8r5cubIXbF6Trai/YHcVcSIc2fdl38cISl p9ypEIAvvJkvoaAOk4IqsURj0LNhlIZRcH8MQUn/gJwN249KXTw1UFKUCqyg4u2MK89T Kevu0pjDLLsC+S6NHjR6JzJeEU/XwMy7C4AQaJMIepfxOClm3dOksfCjEMjTs90jyh+I 5JPw== 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=IetkwfUweD3Gi0+PhqVbWTS8N537yLyHgepl+ZxlTvE=; b=gsCEAFIGQjkWl7zUOKhcAaooOFaA6WZzlH2Xihri++Y9YZxrDvTbCK25xOYQ1kjAIP 0T4f9qaE0nqQiNuOSJ3yRe3Nfy2/eHVMFq6SfNzrH8kjgaO+MA0CBhdh3//HfI4tXqem 7MwOwP5c6M1+uoG8AwlJxkzGarLdT4fynMpvA9uV/uil1/kTgXb0BKj9G2mNv9X50sLY EVj356b0G3f9XGOXJa6kw4AympRIpj1PRCaSnmd6k8kCyHQuBPLYNVMFNBM22FZj9mdM FPCSZ0XqCviRMTujQZ5HY0NpNnfRMutmVCUknY3r1r2nHv6v0U2Bt5AQ1DHFqVxBYTAJ 4WyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jEJ+mmb3; 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 f11-20020a056402194b00b004519cd16132si14851829edz.61.2022.09.26.00.07.53; Mon, 26 Sep 2022 00:08:20 -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=jEJ+mmb3; 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 S233931AbiIZHHh (ORCPT + 99 others); Mon, 26 Sep 2022 03:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233871AbiIZHG6 (ORCPT ); Mon, 26 Sep 2022 03:06:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE0B631372; Mon, 26 Sep 2022 00:06:55 -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 28Q4ZSj1024914; Mon, 26 Sep 2022 07:06:51 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=IetkwfUweD3Gi0+PhqVbWTS8N537yLyHgepl+ZxlTvE=; b=jEJ+mmb34xw3lN2rRgFfwpGb5giP7k7pLvnixW0YFGsGNyYHH46psb+F4TSl1r04dwLw Q8z6dl1GLPcM9YYGQKcuUKruWa1mcZA0W8W96z3tyNHzUEibDTO4jF5Bn/Ws2nVYaVDm mtGD0FJuzon4WwkTrMLeLPi2/t+Y8EAJm3MPId1/ptilJTN8D4UV5oZc+v0yzBtBVy9I r8C9e2hi9pS6CyWmsuvVY9RLSALJ1ESObFcWZHx8WeAJ0wY7KQF/eZmp5yFxg95AWy6O cMlpEZ2Xd5j2nmvCsqyGTjfIteyV4YDsZzy3nskHg3ovnc2I8u0A6vZSL14HfPcyK9ft gA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jtb6u5u7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Sep 2022 07:06:51 +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 28Q6e4Gv014320; Mon, 26 Sep 2022 07:06:50 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jtb6u5u6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Sep 2022 07:06:50 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28Q75V1G027407; Mon, 26 Sep 2022 07:06:48 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3jssh8t11b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Sep 2022 07:06:48 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28Q77Dmx31195446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Sep 2022 07:07:13 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF77E11C050; Mon, 26 Sep 2022 07:06:45 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18D5A11C04A; Mon, 26 Sep 2022 07:06:43 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com (unknown [9.43.30.221]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 26 Sep 2022 07:06:42 +0000 (GMT) From: Ojaswin Mujoo To: linux-ext4@vger.kernel.org, "Theodore Ts'o" Cc: Ritesh Harjani , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Dilger , Jan Kara , Ritesh Harjani Subject: [RFC v2 4/8] ext4: Move overlap assert logic into a separate function Date: Mon, 26 Sep 2022 12:34:55 +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: IGrYpB58pwexRhVausQzoTpMOb1F6qZ2 X-Proofpoint-GUID: z2x27Ifrq87nHGbb42m1SMATGQCuGw9s X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-26_04,2022-09-22_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 spamscore=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209260043 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 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 84950df709bb..d1ce34888dcc 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3985,6 +3985,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 @@ -4141,18 +4164,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