{"id":2219173,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2219173/?format=json","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.0/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260402141839.461257-14-huiwen.he@linux.dev>","date":"2026-04-02T14:18:39","name":"[v3,13/13] smb/client: introduce KUnit tests to check DOS/SRV err mapping search","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ffc0db66fdde45a074eeb989583e695d84c238e7","submitter":{"id":93029,"url":"http://patchwork.ozlabs.org/api/1.0/people/93029/?format=json","name":null,"email":"huiwen.he@linux.dev"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260402141839.461257-14-huiwen.he@linux.dev/mbox/","series":[{"id":498490,"url":"http://patchwork.ozlabs.org/api/1.0/series/498490/?format=json","date":"2026-04-02T14:18:28","name":"smb: improve search speed of SMB1 maperror","version":3,"mbox":"http://patchwork.ozlabs.org/series/498490/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219173/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-10646-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256\n header.s=key1 header.b=sRsAgCET;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10646-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev\n header.b=\"sRsAgCET\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=91.218.175.186","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.dev","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.dev"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmkZW0rz4z1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 01:22:11 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 024DD30537C6\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  2 Apr 2026 14:20:24 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id E731E207DF7;\n\tThu,  2 Apr 2026 14:20:22 +0000 (UTC)","from out-186.mta0.migadu.com (out-186.mta0.migadu.com\n [91.218.175.186])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 410A923EA85\n\tfor <linux-cifs@vger.kernel.org>; Thu,  2 Apr 2026 14:20:21 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775139622; cv=none;\n b=TGqRGG0ubExgwVgduPsMAH86c/04CxTCRPKotffNRl/QHYEbhTYs+6rQGowlcLZ5lbV3iRpoLdZpclFM5AFmi6L5PU0cPiWm0tg5xnBTCaxwYLN08OhP5y0Pr/8KNuCW7HIIMz7ZkK2v6LHds5AZ/Y0Up6C9ljZCVVeNi8QV0uM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775139622; c=relaxed/simple;\n\tbh=QSSJTMc2GDyONWHj/8mxA1ksfbquFhlZfD2GH6xQe4E=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=dvcT5hr5N7uuZ8pCqMp6BT04ZXcPnCeLRWamS0fUt9FkTSBI5oMRmKHglGKEu51LcdcaJFTzUQwZHK8hjgWkYm1XPTJEkxXCDD9uSUg73xBxrDP5r4hhQFtpVZe9sDdVfZ1wlzTWqK6RVKZuVbmxCkepIkoelP3neohoikyA/Ss=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.dev;\n spf=pass smtp.mailfrom=linux.dev;\n dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev\n header.b=sRsAgCET; arc=none smtp.client-ip=91.218.175.186","X-Report-Abuse":"Please report any abuse attempt to abuse@migadu.com and\n include these headers.","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1;\n\tt=1775139619;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=4hkOz/9ZrCAW2nUvtbPrZi1e/vtm1eSKJN9kgwDc7B8=;\n\tb=sRsAgCETSO+KKunS9Np0axAbuuf9fIJyL1R/VQF2Bq4moXkvjGAiBbH4cGylk01fHZfRgO\n\t6Re+w43nWxjYMqkCGZD9lE3nKOipJ/yTP6ZnuzfjzIIupcbY2dwYXREdD/T9Ep/DnC6EJz\n\tTVnWt7KzYnkBzTdftFiI2kOVAqeNJPg=","From":"huiwen.he@linux.dev","To":"smfrench@gmail.com,\n\tlinkinjeon@kernel.org,\n\tdhowells@redhat.com,\n\tchenxiaosong@kylinos.cn,\n\tchenxiaosong@chenxiaosong.com,\n\ttangyouling@kylinos.cn","Cc":"linux-cifs@vger.kernel.org","Subject":"[PATCH v3 13/13] smb/client: introduce KUnit tests to check DOS/SRV\n err mapping search","Date":"Thu,  2 Apr 2026 14:18:39 +0000","Message-ID":"<20260402141839.461257-14-huiwen.he@linux.dev>","In-Reply-To":"<20260402141839.461257-1-huiwen.he@linux.dev>","References":"<20260402141839.461257-1-huiwen.he@linux.dev>","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Migadu-Flow":"FLOW_OUT"},"content":"From: Youling Tang <tangyouling@kylinos.cn>\n\nCheck whether all elements can be correctly found in the arrays.\n\nSigned-off-by: Youling Tang <tangyouling@kylinos.cn>\nReviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>\n---\n fs/smb/client/smb1maperror.c      | 33 ++++++++++++++++++++++++++-----\n fs/smb/client/smb1maperror_test.c | 22 +++++++++++++++++++++\n fs/smb/client/smb1proto.h         |  4 ++++\n fs/smb/client/smberr.h            |  5 +++++\n 4 files changed, 59 insertions(+), 5 deletions(-)","diff":"diff --git a/fs/smb/client/smb1maperror.c b/fs/smb/client/smb1maperror.c\nindex bca9b60ac836..74530088d17d 100644\n--- a/fs/smb/client/smb1maperror.c\n+++ b/fs/smb/client/smb1maperror.c\n@@ -16,11 +16,6 @@\n #include \"nterr.h\"\n #include \"cifs_debug.h\"\n \n-struct smb_to_posix_error {\n-\t__u16 smb_err;\n-\tint posix_code;\n-};\n-\n static __always_inline int smb1_posix_error_cmp(const void *_key, const void *_pivot)\n {\n \t__u16 key = *(__u16 *)_key;\n@@ -260,4 +255,32 @@ EXPORT_SYMBOL_FOR_SMB_TEST(ntstatus_to_dos_map_test);\n \n unsigned int ntstatus_to_dos_num = ARRAY_SIZE(ntstatus_to_dos_map);\n EXPORT_SYMBOL_FOR_SMB_TEST(ntstatus_to_dos_num);\n+\n+const struct smb_to_posix_error *\n+search_mapping_table_ERRDOS_test(__u16 smb_err)\n+{\n+\treturn search_mapping_table_ERRDOS(smb_err);\n+}\n+EXPORT_SYMBOL_FOR_SMB_TEST(search_mapping_table_ERRDOS_test);\n+\n+const struct smb_to_posix_error *\n+mapping_table_ERRDOS_test = mapping_table_ERRDOS;\n+EXPORT_SYMBOL_FOR_SMB_TEST(mapping_table_ERRDOS_test);\n+\n+unsigned int mapping_table_ERRDOS_num = ARRAY_SIZE(mapping_table_ERRDOS);\n+EXPORT_SYMBOL_FOR_SMB_TEST(mapping_table_ERRDOS_num);\n+\n+const struct smb_to_posix_error *\n+search_mapping_table_ERRSRV_test(__u16 smb_err)\n+{\n+\treturn search_mapping_table_ERRSRV(smb_err);\n+}\n+EXPORT_SYMBOL_FOR_SMB_TEST(search_mapping_table_ERRSRV_test);\n+\n+const struct smb_to_posix_error *\n+mapping_table_ERRSRV_test = mapping_table_ERRSRV;\n+EXPORT_SYMBOL_FOR_SMB_TEST(mapping_table_ERRSRV_test);\n+\n+unsigned int mapping_table_ERRSRV_num = ARRAY_SIZE(mapping_table_ERRSRV);\n+EXPORT_SYMBOL_FOR_SMB_TEST(mapping_table_ERRSRV_num);\n #endif\ndiff --git a/fs/smb/client/smb1maperror_test.c b/fs/smb/client/smb1maperror_test.c\nindex b38857dc388c..935142dfdcb0 100644\n--- a/fs/smb/client/smb1maperror_test.c\n+++ b/fs/smb/client/smb1maperror_test.c\n@@ -12,9 +12,14 @@\n #include <kunit/test.h>\n #include \"smb1proto.h\"\n #include \"nterr.h\"\n+#include \"smberr.h\"\n \n extern const struct ntstatus_to_dos_err *ntstatus_to_dos_map_test;\n extern unsigned int ntstatus_to_dos_num;\n+extern const struct smb_to_posix_error *mapping_table_ERRDOS_test;\n+extern unsigned int mapping_table_ERRDOS_num;\n+extern const struct smb_to_posix_error *mapping_table_ERRSRV_test;\n+extern unsigned int mapping_table_ERRSRV_num;\n \n #define DEFINE_CHECK_SEARCH_FUNC(__struct_name, __field,\t\t\\\n \t\t\t\t __array, __num)\t\t\t\\\n@@ -42,12 +47,29 @@ test_cmp_ntstatus_to_dos_err(struct kunit *test,\n \tKUNIT_EXPECT_STREQ(test, expect->nt_errstr, result->nt_errstr);\n }\n \n+static void\n+test_cmp_smb_to_posix_error(struct kunit *test,\n+\t\t\t    const struct smb_to_posix_error *expect,\n+\t\t\t    const struct smb_to_posix_error *result)\n+{\n+\tKUNIT_EXPECT_EQ(test, expect->smb_err, result->smb_err);\n+\tKUNIT_EXPECT_EQ(test, expect->posix_code, result->posix_code);\n+}\n+\n /* check_search_ntstatus_to_dos_map */\n DEFINE_CHECK_SEARCH_FUNC(ntstatus_to_dos_err, ntstatus, ntstatus_to_dos_map,\n \t\t\t ntstatus_to_dos_num);\n+/* check_search_mapping_table_ERRDOS */\n+DEFINE_CHECK_SEARCH_FUNC(smb_to_posix_error, smb_err, mapping_table_ERRDOS,\n+\t\t\t mapping_table_ERRDOS_num);\n+/* check_search_mapping_table_ERRSRV */\n+DEFINE_CHECK_SEARCH_FUNC(smb_to_posix_error, smb_err, mapping_table_ERRSRV,\n+\t\t\t mapping_table_ERRSRV_num);\n \n static struct kunit_case maperror_test_cases[] = {\n \tKUNIT_CASE(check_search_ntstatus_to_dos_map),\n+\tKUNIT_CASE(check_search_mapping_table_ERRDOS),\n+\tKUNIT_CASE(check_search_mapping_table_ERRSRV),\n \t{}\n };\n \ndiff --git a/fs/smb/client/smb1proto.h b/fs/smb/client/smb1proto.h\nindex 43b773e7964b..7d5da03111c1 100644\n--- a/fs/smb/client/smb1proto.h\n+++ b/fs/smb/client/smb1proto.h\n@@ -240,6 +240,10 @@ int map_and_check_smb_error(struct TCP_Server_Info *server,\n #if IS_ENABLED(CONFIG_SMB1_KUNIT_TESTS)\n const struct ntstatus_to_dos_err *\n search_ntstatus_to_dos_map_test(__u32 ntstatus);\n+const struct smb_to_posix_error *\n+search_mapping_table_ERRDOS_test(__u16 smb_err);\n+const struct smb_to_posix_error *\n+search_mapping_table_ERRSRV_test(__u16 smb_err);\n #endif\n \n /*\ndiff --git a/fs/smb/client/smberr.h b/fs/smb/client/smberr.h\nindex 4ec2c5ffae25..5c3415bf18d7 100644\n--- a/fs/smb/client/smberr.h\n+++ b/fs/smb/client/smberr.h\n@@ -9,6 +9,11 @@\n  *\n  */\n \n+struct smb_to_posix_error {\n+\t__u16 smb_err;\n+\tint posix_code;\n+};\n+\n /* The request was successful. */\n #define SUCCESS\t0x00\n /* Error is from the core DOS operating system set */\n","prefixes":["v3","13/13"]}