Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp987871ybf; Thu, 27 Feb 2020 03:11:13 -0800 (PST) X-Google-Smtp-Source: APXvYqwPE6lVDugOd9gJTvTlNUDbno2p+lM4o48auDA5CgJ+/wntckkf7ZTASdHYn3eEe8ftN+xb X-Received: by 2002:aca:b2c5:: with SMTP id b188mr2844277oif.163.1582801873302; Thu, 27 Feb 2020 03:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582801873; cv=none; d=google.com; s=arc-20160816; b=m1qvL3NOoW4/qDHwjxY6+1CSxgTGwhaYovRTdiqEMQEZokmKkdwc4lmLRA52kYGvKE lL5nEQDQYHk5Hz5MpppdfrNIkpnXBba+5qEwrsQsu0pri887cKkVF632JLfqbcU+E2gr 5kV6q4rCAyX1DqA80qp7j5jEo0eedLh+3506YErwE3Rf0yyX+gupPh+6Q9R/n5XC7NyW IkFRfTg72XNYCksqhXjfLhqxhc4SYhvrgGKhhBzZwC/Rix2UDJN5zA0eBpItwTLhXxZB 9th9bcr5qMz/UqrWEjchKDY7D25QMD121XDy/VbmlaQberbuWwvCqX+/VZ/zh0s4z6Ob jFXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=Wc6Gvs41P+BgDB4fp4g908dTv+LkdTnus9JfDJyxY10=; b=TuXjndONDLnV6h7NYmwGi0BU4DDXEee8me73wA9Jr7iCCeA/3wR5OLLy+opd4nbSOy EkC8Zmco1pHXerW8RyaIP7Kig6RH+tVm0LUXJfUjWYvWCpmDenshU59e3cRMIG20GcAm LTi0T9TkiEBV31QQCUCKCqwWj/LqFU3Jr1YZK0xuA6tGhGSEVZNaOiLVngiawjjVf/db wrwRreKAtXpnolPTkkAjIwFphDK7aiQ/tzwSd6BFDqYdEdYMKn5uq5JzC8e/rPyMmD3L We+AAysjluCWJqMeIA0SvVANVs5vEGw1LVPm5ip6+ZL5jREVhXOIN5flyQurlVbovdL6 aFKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s6si1287449otq.115.2020.02.27.03.11.00; Thu, 27 Feb 2020 03:11:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728886AbgB0LKs (ORCPT + 99 others); Thu, 27 Feb 2020 06:10:48 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:11700 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728876AbgB0LKs (ORCPT ); Thu, 27 Feb 2020 06:10:48 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01RBARHB103547 for ; Thu, 27 Feb 2020 06:10:47 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ydcnhfq1r-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 27 Feb 2020 06:10:47 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Feb 2020 11:10:45 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 27 Feb 2020 11:10:41 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01RBAevE55771202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Feb 2020 11:10:40 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DD8742047; Thu, 27 Feb 2020 11:10:40 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E1D142045; Thu, 27 Feb 2020 11:10:37 +0000 (GMT) Received: from dhcp-9-199-158-169.in.ibm.com (unknown [9.199.158.169]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 27 Feb 2020 11:10:36 +0000 (GMT) From: Ritesh Harjani To: jack@suse.cz, tytso@mit.edu, linux-ext4@vger.kernel.org Cc: adilger.kernel@dilger.ca, linux-fsdevel@vger.kernel.org, darrick.wong@oracle.com, hch@infradead.org, cmaiolino@redhat.com, david@fromorbit.com, Ritesh Harjani Subject: [PATCHv4 2/6] ext4: Optimize ext4_ext_precache for 0 depth Date: Thu, 27 Feb 2020 16:40:23 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 20022711-0008-0000-0000-00000356EB06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022711-0009-0000-0000-00004A780CD5 Message-Id: <646479a04296e6284b68788b5f04ab5284017454.1582800839.git.riteshh@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-27_03:2020-02-26,2020-02-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=11 impostorscore=0 clxscore=1015 mlxscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=324 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002270090 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch avoids the memory alloc & free path when depth is 0, since anyway there is no extra caching done in that case. So on checking depth 0, simply return early. Signed-off-by: Ritesh Harjani Reviewed-by: Jan Kara --- fs/ext4/extents.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index ee83fe7c98aa..0de548bb3c90 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -594,6 +594,12 @@ int ext4_ext_precache(struct inode *inode) down_read(&ei->i_data_sem); depth = ext_depth(inode); + /* Don't cache anything if there are no external extent blocks */ + if (!depth) { + up_read(&ei->i_data_sem); + return ret; + } + path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), GFP_NOFS); if (path == NULL) { @@ -601,9 +607,6 @@ int ext4_ext_precache(struct inode *inode) return -ENOMEM; } - /* Don't cache anything if there are no external extent blocks */ - if (depth == 0) - goto out; path[0].p_hdr = ext_inode_hdr(inode); ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); if (ret) -- 2.21.0