[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251208062100.3268777-27-chenxiaosong.chenxiaosong@linux.dev>
Date: Mon, 8 Dec 2025 14:20:56 +0800
From: chenxiaosong.chenxiaosong@...ux.dev
To: sfrench@...ba.org,
smfrench@...il.com,
linkinjeon@...nel.org,
linkinjeon@...ba.org
Cc: linux-cifs@...r.kernel.org,
linux-kernel@...r.kernel.org,
liuzhengyuan@...inos.cn,
huhai@...inos.cn,
liuyun01@...inos.cn,
ChenXiaoSong <chenxiaosong@...inos.cn>
Subject: [PATCH 26/30] smb/client: sort mapping_table_ERRSRV array
From: ChenXiaoSong <chenxiaosong@...inos.cn>
Sort the array in ascending order, and then we can use binary search
algorithm to quickly find the target server class of error code.
Signed-off-by: ChenXiaoSong <chenxiaosong@...inos.cn>
---
fs/smb/client/netmisc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/smb/client/netmisc.c b/fs/smb/client/netmisc.c
index 553d2a33b6de..4b5c049d69b9 100644
--- a/fs/smb/client/netmisc.c
+++ b/fs/smb/client/netmisc.c
@@ -103,7 +103,7 @@ static struct smb_to_posix_error mapping_table_ERRDOS[] = {
static unsigned int errdos_num = sizeof(mapping_table_ERRDOS) /
sizeof(struct smb_to_posix_error);
-static const struct smb_to_posix_error mapping_table_ERRSRV[] = {
+static struct smb_to_posix_error mapping_table_ERRSRV[] = {
{ERRerror, -EIO},
{ERRbadpw, -EACCES}, /* was EPERM */
{ERRbadtype, -EREMOTE},
@@ -148,6 +148,9 @@ static const struct smb_to_posix_error mapping_table_ERRSRV[] = {
{0, 0}
};
+static unsigned int errsrv_num = sizeof(mapping_table_ERRSRV) /
+ sizeof(struct smb_to_posix_error);
+
/*
* Convert a string containing text IPv4 or IPv6 address to binary form.
*
@@ -1077,6 +1080,8 @@ void smb_init_maperror(void)
cmp_nt_err_code_struct, NULL);
sort(mapping_table_ERRDOS, errdos_num,
sizeof(struct smb_to_posix_error), cmp_smb_to_posix_error, NULL);
+ sort(mapping_table_ERRSRV, errsrv_num,
+ sizeof(struct smb_to_posix_error), cmp_smb_to_posix_error, NULL);
}
#if IS_ENABLED(CONFIG_SMB_KUNIT_TESTS)
--
2.43.0
Powered by blists - more mailing lists