* [PATCH v4 00/10] smb: improve search speed of SMB2 maperror
@ 2025-12-06 15:18 chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 01/10] smb/client: reduce loop count in map_smb2_to_linux_error() by half chenxiaosong.chenxiaosong
` (10 more replies)
0 siblings, 11 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Before applying this patchset, when searching for the last element of
smb2_error_map_table array and calling smb2_print_status(),
3486 comparisons are needed.
After applying this patchset, only 10 comparisons are required.
v1: https://lore.kernel.org/linux-cifs/20251204045818.2590727-1-chenxiaosong.chenxiaosong@linux.dev/
The three patches from v1 have already been applied to the for-next branch of cifs-2.6.git.
Please replace the following patches:
- [v1 01/10] smb/client: reduce loop count in map_smb2_to_linux_error() by half: https://git.samba.org/sfrench/?p=sfrench/cifs-2.6.git;a=commitdiff;h=26866d690bd180e1860548c43e70fdefe50638ff
- Replace it with this version(v4) patch #0001: update commit message: array has 1743 elements
- [v1 02/10] smb/client: remove unused elements from smb2_error_map_table array: https://git.samba.org/sfrench/?p=sfrench/cifs-2.6.git;a=commitdiff;h=905d8999d67dcbe4ce12ef87996e4440e068196d
- It is the same as patch #0002 in this version(v4).
- [v1 03/10] smb: add two elements to smb2_error_map_table array: https://git.samba.org/sfrench/?p=sfrench/cifs-2.6.git;a=commitdiff;h=ba521f56912f6ff5121e54c17c855298f947c9ea
- Replace it with this version(v4) patch #0003 #0004.
v3: https://lore.kernel.org/linux-cifs/20251205132536.2703110-1-chenxiaosong.chenxiaosong@linux.dev/
v3->v4:
- Patch #0008: the KUnit test searches all elements of the smb2_error_map_table array
- Create patch #0009
ChenXiaoSong (10):
smb/client: reduce loop count in map_smb2_to_linux_error() by half
smb/client: remove unused elements from smb2_error_map_table array
smb: rename to STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP
smb/client: add two elements to smb2_error_map_table array
smb/client: sort smb2_error_map_table array
smb/client: use bsearch() to find target status code
smb/client: introduce smb2_get_err_map()
smb/client: introduce smb2maperror KUnit tests
smb/client: update some SMB2 status strings
smb/server: rename include guard in smb_common.h
fs/smb/Kconfig | 17 +++++
fs/smb/client/cifsfs.c | 2 +
fs/smb/client/smb2glob.h | 6 ++
fs/smb/client/smb2maperror.c | 101 +++++++++++++++++-------------
fs/smb/client/smb2maperror_test.c | 71 +++++++++++++++++++++
fs/smb/client/smb2proto.h | 4 +-
fs/smb/common/smb2status.h | 5 +-
fs/smb/server/smb2pdu.c | 2 +-
fs/smb/server/smb_common.h | 6 +-
9 files changed, 165 insertions(+), 49 deletions(-)
create mode 100644 fs/smb/client/smb2maperror_test.c
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 01/10] smb/client: reduce loop count in map_smb2_to_linux_error() by half
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 02/10] smb/client: remove unused elements from smb2_error_map_table array chenxiaosong.chenxiaosong
` (9 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
The smb2_error_map_table array currently has 1743 elements. When searching
for the last element and calling smb2_print_status(), 3486 comparisons
are needed.
The loop in smb2_print_status() is unnecessary, smb2_print_status() can be
removed, and only iterate over the array once, printing the message when
the target status code is found.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2maperror.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index 12c2b868789f..d1df6e518d21 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -2418,24 +2418,6 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
{0, 0, NULL}
};
-/*****************************************************************************
- Print an error message from the status code
- *****************************************************************************/
-static void
-smb2_print_status(__le32 status)
-{
- int idx = 0;
-
- while (smb2_error_map_table[idx].status_string != NULL) {
- if ((smb2_error_map_table[idx].smb2_status) == status) {
- pr_notice("Status code returned 0x%08x %s\n", status,
- smb2_error_map_table[idx].status_string);
- }
- idx++;
- }
- return;
-}
-
int
map_smb2_to_linux_error(char *buf, bool log_err)
{
@@ -2452,16 +2434,16 @@ map_smb2_to_linux_error(char *buf, bool log_err)
return 0;
}
- /* mask facility */
- if (log_err && (smb2err != STATUS_MORE_PROCESSING_REQUIRED) &&
- (smb2err != STATUS_END_OF_FILE))
- smb2_print_status(smb2err);
- else if (cifsFYI & CIFS_RC)
- smb2_print_status(smb2err);
+ log_err = (log_err && (smb2err != STATUS_MORE_PROCESSING_REQUIRED) &&
+ (smb2err != STATUS_END_OF_FILE)) ||
+ (cifsFYI & CIFS_RC);
for (i = 0; i < sizeof(smb2_error_map_table) /
sizeof(struct status_to_posix_error); i++) {
if (smb2_error_map_table[i].smb2_status == smb2err) {
+ if (log_err)
+ pr_notice("Status code returned 0x%08x %s\n", smb2err,
+ smb2_error_map_table[i].status_string);
rc = smb2_error_map_table[i].posix_error;
break;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 02/10] smb/client: remove unused elements from smb2_error_map_table array
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 01/10] smb/client: reduce loop count in map_smb2_to_linux_error() by half chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 03/10] smb: rename to STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP chenxiaosong.chenxiaosong
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
STATUS_SUCCESS and STATUS_WAIT_0 are both zero, and since zero indicates
success, they are not needed.
Since smb2_print_status() has been removed, the last element in the array
is no longer needed.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2maperror.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index d1df6e518d21..118e32cc8edc 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -23,8 +23,6 @@ struct status_to_posix_error {
};
static const struct status_to_posix_error smb2_error_map_table[] = {
- {STATUS_SUCCESS, 0, "STATUS_SUCCESS"},
- {STATUS_WAIT_0, 0, "STATUS_WAIT_0"},
{STATUS_WAIT_1, -EIO, "STATUS_WAIT_1"},
{STATUS_WAIT_2, -EIO, "STATUS_WAIT_2"},
{STATUS_WAIT_3, -EIO, "STATUS_WAIT_3"},
@@ -2415,7 +2413,6 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
{STATUS_IPSEC_INTEGRITY_CHECK_FAILED, -EIO,
"STATUS_IPSEC_INTEGRITY_CHECK_FAILED"},
{STATUS_IPSEC_CLEAR_TEXT_DROP, -EIO, "STATUS_IPSEC_CLEAR_TEXT_DROP"},
- {0, 0, NULL}
};
int
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 03/10] smb: rename to STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 01/10] smb/client: reduce loop count in map_smb2_to_linux_error() by half chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 02/10] smb/client: remove unused elements from smb2_error_map_table array chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 04/10] smb/client: add two elements to smb2_error_map_table array chenxiaosong.chenxiaosong
` (7 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
See MS-SMB2 3.3.5.4. To keep the name consistent with the documentation.
Additionally, move STATUS_INVALID_LOCK_RANGE to correct position in order.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/common/smb2status.h | 5 +++--
fs/smb/server/smb2pdu.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/smb/common/smb2status.h b/fs/smb/common/smb2status.h
index 14b4a5f04564..7d6b8ed304fc 100644
--- a/fs/smb/common/smb2status.h
+++ b/fs/smb/common/smb2status.h
@@ -631,6 +631,7 @@ struct ntstatus {
#define STATUS_DOMAIN_TRUST_INCONSISTENT cpu_to_le32(0xC000019B)
#define STATUS_FS_DRIVER_REQUIRED cpu_to_le32(0xC000019C)
#define STATUS_IMAGE_ALREADY_LOADED_AS_DLL cpu_to_le32(0xC000019D)
+#define STATUS_INVALID_LOCK_RANGE cpu_to_le32(0xC00001A1)
#define STATUS_NETWORK_OPEN_RESTRICTION cpu_to_le32(0xC0000201)
#define STATUS_NO_USER_SESSION_KEY cpu_to_le32(0xC0000202)
#define STATUS_USER_SESSION_DELETED cpu_to_le32(0xC0000203)
@@ -1773,5 +1774,5 @@ struct ntstatus {
#define STATUS_IPSEC_INVALID_PACKET cpu_to_le32(0xC0360005)
#define STATUS_IPSEC_INTEGRITY_CHECK_FAILED cpu_to_le32(0xC0360006)
#define STATUS_IPSEC_CLEAR_TEXT_DROP cpu_to_le32(0xC0360007)
-#define STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP cpu_to_le32(0xC05D0000)
-#define STATUS_INVALID_LOCK_RANGE cpu_to_le32(0xC00001a1)
+/* See MS-SMB2 3.3.5.4 */
+#define STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP cpu_to_le32(0xC05D0000)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index a4f6de350df8..b1323f1b100e 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -896,7 +896,7 @@ static __le32 decode_preauth_ctxt(struct ksmbd_conn *conn,
return STATUS_INVALID_PARAMETER;
if (pneg_ctxt->HashAlgorithms != SMB2_PREAUTH_INTEGRITY_SHA512)
- return STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP;
+ return STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP;
conn->preauth_info->Preauth_HashId = SMB2_PREAUTH_INTEGRITY_SHA512;
return STATUS_SUCCESS;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 04/10] smb/client: add two elements to smb2_error_map_table array
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (2 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 03/10] smb: rename to STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 05/10] smb/client: sort " chenxiaosong.chenxiaosong
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Both status codes are mapped to -EIO.
Now all status codes from common/smb2status.h are included in the
smb2_error_map_table array(except for the first two zero definitions).
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2maperror.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index 118e32cc8edc..a77467d2d81c 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -734,6 +734,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
{STATUS_FS_DRIVER_REQUIRED, -EOPNOTSUPP, "STATUS_FS_DRIVER_REQUIRED"},
{STATUS_IMAGE_ALREADY_LOADED_AS_DLL, -EIO,
"STATUS_IMAGE_ALREADY_LOADED_AS_DLL"},
+ {STATUS_INVALID_LOCK_RANGE, -EIO, "STATUS_INVALID_LOCK_RANGE"},
{STATUS_NETWORK_OPEN_RESTRICTION, -EIO,
"STATUS_NETWORK_OPEN_RESTRICTION"},
{STATUS_NO_USER_SESSION_KEY, -EIO, "STATUS_NO_USER_SESSION_KEY"},
@@ -2413,6 +2414,8 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
{STATUS_IPSEC_INTEGRITY_CHECK_FAILED, -EIO,
"STATUS_IPSEC_INTEGRITY_CHECK_FAILED"},
{STATUS_IPSEC_CLEAR_TEXT_DROP, -EIO, "STATUS_IPSEC_CLEAR_TEXT_DROP"},
+ {STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP, -EIO,
+ "STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP"},
};
int
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 05/10] smb/client: sort smb2_error_map_table array
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (3 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 04/10] smb/client: add two elements to smb2_error_map_table array chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 06/10] smb/client: use bsearch() to find target status code chenxiaosong.chenxiaosong
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Sort the array in ascending order, and then we can use binary search
algorithm to quickly find the target status code.
Since the smb2_init_maperror() is called only once when the module is
loaded, the array is sorted just once.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifsfs.c | 2 ++
fs/smb/client/smb2maperror.c | 25 ++++++++++++++++++++++++-
fs/smb/client/smb2proto.h | 1 +
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 6eccb9ed9daa..77d14b3dd650 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -49,6 +49,7 @@
#endif
#include "fs_context.h"
#include "cached_dir.h"
+#include "smb2proto.h"
/*
* DOS dates from 1980/1/1 through 2107/12/31
@@ -1908,6 +1909,7 @@ static int __init
init_cifs(void)
{
int rc = 0;
+ smb2_init_maperror();
cifs_proc_init();
INIT_LIST_HEAD(&cifs_tcp_ses_list);
/*
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index a77467d2d81c..1bd4196386dd 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -8,6 +8,7 @@
*
*/
#include <linux/errno.h>
+#include <linux/sort.h>
#include "cifsglob.h"
#include "cifs_debug.h"
#include "smb2pdu.h"
@@ -22,7 +23,7 @@ struct status_to_posix_error {
char *status_string;
};
-static const struct status_to_posix_error smb2_error_map_table[] = {
+static struct status_to_posix_error smb2_error_map_table[] = {
{STATUS_WAIT_1, -EIO, "STATUS_WAIT_1"},
{STATUS_WAIT_2, -EIO, "STATUS_WAIT_2"},
{STATUS_WAIT_3, -EIO, "STATUS_WAIT_3"},
@@ -2418,6 +2419,20 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
"STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP"},
};
+static unsigned int err_map_num = sizeof(smb2_error_map_table) /
+ sizeof(struct status_to_posix_error);
+
+static int cmp_smb2_status(const void *_a, const void *_b)
+{
+ const struct status_to_posix_error *a = _a, *b = _b;
+
+ if (a->smb2_status < b->smb2_status)
+ return -1;
+ if (a->smb2_status > b->smb2_status)
+ return 1;
+ return 0;
+}
+
int
map_smb2_to_linux_error(char *buf, bool log_err)
{
@@ -2461,3 +2476,11 @@ map_smb2_to_linux_error(char *buf, bool log_err)
le32_to_cpu(smb2err), rc);
return rc;
}
+
+void smb2_init_maperror(void)
+{
+ /* Sort in ascending order */
+ sort(smb2_error_map_table, err_map_num,
+ sizeof(struct status_to_posix_error),
+ cmp_smb2_status, NULL);
+}
diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h
index 5241daaae543..c988f6b37a1b 100644
--- a/fs/smb/client/smb2proto.h
+++ b/fs/smb/client/smb2proto.h
@@ -21,6 +21,7 @@ struct smb_rqst;
*****************************************************************
*/
extern int map_smb2_to_linux_error(char *buf, bool log_err);
+extern void smb2_init_maperror(void);
extern int smb2_check_message(char *buf, unsigned int length,
struct TCP_Server_Info *server);
extern unsigned int smb2_calc_size(void *buf);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 06/10] smb/client: use bsearch() to find target status code
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (4 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 05/10] smb/client: sort " chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 07/10] smb/client: introduce smb2_get_err_map() chenxiaosong.chenxiaosong
` (4 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
The smb2_error_map_table array currently has 1742 elements. When searching
for the last element, the original loop-based search method requires 1742
comparisons, while binary search algorithm requires only 10 comparisons.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2maperror.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index 1bd4196386dd..df8db12ff7a9 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -2437,9 +2437,9 @@ int
map_smb2_to_linux_error(char *buf, bool log_err)
{
struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
- unsigned int i;
int rc = -EIO;
__le32 smb2err = shdr->Status;
+ struct status_to_posix_error *err_map, key;
if (smb2err == 0) {
trace_smb3_cmd_done(le32_to_cpu(shdr->Id.SyncId.TreeId),
@@ -2453,17 +2453,21 @@ map_smb2_to_linux_error(char *buf, bool log_err)
(smb2err != STATUS_END_OF_FILE)) ||
(cifsFYI & CIFS_RC);
- for (i = 0; i < sizeof(smb2_error_map_table) /
- sizeof(struct status_to_posix_error); i++) {
- if (smb2_error_map_table[i].smb2_status == smb2err) {
- if (log_err)
- pr_notice("Status code returned 0x%08x %s\n", smb2err,
- smb2_error_map_table[i].status_string);
- rc = smb2_error_map_table[i].posix_error;
- break;
- }
- }
+ key = (struct status_to_posix_error) {
+ .smb2_status = smb2err,
+ };
+ err_map = bsearch(&key, smb2_error_map_table, err_map_num,
+ sizeof(struct status_to_posix_error),
+ cmp_smb2_status);
+ if (!err_map)
+ goto out;
+
+ rc = err_map->posix_error;
+ if (log_err)
+ pr_notice("Status code returned 0x%08x %s\n", smb2err,
+ err_map->status_string);
+out:
/* on error mapping not found - return EIO */
cifs_dbg(FYI, "Mapping SMB2 status code 0x%08x to POSIX err %d\n",
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 07/10] smb/client: introduce smb2_get_err_map()
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (5 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 06/10] smb/client: use bsearch() to find target status code chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests chenxiaosong.chenxiaosong
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
We may need to get struct status_to_posix_error information in other files
in the future. So we move struct status_to_posix_error to smb2glob.h, and
introduce new global function smb2_get_err_map().
Additionally, delete unused forward declaration `struct statfs`
in smb2proto.h.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2glob.h | 6 ++++++
fs/smb/client/smb2maperror.c | 28 +++++++++++++++-------------
fs/smb/client/smb2proto.h | 3 ++-
3 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/fs/smb/client/smb2glob.h b/fs/smb/client/smb2glob.h
index e56e4d402f13..fe6a5c7f01c4 100644
--- a/fs/smb/client/smb2glob.h
+++ b/fs/smb/client/smb2glob.h
@@ -13,6 +13,12 @@
#ifndef _SMB2_GLOB_H
#define _SMB2_GLOB_H
+struct status_to_posix_error {
+ __le32 smb2_status;
+ int posix_error;
+ char *status_string;
+};
+
/*
*****************************************************************
* Constants go here
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index df8db12ff7a9..0d46fa98952c 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -17,12 +17,6 @@
#include "smb2glob.h"
#include "trace.h"
-struct status_to_posix_error {
- __le32 smb2_status;
- int posix_error;
- char *status_string;
-};
-
static struct status_to_posix_error smb2_error_map_table[] = {
{STATUS_WAIT_1, -EIO, "STATUS_WAIT_1"},
{STATUS_WAIT_2, -EIO, "STATUS_WAIT_2"},
@@ -2433,13 +2427,26 @@ static int cmp_smb2_status(const void *_a, const void *_b)
return 0;
}
+struct status_to_posix_error *smb2_get_err_map(__le32 smb2_status)
+{
+ struct status_to_posix_error *err_map, key;
+
+ key = (struct status_to_posix_error) {
+ .smb2_status = smb2_status,
+ };
+ err_map = bsearch(&key, smb2_error_map_table, err_map_num,
+ sizeof(struct status_to_posix_error),
+ cmp_smb2_status);
+ return err_map;
+}
+
int
map_smb2_to_linux_error(char *buf, bool log_err)
{
struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
int rc = -EIO;
__le32 smb2err = shdr->Status;
- struct status_to_posix_error *err_map, key;
+ struct status_to_posix_error *err_map;
if (smb2err == 0) {
trace_smb3_cmd_done(le32_to_cpu(shdr->Id.SyncId.TreeId),
@@ -2453,12 +2460,7 @@ map_smb2_to_linux_error(char *buf, bool log_err)
(smb2err != STATUS_END_OF_FILE)) ||
(cifsFYI & CIFS_RC);
- key = (struct status_to_posix_error) {
- .smb2_status = smb2err,
- };
- err_map = bsearch(&key, smb2_error_map_table, err_map_num,
- sizeof(struct status_to_posix_error),
- cmp_smb2_status);
+ err_map = smb2_get_err_map(smb2err);
if (!err_map)
goto out;
diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h
index c988f6b37a1b..224840e3a00d 100644
--- a/fs/smb/client/smb2proto.h
+++ b/fs/smb/client/smb2proto.h
@@ -12,8 +12,8 @@
#include <linux/nls.h>
#include <linux/key-type.h>
-struct statfs;
struct smb_rqst;
+struct status_to_posix_error;
/*
*****************************************************************
@@ -21,6 +21,7 @@ struct smb_rqst;
*****************************************************************
*/
extern int map_smb2_to_linux_error(char *buf, bool log_err);
+extern struct status_to_posix_error *smb2_get_err_map(__le32 smb2_status);
extern void smb2_init_maperror(void);
extern int smb2_check_message(char *buf, unsigned int length,
struct TCP_Server_Info *server);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (6 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 07/10] smb/client: introduce smb2_get_err_map() chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-08 21:29 ` kernel test robot
2025-12-09 3:45 ` kernel test robot
2025-12-06 15:18 ` [PATCH v4 09/10] smb/client: update some SMB2 status strings chenxiaosong.chenxiaosong
` (2 subsequent siblings)
10 siblings, 2 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
The KUnit tests are executed when cifs.ko is loaded.
Just like fs/ext4/mballoc.c includes fs/ext4/mballoc-test.c.
smb2maperror.c also includes smb2maperror_test.c, allowing KUnit tests to
access any functions and variables in smb2maperror.c.
The maperror_test_check_sort() checks whether the array is properly sorted.
The maperror_test_check_search() checks whether the expected element can be
correctly searched for in the smb2_error_map_table array.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/Kconfig | 17 ++++++++
fs/smb/client/smb2maperror.c | 4 ++
fs/smb/client/smb2maperror_test.c | 71 +++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+)
create mode 100644 fs/smb/client/smb2maperror_test.c
diff --git a/fs/smb/Kconfig b/fs/smb/Kconfig
index ef425789fa6a..85f7ad5fbc5e 100644
--- a/fs/smb/Kconfig
+++ b/fs/smb/Kconfig
@@ -9,3 +9,20 @@ config SMBFS
tristate
default y if CIFS=y || SMB_SERVER=y
default m if CIFS=m || SMB_SERVER=m
+
+config SMB_KUNIT_TESTS
+ tristate "KUnit tests for SMB" if !KUNIT_ALL_TESTS
+ depends on SMBFS && KUNIT
+ default KUNIT_ALL_TESTS
+ help
+ This builds the SMB KUnit tests.
+
+ KUnit tests run during boot and output the results to the debug log
+ in TAP format (https://testanything.org/). Only useful for kernel devs
+ running KUnit test harness and are not for inclusion into a production
+ build.
+
+ For more information on KUnit and unit tests in general please refer
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
+
+ If unsure, say N.
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index 0d46fa98952c..dc2edeafc93b 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -2490,3 +2490,7 @@ void smb2_init_maperror(void)
sizeof(struct status_to_posix_error),
cmp_smb2_status, NULL);
}
+
+#if IS_ENABLED(CONFIG_SMB_KUNIT_TESTS)
+#include "smb2maperror_test.c"
+#endif /* CONFIG_SMB_KUNIT_TESTS */
diff --git a/fs/smb/client/smb2maperror_test.c b/fs/smb/client/smb2maperror_test.c
new file mode 100644
index 000000000000..b807a860ca59
--- /dev/null
+++ b/fs/smb/client/smb2maperror_test.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: LGPL-2.1
+/*
+ *
+ * KUnit tests of SMB2 maperror
+ *
+ * Copyright (C) 2025 KylinSoft Co., Ltd. All rights reserved.
+ * Author(s): ChenXiaoSong <chenxiaosong@kylinos.cn>
+ *
+ */
+
+#include <kunit/test.h>
+
+static void maperror_test_check_sort(struct kunit *test)
+{
+ bool is_sorted = true;
+ unsigned int i;
+
+ for (i = 1; i < err_map_num; i++) {
+ if (smb2_error_map_table[i].smb2_status >=
+ smb2_error_map_table[i - 1].smb2_status)
+ continue;
+
+ pr_err("smb2_error_map_table array order is incorrect\n");
+ is_sorted = false;
+ break;
+ }
+
+ KUNIT_EXPECT_EQ(test, true, is_sorted);
+}
+
+static void
+test_cmp_map(struct kunit *test, struct status_to_posix_error *expect)
+{
+ struct status_to_posix_error *result;
+
+ result = smb2_get_err_map(expect->smb2_status);
+ KUNIT_EXPECT_PTR_NE(test, NULL, result);
+ KUNIT_EXPECT_EQ(test, expect->smb2_status, result->smb2_status);
+ KUNIT_EXPECT_EQ(test, expect->posix_error, result->posix_error);
+ KUNIT_EXPECT_STREQ(test, expect->status_string, result->status_string);
+}
+
+static void maperror_test_check_search(struct kunit *test)
+{
+ unsigned int i;
+ struct status_to_posix_error expect;
+
+ for (i = 0; i < err_map_num; i++) {
+ expect = smb2_error_map_table[i];
+ test_cmp_map(test, &expect);
+ }
+}
+
+/*
+ * Before running these test cases, the smb2_init_maperror()
+ * function is called first.
+ */
+static struct kunit_case maperror_test_cases[] = {
+ KUNIT_CASE(maperror_test_check_sort),
+ KUNIT_CASE(maperror_test_check_search),
+ {}
+};
+
+static struct kunit_suite maperror_suite = {
+ .name = "smb2_maperror",
+ .test_cases = maperror_test_cases,
+};
+
+kunit_test_suite(maperror_suite);
+
+MODULE_LICENSE("GPL");
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 09/10] smb/client: update some SMB2 status strings
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (7 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-07 17:47 ` Steve French
2025-12-06 15:18 ` [PATCH v4 10/10] smb/server: rename include guard in smb_common.h chenxiaosong.chenxiaosong
2025-12-10 4:29 ` [PATCH v4 00/10] smb: improve search speed of SMB2 maperror ChenXiaoSong
10 siblings, 1 reply; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
The smb2maperror KUnit tests reported the following errors:
KTAP version 1
1..1
KTAP version 1
# Subtest: smb2_maperror
# module: cifs
1..2
ok 1 maperror_test_check_sort
# maperror_test_check_search: EXPECTATION FAILED at fs/smb/client/smb2maperror_test.c:40
Expected expect->status_string == result->status_string, but
expect->status_string == "STATUS_ABANDONED_WAIT_0"
result->status_string == "STATUS_ABANDONED"
# maperror_test_check_search: EXPECTATION FAILED at fs/smb/client/smb2maperror_test.c:40
Expected expect->status_string == result->status_string, but
expect->status_string == "STATUS_FWP_TOO_MANY_CALLOUTS"
result->status_string == "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS"
not ok 2 maperror_test_check_search
# smb2_maperror: pass:1 fail:1 skip:0 total:2
# Totals: pass:1 fail:1 skip:0 total:2
not ok 1 smb2_maperror
These status codes have duplicate values, so update the status strings to
make the log messages more explicit.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2maperror.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index dc2edeafc93b..e54b5871ecc9 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -22,8 +22,9 @@ static struct status_to_posix_error smb2_error_map_table[] = {
{STATUS_WAIT_2, -EIO, "STATUS_WAIT_2"},
{STATUS_WAIT_3, -EIO, "STATUS_WAIT_3"},
{STATUS_WAIT_63, -EIO, "STATUS_WAIT_63"},
- {STATUS_ABANDONED, -EIO, "STATUS_ABANDONED"},
- {STATUS_ABANDONED_WAIT_0, -EIO, "STATUS_ABANDONED_WAIT_0"},
+ {STATUS_ABANDONED, -EIO, "STATUS_ABANDONED or STATUS_ABANDONED_WAIT_0"},
+ {STATUS_ABANDONED_WAIT_0, -EIO,
+ "STATUS_ABANDONED or STATUS_ABANDONED_WAIT_0"},
{STATUS_ABANDONED_WAIT_63, -EIO, "STATUS_ABANDONED_WAIT_63"},
{STATUS_USER_APC, -EIO, "STATUS_USER_APC"},
{STATUS_KERNEL_APC, -EIO, "STATUS_KERNEL_APC"},
@@ -2292,8 +2293,9 @@ static struct status_to_posix_error smb2_error_map_table[] = {
{STATUS_FWP_LIFETIME_MISMATCH, -EIO, "STATUS_FWP_LIFETIME_MISMATCH"},
{STATUS_FWP_BUILTIN_OBJECT, -EIO, "STATUS_FWP_BUILTIN_OBJECT"},
{STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS, -EIO,
- "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS"},
- {STATUS_FWP_TOO_MANY_CALLOUTS, -EIO, "STATUS_FWP_TOO_MANY_CALLOUTS"},
+ "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS or STATUS_FWP_TOO_MANY_CALLOUTS"},
+ {STATUS_FWP_TOO_MANY_CALLOUTS, -EIO,
+ "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS or STATUS_FWP_TOO_MANY_CALLOUTS"},
{STATUS_FWP_NOTIFICATION_DROPPED, -EIO,
"STATUS_FWP_NOTIFICATION_DROPPED"},
{STATUS_FWP_TRAFFIC_MISMATCH, -EIO, "STATUS_FWP_TRAFFIC_MISMATCH"},
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 10/10] smb/server: rename include guard in smb_common.h
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (8 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 09/10] smb/client: update some SMB2 status strings chenxiaosong.chenxiaosong
@ 2025-12-06 15:18 ` chenxiaosong.chenxiaosong
2025-12-10 4:29 ` [PATCH v4 00/10] smb: improve search speed of SMB2 maperror ChenXiaoSong
10 siblings, 0 replies; 15+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-06 15:18 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Make the include guard more descriptive to avoid conflicts with include
guards that may be used in the future.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb_common.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index f47ce4a6719c..302c82480799 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -3,8 +3,8 @@
* Copyright (C) 2018 Samsung Electronics Co., Ltd.
*/
-#ifndef __SMB_COMMON_H__
-#define __SMB_COMMON_H__
+#ifndef __SMB_SERVER_COMMON_H__
+#define __SMB_SERVER_COMMON_H__
#include <linux/kernel.h>
@@ -196,4 +196,4 @@ unsigned int ksmbd_server_side_copy_max_chunk_size(void);
unsigned int ksmbd_server_side_copy_max_total_size(void);
bool is_asterisk(char *p);
__le32 smb_map_generic_desired_access(__le32 daccess);
-#endif /* __SMB_COMMON_H__ */
+#endif /* __SMB_SERVER_COMMON_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v4 09/10] smb/client: update some SMB2 status strings
2025-12-06 15:18 ` [PATCH v4 09/10] smb/client: update some SMB2 status strings chenxiaosong.chenxiaosong
@ 2025-12-07 17:47 ` Steve French
0 siblings, 0 replies; 15+ messages in thread
From: Steve French @ 2025-12-07 17:47 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: linkinjeon, linkinjeon, linux-cifs, linux-kernel, liuzhengyuan,
huhai, liuyun01, ChenXiaoSong
Good catch - merged into cifs-2.6.git for-next
On Sat, Dec 6, 2025 at 9:20 AM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> The smb2maperror KUnit tests reported the following errors:
>
> KTAP version 1
> 1..1
> KTAP version 1
> # Subtest: smb2_maperror
> # module: cifs
> 1..2
> ok 1 maperror_test_check_sort
> # maperror_test_check_search: EXPECTATION FAILED at fs/smb/client/smb2maperror_test.c:40
> Expected expect->status_string == result->status_string, but
> expect->status_string == "STATUS_ABANDONED_WAIT_0"
> result->status_string == "STATUS_ABANDONED"
> # maperror_test_check_search: EXPECTATION FAILED at fs/smb/client/smb2maperror_test.c:40
> Expected expect->status_string == result->status_string, but
> expect->status_string == "STATUS_FWP_TOO_MANY_CALLOUTS"
> result->status_string == "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS"
> not ok 2 maperror_test_check_search
> # smb2_maperror: pass:1 fail:1 skip:0 total:2
> # Totals: pass:1 fail:1 skip:0 total:2
> not ok 1 smb2_maperror
>
> These status codes have duplicate values, so update the status strings to
> make the log messages more explicit.
>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
> fs/smb/client/smb2maperror.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
> index dc2edeafc93b..e54b5871ecc9 100644
> --- a/fs/smb/client/smb2maperror.c
> +++ b/fs/smb/client/smb2maperror.c
> @@ -22,8 +22,9 @@ static struct status_to_posix_error smb2_error_map_table[] = {
> {STATUS_WAIT_2, -EIO, "STATUS_WAIT_2"},
> {STATUS_WAIT_3, -EIO, "STATUS_WAIT_3"},
> {STATUS_WAIT_63, -EIO, "STATUS_WAIT_63"},
> - {STATUS_ABANDONED, -EIO, "STATUS_ABANDONED"},
> - {STATUS_ABANDONED_WAIT_0, -EIO, "STATUS_ABANDONED_WAIT_0"},
> + {STATUS_ABANDONED, -EIO, "STATUS_ABANDONED or STATUS_ABANDONED_WAIT_0"},
> + {STATUS_ABANDONED_WAIT_0, -EIO,
> + "STATUS_ABANDONED or STATUS_ABANDONED_WAIT_0"},
> {STATUS_ABANDONED_WAIT_63, -EIO, "STATUS_ABANDONED_WAIT_63"},
> {STATUS_USER_APC, -EIO, "STATUS_USER_APC"},
> {STATUS_KERNEL_APC, -EIO, "STATUS_KERNEL_APC"},
> @@ -2292,8 +2293,9 @@ static struct status_to_posix_error smb2_error_map_table[] = {
> {STATUS_FWP_LIFETIME_MISMATCH, -EIO, "STATUS_FWP_LIFETIME_MISMATCH"},
> {STATUS_FWP_BUILTIN_OBJECT, -EIO, "STATUS_FWP_BUILTIN_OBJECT"},
> {STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS, -EIO,
> - "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS"},
> - {STATUS_FWP_TOO_MANY_CALLOUTS, -EIO, "STATUS_FWP_TOO_MANY_CALLOUTS"},
> + "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS or STATUS_FWP_TOO_MANY_CALLOUTS"},
> + {STATUS_FWP_TOO_MANY_CALLOUTS, -EIO,
> + "STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS or STATUS_FWP_TOO_MANY_CALLOUTS"},
> {STATUS_FWP_NOTIFICATION_DROPPED, -EIO,
> "STATUS_FWP_NOTIFICATION_DROPPED"},
> {STATUS_FWP_TRAFFIC_MISMATCH, -EIO, "STATUS_FWP_TRAFFIC_MISMATCH"},
> --
> 2.43.0
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests
2025-12-06 15:18 ` [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests chenxiaosong.chenxiaosong
@ 2025-12-08 21:29 ` kernel test robot
2025-12-09 3:45 ` kernel test robot
1 sibling, 0 replies; 15+ messages in thread
From: kernel test robot @ 2025-12-08 21:29 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong, sfrench, smfrench, linkinjeon,
linkinjeon
Cc: llvm, oe-kbuild-all, linux-cifs, linux-kernel, liuzhengyuan,
huhai, liuyun01, ChenXiaoSong
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on linus/master v6.18]
[cannot apply to cifs/for-next next-20251208]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/chenxiaosong-chenxiaosong-linux-dev/smb-client-reduce-loop-count-in-map_smb2_to_linux_error-by-half/20251206-232731
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20251206151826.2932970-9-chenxiaosong.chenxiaosong%40linux.dev
patch subject: [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests
config: i386-randconfig-004-20251208 (https://download.01.org/0day-ci/archive/20251209/202512090558.gcQGSnU4-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251209/202512090558.gcQGSnU4-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512090558.gcQGSnU4-lkp@intel.com/
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: kunit_binary_str_assert_format
>>> referenced by smb2maperror_test.c:40 (fs/smb/client/smb2maperror_test.c:40)
>>> fs/smb/client/smb2maperror.o:(maperror_test_check_search) in archive vmlinux.a
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests
2025-12-06 15:18 ` [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests chenxiaosong.chenxiaosong
2025-12-08 21:29 ` kernel test robot
@ 2025-12-09 3:45 ` kernel test robot
1 sibling, 0 replies; 15+ messages in thread
From: kernel test robot @ 2025-12-09 3:45 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong, sfrench, smfrench, linkinjeon,
linkinjeon
Cc: oe-kbuild-all, linux-cifs, linux-kernel, liuzhengyuan, huhai,
liuyun01, ChenXiaoSong
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on linus/master v6.18]
[cannot apply to cifs/for-next next-20251208]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/chenxiaosong-chenxiaosong-linux-dev/smb-client-reduce-loop-count-in-map_smb2_to_linux_error-by-half/20251206-232731
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20251206151826.2932970-9-chenxiaosong.chenxiaosong%40linux.dev
patch subject: [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests
config: i386-randconfig-063-20251208 (https://download.01.org/0day-ci/archive/20251209/202512091143.FGQ64S2k-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251209/202512091143.FGQ64S2k-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512091143.FGQ64S2k-lkp@intel.com/
All errors (new ones prefixed by >>):
ld: fs/smb/client/smb2maperror.o: in function `test_cmp_map':
>> fs/smb/client/smb2maperror_test.c:40:(.text+0x1d4): undefined reference to `kunit_binary_str_assert_format'
>> ld: fs/smb/client/smb2maperror_test.c:40:(.text+0x20c): undefined reference to `__kunit_do_failed_assertion'
>> ld: fs/smb/client/smb2maperror_test.c:39:(.text+0x245): undefined reference to `kunit_binary_assert_format'
ld: fs/smb/client/smb2maperror_test.c:39:(.text+0x263): undefined reference to `__kunit_do_failed_assertion'
ld: fs/smb/client/smb2maperror_test.c:38:(.text+0x274): undefined reference to `kunit_binary_assert_format'
ld: fs/smb/client/smb2maperror_test.c:38:(.text+0x2ba): undefined reference to `__kunit_do_failed_assertion'
>> ld: fs/smb/client/smb2maperror_test.c:37:(.text+0x2da): undefined reference to `kunit_binary_ptr_assert_format'
ld: fs/smb/client/smb2maperror_test.c:37:(.text+0x314): undefined reference to `__kunit_do_failed_assertion'
ld: fs/smb/client/smb2maperror.o: in function `maperror_test_check_sort':
>> fs/smb/client/smb2maperror_test.c:28:(.text.unlikely+0x4b): undefined reference to `kunit_binary_assert_format'
>> ld: fs/smb/client/smb2maperror_test.c:28:(.text.unlikely+0x60): undefined reference to `__kunit_do_failed_assertion'
vim +40 fs/smb/client/smb2maperror_test.c
12
13 static void maperror_test_check_sort(struct kunit *test)
14 {
15 bool is_sorted = true;
16 unsigned int i;
17
18 for (i = 1; i < err_map_num; i++) {
19 if (smb2_error_map_table[i].smb2_status >=
20 smb2_error_map_table[i - 1].smb2_status)
21 continue;
22
23 pr_err("smb2_error_map_table array order is incorrect\n");
24 is_sorted = false;
25 break;
26 }
27
> 28 KUNIT_EXPECT_EQ(test, true, is_sorted);
29 }
30
31 static void
32 test_cmp_map(struct kunit *test, struct status_to_posix_error *expect)
33 {
34 struct status_to_posix_error *result;
35
36 result = smb2_get_err_map(expect->smb2_status);
> 37 KUNIT_EXPECT_PTR_NE(test, NULL, result);
38 KUNIT_EXPECT_EQ(test, expect->smb2_status, result->smb2_status);
> 39 KUNIT_EXPECT_EQ(test, expect->posix_error, result->posix_error);
> 40 KUNIT_EXPECT_STREQ(test, expect->status_string, result->status_string);
41 }
42
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 00/10] smb: improve search speed of SMB2 maperror
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
` (9 preceding siblings ...)
2025-12-06 15:18 ` [PATCH v4 10/10] smb/server: rename include guard in smb_common.h chenxiaosong.chenxiaosong
@ 2025-12-10 4:29 ` ChenXiaoSong
10 siblings, 0 replies; 15+ messages in thread
From: ChenXiaoSong @ 2025-12-10 4:29 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01
Hi Steve and Namjae,
I have tested all patches using KUnit tests, xfstests, and smbtorture,
and no additional test failures were observed. The detailed test results
can be found in: https://chenxiaosong.com/en/smb-test-20251210.html
For more detailed information about the patches to be reviewed, please
see the link: https://chenxiaosong.com/en/smb-patch.html
Thanks,
ChenXiaoSong.
On 12/6/25 23:18, chenxiaosong.chenxiaosong@linux.dev wrote:
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> Before applying this patchset, when searching for the last element of
> smb2_error_map_table array and calling smb2_print_status(),
> 3486 comparisons are needed.
>
> After applying this patchset, only 10 comparisons are required.
>
> v1: https://lore.kernel.org/linux-cifs/20251204045818.2590727-1-chenxiaosong.chenxiaosong@linux.dev/
> The three patches from v1 have already been applied to the for-next branch of cifs-2.6.git.
> Please replace the following patches:
>
> - [v1 01/10] smb/client: reduce loop count in map_smb2_to_linux_error() by half: https://git.samba.org/sfrench/?p=sfrench/cifs-2.6.git;a=commitdiff;h=26866d690bd180e1860548c43e70fdefe50638ff
> - Replace it with this version(v4) patch #0001: update commit message: array has 1743 elements
>
> - [v1 02/10] smb/client: remove unused elements from smb2_error_map_table array: https://git.samba.org/sfrench/?p=sfrench/cifs-2.6.git;a=commitdiff;h=905d8999d67dcbe4ce12ef87996e4440e068196d
> - It is the same as patch #0002 in this version(v4).
>
> - [v1 03/10] smb: add two elements to smb2_error_map_table array: https://git.samba.org/sfrench/?p=sfrench/cifs-2.6.git;a=commitdiff;h=ba521f56912f6ff5121e54c17c855298f947c9ea
> - Replace it with this version(v4) patch #0003 #0004.
>
> v3: https://lore.kernel.org/linux-cifs/20251205132536.2703110-1-chenxiaosong.chenxiaosong@linux.dev/
> v3->v4:
> - Patch #0008: the KUnit test searches all elements of the smb2_error_map_table array
> - Create patch #0009
>
> ChenXiaoSong (10):
> smb/client: reduce loop count in map_smb2_to_linux_error() by half
> smb/client: remove unused elements from smb2_error_map_table array
> smb: rename to STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP
> smb/client: add two elements to smb2_error_map_table array
> smb/client: sort smb2_error_map_table array
> smb/client: use bsearch() to find target status code
> smb/client: introduce smb2_get_err_map()
> smb/client: introduce smb2maperror KUnit tests
> smb/client: update some SMB2 status strings
> smb/server: rename include guard in smb_common.h
>
> fs/smb/Kconfig | 17 +++++
> fs/smb/client/cifsfs.c | 2 +
> fs/smb/client/smb2glob.h | 6 ++
> fs/smb/client/smb2maperror.c | 101 +++++++++++++++++-------------
> fs/smb/client/smb2maperror_test.c | 71 +++++++++++++++++++++
> fs/smb/client/smb2proto.h | 4 +-
> fs/smb/common/smb2status.h | 5 +-
> fs/smb/server/smb2pdu.c | 2 +-
> fs/smb/server/smb_common.h | 6 +-
> 9 files changed, 165 insertions(+), 49 deletions(-)
> create mode 100644 fs/smb/client/smb2maperror_test.c
>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-12-10 4:29 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-06 15:18 [PATCH v4 00/10] smb: improve search speed of SMB2 maperror chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 01/10] smb/client: reduce loop count in map_smb2_to_linux_error() by half chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 02/10] smb/client: remove unused elements from smb2_error_map_table array chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 03/10] smb: rename to STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 04/10] smb/client: add two elements to smb2_error_map_table array chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 05/10] smb/client: sort " chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 06/10] smb/client: use bsearch() to find target status code chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 07/10] smb/client: introduce smb2_get_err_map() chenxiaosong.chenxiaosong
2025-12-06 15:18 ` [PATCH v4 08/10] smb/client: introduce smb2maperror KUnit tests chenxiaosong.chenxiaosong
2025-12-08 21:29 ` kernel test robot
2025-12-09 3:45 ` kernel test robot
2025-12-06 15:18 ` [PATCH v4 09/10] smb/client: update some SMB2 status strings chenxiaosong.chenxiaosong
2025-12-07 17:47 ` Steve French
2025-12-06 15:18 ` [PATCH v4 10/10] smb/server: rename include guard in smb_common.h chenxiaosong.chenxiaosong
2025-12-10 4:29 ` [PATCH v4 00/10] smb: improve search speed of SMB2 maperror ChenXiaoSong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).