Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp240092ybl; Tue, 28 Jan 2020 02:19:27 -0800 (PST) X-Google-Smtp-Source: APXvYqymV55OQXj7XBZ873Z1p3eyklEUOQEUbhnTTuI0I9yjs/ohRhWhMRg8kG2oXnIG8jFeQEAj X-Received: by 2002:aca:4994:: with SMTP id w142mr2293241oia.178.1580206767787; Tue, 28 Jan 2020 02:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580206767; cv=none; d=google.com; s=arc-20160816; b=RaUn1sZqBN0nRRBrylAcaMxwRVNgXIaUUgSOtWnoJHVb3UBZCeWfjZ2KLREUPMlt31 nsPy/31LND3kf5RzU939h+6dHEqgkVTWMq/D7yy7DGMzUMpSta7/1qxXN2wEAcMnyinP obndLgY2UeG/DfWegVAYnRSjhC/eL32uJVvapGg2/vpOjTsZ60nBfH7MmEE3TQNh51bw 24LhmTkT3CBi9nZZBw/kf1uIB1smDR4+f8Y9KguEUSkCwe1RIe7JTp/wTMIFCBrjmGZS HZfge2WRNG2N9tHKXGvG2hNZItNYOrhCW9Z3+t9FAA7UALYzCaffoBrIdCZHouEUYZTx FYaw== 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=f/EuRzCsbu44AxVdf+Oy9KQOBexUvnEaXBPxSwXPahNiYKLjVFMqQseK0rcYuVxMeF YEC/q5mEDaydW00IBAb/Pqtk465cnkH61imrYmzKSBz9KpjOixP2wkJgKjyIm/76QOJ7 nCcMQBAXO74adjCB/rbZYPT0bzQDZxuxAwmpKQI5frt2xJmYfby6T5Nc4rO+t4F1TfhS Y4sm7pBCD9BK/7n+T6/3vz8e+wSz/SvkFcxdFMTLqtEFE2IHCB4gw/9vBoLqJ6GCxeiu 8TL0ak19sIr870F8Cohr05RwEwCqd1sfPtc6ebTL7OsqMV/fzZ9Bhkz+vqx67jifNePT 0HkA== 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 l5si2508563otn.35.2020.01.28.02.19.15; Tue, 28 Jan 2020 02:19:27 -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 S1726097AbgA1KS4 (ORCPT + 99 others); Tue, 28 Jan 2020 05:18:56 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:62258 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726066AbgA1KS4 (ORCPT ); Tue, 28 Jan 2020 05:18:56 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00SA9k6I117300 for ; Tue, 28 Jan 2020 05:18:55 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xrje9xgn5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jan 2020 05:18:54 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Jan 2020 10:18:46 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 28 Jan 2020 10:18:42 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00SAHolI31326596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Jan 2020 10:17:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 626EDAE059; Tue, 28 Jan 2020 10:18:41 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A23CAE057; Tue, 28 Jan 2020 10:18:39 +0000 (GMT) Received: from dhcp-9-199-158-40.in.ibm.com (unknown [9.199.158.40]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 28 Jan 2020 10:18:38 +0000 (GMT) From: Ritesh Harjani To: jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, darrick.wong@oracle.com, hch@infradead.org, cmaiolino@redhat.com, Ritesh Harjani Subject: [RFCv2 2/4] ext4: Optimize ext4_ext_precache for 0 depth Date: Tue, 28 Jan 2020 15:48:26 +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: 20012810-0012-0000-0000-000003816244 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20012810-0013-0000-0000-000021BDB511 Message-Id: <597d295e3f667478de3e085800f7cdad75722823.1580121790.git.riteshh@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-28_02:2020-01-24,2020-01-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=11 clxscore=1015 spamscore=0 mlxscore=0 mlxlogscore=307 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001280083 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