* [PATCH] fs: micro optimizations in ext4/xattr
@ 2023-09-08 8:24 onur-ozkan
0 siblings, 0 replies; only message in thread
From: onur-ozkan @ 2023-09-08 8:24 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4, linux-kernel, onur-ozkan
Improve the `ext4_xattr_inode_read` function slightly by using the
constant literal(from `MAX_BHS_SIZE`) for the `bhs_inline` initialization
and in the size checking condition as a replacement for `ARRAY_SIZE`.
Additionally, in the `ext4_xattr_cmp function, remove the `if` block to
improve code readability and clarity.
Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
fs/ext4/xattr.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 92ba28cebac6..e749aab8a152 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -376,6 +376,8 @@ static void ext4_xattr_inode_set_hash(struct inode *ea_inode, u32 hash)
ea_inode->i_atime.tv_sec = hash;
}
+#define MAX_BHS_SIZE 8
+
/*
* Read the EA value from an inode.
*/
@@ -384,11 +386,11 @@ static int ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t size)
int blocksize = 1 << ea_inode->i_blkbits;
int bh_count = (size + blocksize - 1) >> ea_inode->i_blkbits;
int tail_size = (size % blocksize) ?: blocksize;
- struct buffer_head *bhs_inline[8];
+ struct buffer_head *bhs_inline[MAX_BHS_SIZE];
struct buffer_head **bhs = bhs_inline;
int i, ret;
- if (bh_count > ARRAY_SIZE(bhs_inline)) {
+ if (bh_count > MAX_BHS_SIZE) {
bhs = kmalloc_array(bh_count, sizeof(*bhs), GFP_NOFS);
if (!bhs)
return -ENOMEM;
@@ -3093,9 +3095,8 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
entry1 = EXT4_XATTR_NEXT(entry1);
entry2 = EXT4_XATTR_NEXT(entry2);
}
- if (!IS_LAST_ENTRY(entry2))
- return 1;
- return 0;
+
+ return (IS_LAST_ENTRY(entry2)) ? 0 : 1;
}
/*
--
2.42.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-08 8:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08 8:24 [PATCH] fs: micro optimizations in ext4/xattr onur-ozkan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®