Commit 2f424a5a authored by Ritesh Harjani's avatar Ritesh Harjani Committed by Theodore Ts'o

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: default avatarRitesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/93da0d0f073c73358e85bb9849d8a5378d1da539.1582880246.git.riteshh@linux.ibm.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 6386722a
...@@ -549,6 +549,12 @@ int ext4_ext_precache(struct inode *inode) ...@@ -549,6 +549,12 @@ int ext4_ext_precache(struct inode *inode)
down_read(&ei->i_data_sem); down_read(&ei->i_data_sem);
depth = ext_depth(inode); 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), path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
GFP_NOFS); GFP_NOFS);
if (path == NULL) { if (path == NULL) {
...@@ -556,9 +562,6 @@ int ext4_ext_precache(struct inode *inode) ...@@ -556,9 +562,6 @@ int ext4_ext_precache(struct inode *inode)
return -ENOMEM; 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); path[0].p_hdr = ext_inode_hdr(inode);
ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment