diff options
author | Ritesh Harjani <riteshh@linux.ibm.com> | 2020-02-28 14:56:55 +0530 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-03-14 14:43:12 -0400 |
commit | 2f424a5a09a506e1a6ad432e50bca3000a767d5a (patch) | |
tree | 8b62c291f6306576bfa7d3dcf0a1c9fa5713f9ec /fs/ext4 | |
parent | 6386722a329824e005c3fd1b4a8cc37db367c76a (diff) |
ext4: optimize ext4_ext_precache for 0 depth
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 <riteshh@linux.ibm.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/93da0d0f073c73358e85bb9849d8a5378d1da539.1582880246.git.riteshh@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/extents.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index bc96529d1509..2ebc858fd392 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -549,6 +549,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) { @@ -556,9 +562,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) |