Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2913317rwb; Mon, 16 Jan 2023 00:52:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXs13AerWqRjbPPO+/OnfSWmXBIvrhVFjAcir/WR/WgCe9gXcyf0TzkwbCCT1N/RMP4yA1m6 X-Received: by 2002:a17:906:8478:b0:84d:373b:39da with SMTP id hx24-20020a170906847800b0084d373b39damr28033007ejc.40.1673859137023; Mon, 16 Jan 2023 00:52:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673859137; cv=none; d=google.com; s=arc-20160816; b=Zq6iKTu/rZI/w0SE9vXkbhfobu/acpDvJ2Ip0XojpUUgUHeE9fj0i2Hcc6ToectQU1 KA35vyYKRjZgFJHomBgAtoi1C9dQ4Vu09gcPdssuvPE3ECHqz1x1N3cnn8g52/ueWpq7 rZx6Ik+9jiN5mrfh2csAsHKEmqyBoev66JCd8K7Q+P3Zrzh7EepUN47QnaytF7v9Qz9N 4NAa2T1E4XKXnKS625/+NLdJ550TmNRIQx5fKiXKhsapEkq5YoYV3A27lXvPK993aWZi FdQy1NaN4eOJIsGv6AZH1BLA2RVBFEpBPAbUcytma7srWKtzR8w/oqaIZHAw6buXqPmS 5WTQ== 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=xCvCGiyZshaoo7u5KiEiVhWdKt4a5oqWxtBVzxggjfU=; b=s+bYpw333Xr5La/by30sS7IfLVHG/fA47p/J0IP7CS5iuF0fBshTwQeTW65OSwEh9V +O9byWyNhA5w6TNf7T7olAwf/GmQcjmwX7RZmMvezuIIe2JLmg88iQtKCbMR7vhFUX80 KV1H0VsgWXYtp4D3oitvtOm+kGnQAsgbQWMzI0y4ztvVsnZsfPG+Wm1kgFUNGzFzKLpg QLcesFHRF3DHhfekkW6QUqQsfVvFm1IfG+HW0Y9CTYRmgGM6b6bJM5J7cCDGW6xOqa+O p7R9m1e0Q1KVZJ0XgOqMm0MqOuuQtEvexfVoBDoDkM46W1t9D4pecydszcH09VuAQ5Pi FvQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=SbDKGt7i; 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 sd1-20020a1709076e0100b008705d5bb5dcsi3286363ejc.85.2023.01.16.00.51.52; Mon, 16 Jan 2023 00:52:16 -0800 (PST) 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=SbDKGt7i; 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 S232180AbjAPIE1 (ORCPT + 99 others); Mon, 16 Jan 2023 03:04:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232153AbjAPIDS (ORCPT ); Mon, 16 Jan 2023 03:03:18 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AC046B3; Mon, 16 Jan 2023 00:02:54 -0800 (PST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30G5pfi7027923; Mon, 16 Jan 2023 08:02: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=xCvCGiyZshaoo7u5KiEiVhWdKt4a5oqWxtBVzxggjfU=; b=SbDKGt7izqBEwEWUH8ecCQTdwfp0dv0w0xlp+EjNu9yuq7XTf7LYPWEVSwkpXvtOsdme ntE2Z5RX68sVqaBXFaVhL/KVJ/1uhf8s/dSd+2/8Wevf9Nbynu+NIUprDWhemnxrA2an 5Pc1uISu5vhHhAoDCIRnnU2vs76mVJAo3pLMW4tsxd4u3Axk+/xxEYLWA1HASyBVSjt1 EmL+wd1OEaRux7V3humzmASl0ab8bQKUsByQVnx/lXmVOF48OO+bOQSmUGu8g+zbt6v0 8w2k2jE3bVzizKz9JaVa5t5eUvQmp+00alS2hN6nABfpy17o6Kp37F6AOeeroOCP3nT3 xw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n4f9c1ucb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Jan 2023 08:02:50 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30G7Z0lx017741; Mon, 16 Jan 2023 08:02:50 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n4f9c1u6r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Jan 2023 08:02:50 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30FKjgPK019225; Mon, 16 Jan 2023 08:02:31 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3n3m169gn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Jan 2023 08:02:31 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30G82SEE42991876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Jan 2023 08:02:28 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C845C2004B; Mon, 16 Jan 2023 08:02:28 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFE4120043; Mon, 16 Jan 2023 08:02:26 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.in.ibm.com (unknown [9.109.253.169]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 16 Jan 2023 08:02:26 +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 v3 4/8] ext4: Move overlap assert logic into a separate function Date: Mon, 16 Jan 2023 13:32:12 +0530 Message-Id: <20230116080216.249195-5-ojaswin@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230116080216.249195-1-ojaswin@linux.ibm.com> References: <20230116080216.249195-1-ojaswin@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: deTKAbRVbDRXFHbFuhv_YZrY-GCNQJs- X-Proofpoint-GUID: -uLG3OR_CfO6G726HqnHbJQDkUaSqGP6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-16_06,2023-01-13_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160058 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) Reviewed-by: Jan Kara --- 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 f4e699bce99f..1628b008a096 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3984,6 +3984,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 @@ -4140,18 +4163,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