diff options
author | Chengguang Xu <cgxu519@zoho.com.cn> | 2019-05-28 10:59:47 +0800 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2019-05-28 10:23:52 +0200 |
commit | 1eaf5faab18cd55a3658e0c7517654325f59a793 (patch) | |
tree | d836a20b84fc05cfd471a94093ab476460070ea6 /fs/ext2 | |
parent | d561d4dd4f560e4d97bf665c5eeab7ac9fe8aca3 (diff) |
ext2: optimize ext2_xattr_get()
Since xattr entry names are sorted, we don't have
to continue when current entry name is greater than
target.
Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/xattr.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 59356cd2a842..839e71e78673 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -199,7 +199,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name, struct ext2_xattr_entry *entry; size_t name_len, size; char *end; - int error; + int error, not_found; struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", @@ -238,10 +238,14 @@ bad_block: if (!ext2_xattr_entry_valid(entry, end, inode->i_sb->s_blocksize)) goto bad_block; - if (name_index == entry->e_name_index && - name_len == entry->e_name_len && - memcmp(name, entry->e_name, name_len) == 0) + + not_found = ext2_xattr_cmp_entry(name_index, name_len, name, + entry); + if (!not_found) goto found; + if (not_found < 0) + break; + entry = EXT2_XATTR_NEXT(entry); } if (ext2_xattr_cache_insert(ea_block_cache, bh)) |