ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT
authorRobin Dong <hao.bigrat@gmail.com>
Mon, 18 Jul 2011 03:27:43 +0000 (23:27 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 18 Jul 2011 03:27:43 +0000 (23:27 -0400)
This patch avoids an extraneous lookup of the extent cache
in ext4_ext_map_blocks() when the flag
EXT4_GET_BLOCKS_PUNCH_OUT_EXT is absent.

The existing logic was performing the lookup but not making
use of the result. The patch simply reverses the order of evaluation
in the condition.

Since ext4_ext_in_cache() does not initialize newex on misses, bypassing
its invocation does not introduce any new issue in this regard.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Gouriou <egouriou@google.com>
fs/ext4/extents.c

index 3d8c5f50ba33c1c911b70a4250721692b1b13891..b8acfab00224b321e112535d214b6a18c386e92b 100644 (file)
@@ -3320,8 +3320,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
        trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);
 
        /* check in cache */
-       if (ext4_ext_in_cache(inode, map->m_lblk, &newex) &&
-               ((flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) == 0)) {
+       if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) &&
+               ext4_ext_in_cache(inode, map->m_lblk, &newex)) {
                if (!newex.ee_start_lo && !newex.ee_start_hi) {
                        if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
                                /*