Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4872542ybv; Wed, 26 Feb 2020 04:32:50 -0800 (PST) X-Google-Smtp-Source: APXvYqzgQ1S6odL0cT6L2+5E6VXt6jChRDDSje5crxLxoaalzn+ZTusaOFbvJgbGaKz3zGZ53/hB X-Received: by 2002:a9d:de9:: with SMTP id 96mr2789664ots.222.1582720370152; Wed, 26 Feb 2020 04:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582720370; cv=none; d=google.com; s=arc-20160816; b=MBN0FEAGivbcCHV+TSyANU5e++oWMmJz+pQDrN8GcQReNsRCsiRRSzioTaKsgf+mP3 PCa8V3eJPYNw/R10lbWX630ryL6u/Rq7oSaQZDlmUi98WI+FFsIuFw6w7XeDdOKBkLoe NTelBAVHSpT1euZnG6si1Z8NU0eMkAU5S8Z1LW4pUfuMtlBJfHCVfgsbLgY2r0S3k4aN xOqJ8/+DLb7PucFnkNkBgMcYa/jjpXL7Brh6pKts5nTnnekQqicFKAp+CPg8Mnikg4vG pI5J8PR8FQeowpSlUn3JVfQ84eAIi7mJSNXV+FoVuO6TNTFQO6PWgq6XrAQy+/NjRGhT bZ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1LFGC2LDEfgjZSELhzQDmfiNpcEi5WGnAilCK+nwbQk=; b=u1E1W2ETLZU1p2Pb5FSzLtKZ9ICCChSve+IPuM8tQYsPSxbgOBDrswV4thnnBzK+Iq ellzP4rcxt4DjgjJFozBbZTiNe6EqmJGpN/KVi8AJWy3WH86AMtGkUzIwYfNj+ncl9Ng L+Q5ttJsZZsfaE9s9RNEDzdUFtGIPjwD3PVoiaHRJ8TLsVKZVceVYQ0noRb/fu37IjGQ jVapnB9n8fxpjEYPAja/YJkzvRaNZcVvab8nslF8WoLGS0RE9wvhx53Q+Y+zoFNi8L2L 5LiFveI2sxEMenYD4WEEdG4b52/9yCuKCP0VU2SLNaLuojw2rgufSjOqgR1D2Nm9qen2 /3xA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20si1052192oih.70.2020.02.26.04.32.38; Wed, 26 Feb 2020 04:32:50 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726819AbgBZM2t (ORCPT + 99 others); Wed, 26 Feb 2020 07:28:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:42638 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbgBZM2t (ORCPT ); Wed, 26 Feb 2020 07:28:49 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CB0F9AC53; Wed, 26 Feb 2020 12:28:47 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 730321E0EA2; Wed, 26 Feb 2020 13:28:47 +0100 (CET) Date: Wed, 26 Feb 2020 13:28:47 +0100 From: Jan Kara To: Ritesh Harjani Cc: jack@suse.cz, tytso@mit.edu, linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca, linux-fsdevel@vger.kernel.org, darrick.wong@oracle.com, hch@infradead.org, cmaiolino@redhat.com Subject: Re: [PATCHv3 2/6] ext4: Optimize ext4_ext_precache for 0 depth Message-ID: <20200226122847.GN10728@quack2.suse.cz> References: <30a143eafd931603d54bef8026411d89c71ffdda.1582702694.git.riteshh@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <30a143eafd931603d54bef8026411d89c71ffdda.1582702694.git.riteshh@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed 26-02-20 15:27:04, Ritesh Harjani wrote: > 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 Looks good to me. You can add: Reviewed-by: Jan Kara Honza > --- > 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 > -- Jan Kara SUSE Labs, CR