Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp241155rwl; Sat, 25 Mar 2023 01:15:13 -0700 (PDT) X-Google-Smtp-Source: AKy350bNmK49PQ6/SNOHN2FeiK5+cYxs57+43D9iRTzjgNbZ/K+5Sva5oKMVL2fv9wOfgNE3SX44 X-Received: by 2002:aa7:ccc7:0:b0:4fc:709f:7ab0 with SMTP id y7-20020aa7ccc7000000b004fc709f7ab0mr5954216edt.0.1679732112907; Sat, 25 Mar 2023 01:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679732112; cv=none; d=google.com; s=arc-20160816; b=nFXN4iRUIAZLDCFBzwVEW51io6cxb3AkMEBWRuPmoLmr53tXWsV6qQ0tmUQaRgFGH7 N32YdFod+5s8cna4BUXpbfY8Z0MSDOVn6eysrh4+PNo3yLr3qdTrL6KPFfF83tNxZ1qe WCxwQ9oKsrGVUYagvgWC0GYnQEcO7Qq7X8ibGwJ7q2ily5gz/FxXe1A02sO53f1Cz8LU xECs/cVJEy+0JP9aoPEoykf3vg+Vdz/IMGnDkXGeFqaZpojPKObIRgDEVn/HInci7Fu0 M3SaUfjc9uly7nD1BHc4sT3tq3q/BptlQt+uFdMZapZqikoNIOxbWVLbIJ4HlXgqTnDR oS+A== 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=itKEK4oNCV7DlUSLzWA1Wtf6ATzED6UkuTpj584/Dpk=; b=Us0W7fq42gshx3c4PkklYcNqdDPu+kEYoTP+LUmbY7AyiZ6MkX1V/MeaOG3G5ZIHgQ 89X6ZUYjEsMJKXHV6puydxW7ZOsKxNLFtNDaiVFf78S8ev0RVST+xHCKkQiMNWbgPf/+ 9EtElMBnbqAdlalmlbj7tkBJpej5JBJX6/laXh+EWSLCDuzledLT1JzLsD5Lfn4voCSm eAsPSkt77I2q4QCGcxFTUdEStM2x9hHiEzy7jpB44JN9MSfWmhTG/xvNDNlhVRaeq08u zIt36XLNXv8t4lg0jHsDs7ed7QnIwq6xImruO6/PTcifCAaQ/RlZi+vK0LjhNnmVJ7g2 4KgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=K6k+TUiq; 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=REJECT 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 m19-20020aa7d353000000b00502038c2d09si7871317edr.596.2023.03.25.01.14.49; Sat, 25 Mar 2023 01:15:12 -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=K6k+TUiq; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231801AbjCYIOS (ORCPT + 99 others); Sat, 25 Mar 2023 04:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231817AbjCYIOL (ORCPT ); Sat, 25 Mar 2023 04:14:11 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 678DB1043D; Sat, 25 Mar 2023 01:14:07 -0700 (PDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32P6g9xe018536; Sat, 25 Mar 2023 08:14:02 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=itKEK4oNCV7DlUSLzWA1Wtf6ATzED6UkuTpj584/Dpk=; b=K6k+TUiq/+sF+NYhe19z5/eh8IOR1koc/5ePU/Q5Vvgn6uPC4vmrG91qSbcanqjV4x2d IjRU81iMzHvEbWNsKe7JAfoVTZpqD6dNwFFDCDA3Vt/9o1MKV0ZyFhmTstMNCimYUDtD 4j1QXfYgG6NjtUmxScFWedPT/SuTcqzFSRRMvjvYHBj/NZlyBxEwgWZPTWbOE4c/Erak eB4ncnzlQq6Z+vk8amfT6aqzd4/K578clIO8549on/8f+tOwnPvCxAJQjvS+CkLk+UFe po0sJDZ8jbSD33joL0YI9d8WT8uXKVVZ0UG3mSjuH+rWp85faCmDzUUw08vHNJitjBEN YQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3phuwq12pq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 25 Mar 2023 08:14:02 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32P8E1Nw021326; Sat, 25 Mar 2023 08:14:01 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 3phuwq12pe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 25 Mar 2023 08:14:01 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32P2sr95009626; Sat, 25 Mar 2023 08:13:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3phrk6g8be-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 25 Mar 2023 08:13:58 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32P8DuNh46007012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 25 Mar 2023 08:13:56 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 88C1820043; Sat, 25 Mar 2023 08:13:56 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7845A20040; Sat, 25 Mar 2023 08:13:54 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com (unknown [9.43.63.61]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 25 Mar 2023 08:13:54 +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, Jan Kara , rookxu , Ritesh Harjani Subject: [PATCH v6 4/9] ext4: Move overlap assert logic into a separate function Date: Sat, 25 Mar 2023 13:43:37 +0530 Message-Id: <35dd5d94fa0b2d1cd2d2947adf8967279c72967d.1679731817.git.ojaswin@linux.ibm.com> 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-GUID: ffTB42pTklzLitTW1si5D6iz_PIZf1TL X-Proofpoint-ORIG-GUID: g1mU77Rdh9WuOEGbJqQJ4IuBzAK_lciF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-24_11,2023-03-24_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303250065 X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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) Reviewed-by: Jan Kara --- fs/ext4/mballoc.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a1429d5a1197..daa8411d6b61 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3978,6 +3978,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 @@ -4135,17 +4158,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