From patchwork Thu Jun 29 13:47:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ojaswin Mujoo X-Patchwork-Id: 114312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9655649vqr; Thu, 29 Jun 2023 06:58:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlGU4B5lCb+d8hjtHUFtwk6DSsYGe+FXv+qjItEr61HuGcFIbFqMkRtUteyXMf2itdpUhv4r X-Received: by 2002:a05:6a00:8016:b0:677:3439:874a with SMTP id eg22-20020a056a00801600b006773439874amr22434pfb.3.1688047120767; Thu, 29 Jun 2023 06:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688047120; cv=none; d=google.com; s=arc-20160816; b=Nn89ic62jEM4DhIz78YBoxSzvG7g6UBMVA3CLv05FdppI5EQZunMZaayvkzTQzD97j n8j/Og/ZyKwPuNnLa5yAozrpqsCHUWxpYVKIGrgMo+luEVBsh4tudcXcXysBrfWYKM0V nNj+7xrZPvmlhtcxaF+zbCr2/duu51H4Uxpxp9dGnnIPkSE2kZ8kjRkIQkldiSQA8F0y w7eFpLKxerxyYdFuP0VuXu13bkppmE1RqspPV4BCWlE7RnfQ2EC/WouaLLUYVZ+av9KZ 8txuQrFqUvvGHFQn6PrktDYfY6DKCU+yH95P6zP5vlf5lKz4rlcLhy6qYfU5ztCGK0qm ehIw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=dbRiAIZ0g8cUPtf7bZFwLT9yLNoqZAhs7QkDidxTlAk=; fh=jMRh0H0t5P7/eG8aZwh1VPPTYWftNNNixJQcr1Xph60=; b=tJ4wEcV4k4L4nygGq6M/avzlgtJw6LJR4SZeDztlWajaqY5gF/71pdPiAoKz+EHk+h crCf8fRj09Y/L/NUhz9bj4xmmskKJnADjhT4N3FtJRCMaYK47Lwunx1GTL/ljMaKFVP2 BcDzgLOsD6GTMs3gjHDdZ5QCn77+F/E8mLcckMtzme4Yw3Di9vSozP9oNoRVjjJ855EP fYx8LQ8pRf99Sf4bEtVxR62YIX8WbbfV3ZQEJCbJDvCWU8LFrmHLtmeUJy7xrybuichu lqLcA/asKLVQTmw+kAI7ScXtAllM++YAHM1SHgO13ZDKAnc6edu2qvGzokER7czzP8+9 Oygw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ajX6+rkx; 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; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a634a03000000b0054a291a0bf9si10415582pga.672.2023.06.29.06.58.25; Thu, 29 Jun 2023 06:58:40 -0700 (PDT) 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; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ajX6+rkx; 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; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232128AbjF2Nrs (ORCPT + 99 others); Thu, 29 Jun 2023 09:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232096AbjF2Nrq (ORCPT ); Thu, 29 Jun 2023 09:47:46 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09CC63588; Thu, 29 Jun 2023 06:47:45 -0700 (PDT) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TDiliY003116; Thu, 29 Jun 2023 13:47:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=dbRiAIZ0g8cUPtf7bZFwLT9yLNoqZAhs7QkDidxTlAk=; b=ajX6+rkx6KLqsqwDCB5WeM4DqMS1DWnoeCPBhtJ4TJXOdNcmWPKHhXJgb5Y7/4PAe8kg XLIBD/Qp5I6LuYjBn6koBrcqxLALhpAqSVhgaQd310nBDRDqdM7fFyv+jEoNzd957kIX o6/UmCnCet+KGUEprwYrBYcs0EqiO9zp5Nx5xX9X+VvkXsbY1smqjAwh725q5sL5JogC EHCj12ktc170T22oAMRAfpGLzM4ezIBE8qDe8/O1AlquX+QXbZ1rD1AEJ1sCIDM0JFOW Lv1x9E+PHTFC5JRgoWVxZBL9uScO/4G9nsaVAXvar9BFCcAHonStsMWtRH3aqpldKiQ+ Hw== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rhb3u04yf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 13:47:27 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35T7voGf003733; Thu, 29 Jun 2023 13:47:25 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3rdr453cd0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 13:47:25 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35TDlNDx43451020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 13:47:23 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 847A02004D; Thu, 29 Jun 2023 13:47:23 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBF0D20040; Thu, 29 Jun 2023 13:47:21 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com.com (unknown [9.43.95.242]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Jun 2023 13:47:21 +0000 (GMT) From: Ojaswin Mujoo To: linux-ext4@vger.kernel.org, "Theodore Ts'o" Cc: Ritesh Harjani , linux-kernel@vger.kernel.org, Jan Kara , Kemeng Shi Subject: [PATCH] ext4: Replace CR_FAST macro with inline function for readability Date: Thu, 29 Jun 2023 19:17:19 +0530 Message-Id: <20230629134719.108104-1-ojaswin@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Xr3wRvvdaDjVBLg7-_5mr_6rGqNTZZe4 X-Proofpoint-ORIG-GUID: Xr3wRvvdaDjVBLg7-_5mr_6rGqNTZZe4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-29_03,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 priorityscore=1501 impostorscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306290122 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770045697786471315?= X-GMAIL-MSGID: =?utf-8?q?1770045697786471315?= Replace CR_FAST with ext4_mb_cr_expensive() inline function for better readability. This function returns true if the criteria is one of the expensive/slower ones where lots of disk IO/prefetching is acceptable. No functional changes are intended in this patch. Signed-off-by: Ojaswin Mujoo Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 7 ++++--- fs/ext4/mballoc.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 45a531446ea2..e404169a2858 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -176,9 +176,6 @@ enum criteria { EXT4_MB_NUM_CRS }; -/* criteria below which we use fast block scanning and avoid unnecessary IO */ -#define CR_FAST CR_GOAL_LEN_SLOW - /* * Flags used in mballoc's allocation_context flags field. * @@ -2924,6 +2921,10 @@ extern int ext4_trim_fs(struct super_block *, struct fstrim_range *); extern void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid); extern void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block, int len, int state); +static inline bool ext4_mb_cr_expensive(enum criteria cr) +{ + return cr >= CR_GOAL_LEN_SLOW; +} /* inode.c */ void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw, diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a2475b8c9fb5..94fdcc757aa9 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2446,7 +2446,7 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, break; } - if (ac->ac_criteria < CR_FAST) { + if (!ext4_mb_cr_expensive(ac->ac_criteria)) { /* * In CR_GOAL_LEN_FAST and CR_BEST_AVAIL_LEN, we are * sure that this group will have a large enough @@ -2630,7 +2630,7 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac, free = grp->bb_free; if (free == 0) goto out; - if (cr <= CR_FAST && free < ac->ac_g_ex.fe_len) + if (cr <= CR_GOAL_LEN_SLOW && free < ac->ac_g_ex.fe_len) goto out; if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) goto out; @@ -2654,7 +2654,7 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac, * sure we locate metadata blocks in the first block group in * the flex_bg if possible. */ - if (cr < CR_FAST && + if (!ext4_mb_cr_expensive(cr) && (!sbi->s_log_groups_per_flex || ((group & ((1 << sbi->s_log_groups_per_flex) - 1)) != 0)) && !(ext4_has_group_desc_csum(sb) && @@ -2848,7 +2848,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) * spend a lot of time loading imperfect groups */ if ((prefetch_grp == group) && - (cr >= CR_FAST || + (ext4_mb_cr_expensive(cr) || prefetch_ios < sbi->s_mb_prefetch_limit)) { nr = sbi->s_mb_prefetch; if (ext4_has_feature_flex_bg(sb)) {