From: onur-ozkan <work@onurozkan.dev>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
onur-ozkan <work@onurozkan.dev>
Subject: [PATCH] fs: micro optimizations in ext4/xattr
Date: Fri, 8 Sep 2023 11:24:56 +0300 [thread overview]
Message-ID: <20230908082456.25983-1-work@onurozkan.dev> (raw)
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
reply other threads:[~2023-09-08 8:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230908082456.25983-1-work@onurozkan.dev \
--to=work@onurozkan.dev \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®