Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4719435ybv; Wed, 26 Feb 2020 01:57:53 -0800 (PST) X-Google-Smtp-Source: APXvYqytT86g7CpYrfUwM0EMVMiA6rPYCFYBM6RXzaIWn7//44KG3ZDh35hsYQvXzISW1AcozMdh X-Received: by 2002:a05:6830:4a4:: with SMTP id l4mr2321429otd.91.1582711073641; Wed, 26 Feb 2020 01:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582711073; cv=none; d=google.com; s=arc-20160816; b=whWhlgBR5lh9Gj7LrjijZv3BGvioGaeFwCDcvkFKsKm4jkBPx8kabjJTVkCDr7DzCw LqmcLLf9kA3tRJNrojd1Th5QczTNInPodIBIh1vaB5o0XOD41kOO86s8Piu334JlxOeT C2VPRbXdLZCh7qrYe7IIfs1hckEbAH/fi2Tg2QPJRps+fNqboGdyK7qUNO9exTUsT0N7 pmPu5REr6DZtj6zAi6XuOoL5GYM7TMYDc5+lKfwdu+nPZoRYZtkTS04TXMrND2ND8Yop 3Ogj37uhh1K+/grc5R9wpGD8tnb1cRlm5xDbPcFMLUaJf0qKZ1oI+YBrUpHbXwLSEwD4 VQmQ== 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=nq4QFkXYoxcxDIy0nEunbxooHELGGAyJel3dNLWZTiI=; b=UlYfJVLZE5n9JUTA8YfGcilum+LZc4qskK3aDIAteodycp+5vp6tjqvES13PQOEv5z WcB/HvHAcfoDlmbdNQQEvxPglg6pGqQ1VatsM5tV8vJdFESiwVMvLugWq+iGKB6SdkiO kvL3Gc+HQosq7rIyRLz/7u2nGPRQaFppU/9CUAORBg/D7mTZBPsPlVNx1+c5J7RnpMT+ 478ofuhRgK0swLPhJ7EkiU8TzPihwLdBw7OUyJdOfr5y2y5nweEuqSxOuGcDZSzbR6O5 IJGtUj3dNQFlRwKCBosxJN7o0zUfRqljRiI6Hct2iMIEHKYPHptrdiIgxB45wRDQ9ohk BulA== 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 g5si1104788otn.232.2020.02.26.01.57.42; Wed, 26 Feb 2020 01:57:53 -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 S1726329AbgBZJ5g (ORCPT + 99 others); Wed, 26 Feb 2020 04:57:36 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58072 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727359AbgBZJ5e (ORCPT ); Wed, 26 Feb 2020 04:57:34 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01Q9q9Oq023278 for ; Wed, 26 Feb 2020 04:57:34 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ydh910gyc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 26 Feb 2020 04:57:32 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Feb 2020 09:57:29 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 26 Feb 2020 09:57:25 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01Q9vP4o58917114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2020 09:57:25 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB6C14204B; Wed, 26 Feb 2020 09:57:24 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D39624205F; Wed, 26 Feb 2020 09:57:22 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.199.47.18]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 26 Feb 2020 09:57:22 +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, Ritesh Harjani Subject: [PATCHv3 2/6] ext4: Optimize ext4_ext_precache for 0 depth Date: Wed, 26 Feb 2020 15:27:04 +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: 20022609-0028-0000-0000-000003DE196C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022609-0029-0000-0000-000024A334BB Message-Id: <30a143eafd931603d54bef8026411d89c71ffdda.1582702694.git.riteshh@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-26_02:2020-02-25,2020-02-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxlogscore=619 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=2 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002260074 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 --- 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