From patchwork Sun Jan 15 10:32:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawei Li X-Patchwork-Id: 43826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp678503wrn; Sun, 15 Jan 2023 02:33:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXtT6t8l2OOU7LV/ZmxVbme7EY5uaolKkZsdD4bFnSS4s5NzqfAsSDqlvhYmnGWw91ka2gXo X-Received: by 2002:a17:906:68ca:b0:86e:d375:1f09 with SMTP id y10-20020a17090668ca00b0086ed3751f09mr2897078ejr.67.1673778810234; Sun, 15 Jan 2023 02:33:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673778810; cv=pass; d=google.com; s=arc-20160816; b=RxgbwgfgicuL/nBLPb78SAYn68XBQTuOwrgLTOlrNA/Fq2lYX01eJ2SlAEUZoDm6ki xveD460UkDkjaYzWP93sOjKGQkalFZC18EQz3uB98ji19OFCTZnRAwD/yrOoICgPpH0x tImQmOC6UoJnZFxlFpQ3ibBIM7e/v/5kCojTpxQJJP6hD24xGdQFUm0H+s5JNm2Ccuac sVJvqsJiXiVpoliFo9IpW/X0hZdIVMiK8TVPgaajSlLOq6dDvRwNgO2s2TCz/F1BcA7v qLm5tzh6g+DrBeETndUnKSQE4wzSuJoSQ5dJPN9NnaC364kKyVxkecvBFvf1CM8NwK8m 2yjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1bCwXQROHXsw8VYvL5v6AwzG2CGy/x/ZiC0wL0JZbLU=; b=AKht9wTAer2Q927slqA+JXSFgmYwIRj/iKCbzjLsvJpVZ/t8cGXnDDJFt7kVkFd52r gbM2DuC6JoJPye6DIYY/i6yfrSAaFRD9PPrWz2Oc6Ly0wBQwITpe3Qkpyn8dVb1PzfIs Xz0aTrTSU9Auv7bquMNbD79BWw7gPdQRYehzh7yqPaM32QmgSsYvIS/0dEOklT932xV7 VM0LxmI0CigyE4stZgvr3vcJuuHngQkvfFpLDAqfo/IHeabWeD9JuHrRTaONMh+LJ61H xGJhptCJVVHv6PugrU7LQ1lAnEEMaf1lj3o7TjtKlrO4iEin0IcG47SG7VRek+eW/ACR by9Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=HtOv+DBJ; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wy10-20020a170906fe0a00b0084d37a7d9casi2969866ejb.187.2023.01.15.02.33.06; Sun, 15 Jan 2023 02:33:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=HtOv+DBJ; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbjAOKc0 (ORCPT + 99 others); Sun, 15 Jan 2023 05:32:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjAOKcW (ORCPT ); Sun, 15 Jan 2023 05:32:22 -0500 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2097.outbound.protection.outlook.com [40.92.98.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0B2CDC2; Sun, 15 Jan 2023 02:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jNymLNCiGEc8vHZHt+pLzXCPIQkAj2tjvupXd5vVv2N5fhoID6wtqMLilB1bm8GmZwkjz3oBnG20N+cRYeVPpzLu2P/Ar/c8qnhh2+/O/ExjgFAbNKqczdzpFD52En32wJHdKM31Ri5uNHUjvIwKZXK1TzPCVqkMpZw7iGDQ/uQEkxOgLEnhtFjQn6L2n/NNaCg37sV4KJM3GVu9QXcdxk0gzUv/AOeCdIYfWXzXVcmW79pW5YW6eBdpP8D6NITt4bV+TXpiyAL70laGPLEClsWMDJMiHvbyEoxsVIhIZN3jHTM9jBQbwfc42XwX27Dy88/jgrzr5sJQC2KWUhQpTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1bCwXQROHXsw8VYvL5v6AwzG2CGy/x/ZiC0wL0JZbLU=; b=bIUEILg4heRl67xANwrWIicmUJ927vm4afg5QfFMLC3pA2Y0uYlTtsR8h+89UpMQ26rxiWKukpSAImqzLHnS/tTqZjxuvtdL7mf/SuJLvmGfva3+HCBnewTfrCPcO7buPXu7hWC7bXBuxW+hckw3nzvQbUXoak779MwRMEIPl+YBebkzseZT1DTQOtDGxKbhN6aqHcqQuGegujtDBn6BeAD/gbzkDgqP0vXzqB3b9ma566tJ8ThuboftCltUGK9GjfzvszIDvvYJcsU+YTKZ8egNImY3vZ2U+fvKY6yOSLMPPiIbmr/uCzB4ahGzipNIWA69H2nzGhUHGUEa1eRA4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1bCwXQROHXsw8VYvL5v6AwzG2CGy/x/ZiC0wL0JZbLU=; b=HtOv+DBJNy4CIGhSM+5lsPTpGdUjCDBCjwqgTln8SWDes+BGLe3YhJZ9glpOCY+EnpB7gMDGeJ4AMq8UWi5Z6Gy1+t4U3Y3NkSjurZuFIKuwpU/XSiT9pnxoM2c8BDIFwsQzi/wANKc0TUHrwtCopD6BT7RW0AyecJNnCXoqtNH1Jomt2zkEpdx67ETvnGuN0OnkRiCDzqHooWKKVskMB0EMUll28Cy3g85xJ9dOyh1SeDHM82bqzrq3oKAZMUUBvnp3NwZ+ums5OSTIDUgWu/SNcvPJto5ENfU342EbIlng0liOKmyTBw51D7mQqK8EhfGzGv69hKQXNMg/0UdAuQ== Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) by OS3P286MB2025.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Sun, 15 Jan 2023 10:32:18 +0000 Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605]) by TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605%4]) with mapi id 15.20.6002.012; Sun, 15 Jan 2023 10:32:18 +0000 From: Dawei Li To: linkinjeon@kernel.org, sfrench@samba.org Cc: senozhatsky@chromium.org, tom@talpey.com, hyc.lee@gmail.com, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] ksmbd: Implements sess->ksmbd_chann_list as xarray Date: Sun, 15 Jan 2023 18:32:04 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230115103209.146002-1-set_pte_at@outlook.com> References: <20230115103209.146002-1-set_pte_at@outlook.com> X-TMN: [d7LqBg5C+xsn7ZcKt51vzaRYyK0so46QxmVWZm5BlJ0=] X-ClientProxiedBy: TYAPR01CA0210.jpnprd01.prod.outlook.com (2603:1096:404:29::30) To TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) X-Microsoft-Original-Message-ID: <20230115103209.146002-2-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2323:EE_|OS3P286MB2025:EE_ X-MS-Office365-Filtering-Correlation-Id: 08094b11-7137-4ed4-7dab-08daf6e3c712 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3yWdVFZ8laLo6bCijX4InFwEZli2FLOkju5xJUVfzi0rx1SRZHNnF96yM0n+tKM6qLh+iJZaB/WGMmNDZ7azSnm2+zvIKoZ4w134448rH7TKw5oz+BqkhNTc7aUkKSlLBYVov286UjkypviARlTYrvGvZurflOt5abshtpYNyvQRu1AJ2YjkWmRaUcOBoDsmUrJC7nZ7fMiiflX7VjkLdHIIGImx/s7twZ2rv4oMsv2yVOwBGUftGL7LGEl7mf+2dT/JZRcNB6MhdgnUYwkrudB19IB3s0vksNob9DvHGaHq+4M00Dq/gJQneO8hejWA2gl3HniINkN3P+LKEehV4HvgiHHHYUOcnvoSmBhGtxxvJniWjrxKDV+ZMZxggkXc254iyxzfOQ85wB9IWNHIJB65TKWUtgkxHyyrmNAj+897d0omVUzMKjNW1mEflG+rkQ6Ir8GJ6OgVgcpB9VDUUTlLu3dbWvIe2luLKrIKpcUaufJM2r4iuBJxwl4bYjXmtW09CnpqNHCGaZJkOLSEOQiVj/Tiu88QTPd9h4YwUZJIJlN7xO+zoMzJc+diaQcI+8p/QJBnPkKWrDk5wSNdU7OzR8Rd0UQKYEkUUJs7pz0= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qVRSJOnFHo+Ar4/bIZFRinpn/6itWDsFyWDkzoRHyeQWTuf4CBeFhBSb/ygoEJFuTBvVj0AbRU+cpRKaRJyizJh1d1zYgqmr4tbR0qZoRZkGfoyZGTevmgCeSm7ovX4Zwf0wWr5Dg0HI9BuGuKVhFkX8bc24ijTg9FdFkuEn3kHfv4PYnkpt2ACJKIrVJ3wALPfFwRjqm6gGNAAufp3PAkIdlSB/hytidEsJpzXDdTfVc6E/2rrx7nwwm/8T+jzJjrBSpvA+GSDW1ln3wsm4g8S0sojtyc2KCko8I6wDCFwQEAsejo1+6CAHCg6tkBuhlugtnUNIXGgQCNEiwdADraSaXTmaX4w1OfrLCIusmrhVKLMrVzQOKb2brs82JoUH6EJ9HAJc9+qcDuRI2px23GM2D4f1HIt9PUFKrwX3jaHXRm8BodR0kzi1FPJ4qJjlnASUWMfgHAQuX+EQlo9Q6LVf+kahNU3VW7Pq3ait2A6+dZRPcXjxZ1GhooJwVMziJf3fS5MaTXDt1hIIHIMPx4xwqoQLeTRYF6vVgri9qbbKf0E3AwI3sJ+gupPl7e9Vx2VQmDBLb+LGW9xlcKadt1dkeLQM5i+oH6lsnIxZ6nm6fsQ2RvZAwtq/wzDfGEpnA8chL9d3CzvB35MDvnCpSBL28kUMyvzFhdXjocxQQxMfLTQcWRduiQ5x66SIt1pErJgOqzxlA3gB+hqHozyu85zfIbkJ6EyCeG44NvryTWLUZXV0DmkBpKW1QODL0nT866FoNA8RbB7ZW+nIJiq9cvqSWj1xYQn6XbAGQssXYK+QqxVGhaB/sY3/+aGTxQbm/lilfbUdD8/+jWScrj8zbt/clh7mHgojhEd7tvfvCPuTFTRWVcGpds0qJUWKOZpl/+YarzlxrralN+SJVRw5jJeA6Fb4h/vznT40B3k9SQVafMpi/uK99eD2AKu8qQ0VtlRPFFFNWgY7VT+ugV2NN4ZUzazRVD7iJyYE2N1ulJQ5BsEd1jjqZ/1VLYjjgIMKzy3e+iHamJ+WaX9j8kFu3J4EOJ2UzEny+nigWBIsaWISI6vHE/TV6n4/broSYX/0IQpGesbVKD6pqWOUm4feIyYHHHH+KgwppGc/12wbNLCzICMQZdu8wi55midd5rJe0sZhvXjUFAJRCk6TVL7JmwvZfu7DBxUB1LEVae+BoPcEpg5YvJ33p2KVFqqKFmtZDeL6lEn7dUPs/WYz5dBd94Sb0xl7PWUV3MK7d2Ti/OhNKfo3gykEODHMVDCYeafeLHUiQ4frOIpR9OjidkV+Rrtkr1CehEjnH+ucumq0KTY= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08094b11-7137-4ed4-7dab-08daf6e3c712 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 10:32:18.7514 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2025 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755084289455066556?= X-GMAIL-MSGID: =?utf-8?q?1755084289455066556?= For some ops on channel: 1. lookup_chann_list(), possibly on high frequency. 2. ksmbd_chann_del(). Connection is used as indexing key to lookup channel, in that case, linear search based on list may suffer a bit for performance. Implements sess->ksmbd_chann_list as xarray. Signed-off-by: Dawei Li --- fs/ksmbd/mgmt/user_session.c | 61 ++++++++++++++---------------------- fs/ksmbd/mgmt/user_session.h | 4 +-- fs/ksmbd/smb2pdu.c | 34 +++----------------- 3 files changed, 30 insertions(+), 69 deletions(-) diff --git a/fs/ksmbd/mgmt/user_session.c b/fs/ksmbd/mgmt/user_session.c index 92b1603b5abe..a2b128dedcfc 100644 --- a/fs/ksmbd/mgmt/user_session.c +++ b/fs/ksmbd/mgmt/user_session.c @@ -30,15 +30,15 @@ struct ksmbd_session_rpc { static void free_channel_list(struct ksmbd_session *sess) { - struct channel *chann, *tmp; + struct channel *chann; + unsigned long index; - write_lock(&sess->chann_lock); - list_for_each_entry_safe(chann, tmp, &sess->ksmbd_chann_list, - chann_list) { - list_del(&chann->chann_list); + xa_for_each(&sess->ksmbd_chann_list, index, chann) { + xa_erase(&sess->ksmbd_chann_list, index); kfree(chann); } - write_unlock(&sess->chann_lock); + + xa_destroy(&sess->ksmbd_chann_list); } static void __session_rpc_close(struct ksmbd_session *sess, @@ -190,21 +190,15 @@ int ksmbd_session_register(struct ksmbd_conn *conn, static int ksmbd_chann_del(struct ksmbd_conn *conn, struct ksmbd_session *sess) { - struct channel *chann, *tmp; - - write_lock(&sess->chann_lock); - list_for_each_entry_safe(chann, tmp, &sess->ksmbd_chann_list, - chann_list) { - if (chann->conn == conn) { - list_del(&chann->chann_list); - kfree(chann); - write_unlock(&sess->chann_lock); - return 0; - } - } - write_unlock(&sess->chann_lock); + struct channel *chann; + + chann = xa_erase(&sess->ksmbd_chann_list, (long)conn); + if (!chann) + return -ENOENT; - return -ENOENT; + kfree(chann); + + return 0; } void ksmbd_sessions_deregister(struct ksmbd_conn *conn) @@ -234,7 +228,7 @@ void ksmbd_sessions_deregister(struct ksmbd_conn *conn) return; sess_destroy: - if (list_empty(&sess->ksmbd_chann_list)) { + if (xa_empty(&sess->ksmbd_chann_list)) { xa_erase(&conn->sessions, sess->id); ksmbd_session_destroy(sess); } @@ -320,6 +314,9 @@ static struct ksmbd_session *__session_create(int protocol) struct ksmbd_session *sess; int ret; + if (protocol != CIFDS_SESSION_FLAG_SMB2) + return NULL; + sess = kzalloc(sizeof(struct ksmbd_session), GFP_KERNEL); if (!sess) return NULL; @@ -329,30 +326,20 @@ static struct ksmbd_session *__session_create(int protocol) set_session_flag(sess, protocol); xa_init(&sess->tree_conns); - INIT_LIST_HEAD(&sess->ksmbd_chann_list); + xa_init(&sess->ksmbd_chann_list); INIT_LIST_HEAD(&sess->rpc_handle_list); sess->sequence_number = 1; - rwlock_init(&sess->chann_lock); - - switch (protocol) { - case CIFDS_SESSION_FLAG_SMB2: - ret = __init_smb2_session(sess); - break; - default: - ret = -EINVAL; - break; - } + ret = __init_smb2_session(sess); if (ret) goto error; ida_init(&sess->tree_conn_ida); - if (protocol == CIFDS_SESSION_FLAG_SMB2) { - down_write(&sessions_table_lock); - hash_add(sessions_table, &sess->hlist, sess->id); - up_write(&sessions_table_lock); - } + down_write(&sessions_table_lock); + hash_add(sessions_table, &sess->hlist, sess->id); + up_write(&sessions_table_lock); + return sess; error: diff --git a/fs/ksmbd/mgmt/user_session.h b/fs/ksmbd/mgmt/user_session.h index 8934b8ee275b..44a3c67b2bd9 100644 --- a/fs/ksmbd/mgmt/user_session.h +++ b/fs/ksmbd/mgmt/user_session.h @@ -21,7 +21,6 @@ struct ksmbd_file_table; struct channel { __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE]; struct ksmbd_conn *conn; - struct list_head chann_list; }; struct preauth_session { @@ -50,8 +49,7 @@ struct ksmbd_session { char sess_key[CIFS_KEY_SIZE]; struct hlist_node hlist; - rwlock_t chann_lock; - struct list_head ksmbd_chann_list; + struct xarray ksmbd_chann_list; struct xarray tree_conns; struct ida tree_conn_ida; struct list_head rpc_handle_list; diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index 38fbda52e06f..771e045c8d4a 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -74,14 +74,7 @@ static inline bool check_session_id(struct ksmbd_conn *conn, u64 id) struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_conn *conn) { - struct channel *chann; - - list_for_each_entry(chann, &sess->ksmbd_chann_list, chann_list) { - if (chann->conn == conn) - return chann; - } - - return NULL; + return xa_load(&sess->ksmbd_chann_list, (long)conn); } /** @@ -595,6 +588,7 @@ static void destroy_previous_session(struct ksmbd_conn *conn, struct ksmbd_session *prev_sess = ksmbd_session_lookup_slowpath(id); struct ksmbd_user *prev_user; struct channel *chann; + long index; if (!prev_sess) return; @@ -608,10 +602,8 @@ static void destroy_previous_session(struct ksmbd_conn *conn, return; prev_sess->state = SMB2_SESSION_EXPIRED; - write_lock(&prev_sess->chann_lock); - list_for_each_entry(chann, &prev_sess->ksmbd_chann_list, chann_list) + xa_for_each(&prev_sess->ksmbd_chann_list, index, chann) chann->conn->status = KSMBD_SESS_EXITING; - write_unlock(&prev_sess->chann_lock); } /** @@ -1519,19 +1511,14 @@ static int ntlm_authenticate(struct ksmbd_work *work) binding_session: if (conn->dialect >= SMB30_PROT_ID) { - read_lock(&sess->chann_lock); chann = lookup_chann_list(sess, conn); - read_unlock(&sess->chann_lock); if (!chann) { chann = kmalloc(sizeof(struct channel), GFP_KERNEL); if (!chann) return -ENOMEM; chann->conn = conn; - INIT_LIST_HEAD(&chann->chann_list); - write_lock(&sess->chann_lock); - list_add(&chann->chann_list, &sess->ksmbd_chann_list); - write_unlock(&sess->chann_lock); + xa_store(&sess->ksmbd_chann_list, (long)conn, chann, GFP_KERNEL); } } @@ -1606,19 +1593,14 @@ static int krb5_authenticate(struct ksmbd_work *work) } if (conn->dialect >= SMB30_PROT_ID) { - read_lock(&sess->chann_lock); chann = lookup_chann_list(sess, conn); - read_unlock(&sess->chann_lock); if (!chann) { chann = kmalloc(sizeof(struct channel), GFP_KERNEL); if (!chann) return -ENOMEM; chann->conn = conn; - INIT_LIST_HEAD(&chann->chann_list); - write_lock(&sess->chann_lock); - list_add(&chann->chann_list, &sess->ksmbd_chann_list); - write_unlock(&sess->chann_lock); + xa_store(&sess->ksmbd_chann_list, (long)conn, chann, GFP_KERNEL); } } @@ -8409,14 +8391,11 @@ int smb3_check_sign_req(struct ksmbd_work *work) if (le16_to_cpu(hdr->Command) == SMB2_SESSION_SETUP_HE) { signing_key = work->sess->smb3signingkey; } else { - read_lock(&work->sess->chann_lock); chann = lookup_chann_list(work->sess, conn); if (!chann) { - read_unlock(&work->sess->chann_lock); return 0; } signing_key = chann->smb3signingkey; - read_unlock(&work->sess->chann_lock); } if (!signing_key) { @@ -8476,14 +8455,11 @@ void smb3_set_sign_rsp(struct ksmbd_work *work) le16_to_cpu(hdr->Command) == SMB2_SESSION_SETUP_HE) { signing_key = work->sess->smb3signingkey; } else { - read_lock(&work->sess->chann_lock); chann = lookup_chann_list(work->sess, work->conn); if (!chann) { - read_unlock(&work->sess->chann_lock); return; } signing_key = chann->smb3signingkey; - read_unlock(&work->sess->chann_lock); } if (!signing_key) From patchwork Sun Jan 15 10:32:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawei Li X-Patchwork-Id: 43827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp678540wrn; Sun, 15 Jan 2023 02:33:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtjl+fYqbNvP5PMx0uIgSGSM3wv7YlvTyXt5i/KB8mh8p0UhIGNYwtqAoc5wW9AegwwhFoK X-Received: by 2002:a17:906:40ca:b0:861:b4c5:63ba with SMTP id a10-20020a17090640ca00b00861b4c563bamr14566726ejk.41.1673778815276; Sun, 15 Jan 2023 02:33:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673778815; cv=pass; d=google.com; s=arc-20160816; b=HN1a8aA+2WNXCkpKhhXtqXFwjWCOW7z0059dIoK8FoaaSLMZPBe6Devpb1wprx9QKD 9vHu2kg+7R5x39lCiQM+hE3dCLFOD+AiFE9kzl2wvJtY7gJyvyFXgyNbsCzZwPPVa9UX n5ef8PVe1vZB0XigUZ8S5hO0NVfHoy5xf940jPSJ9ucsGTgyVBoFDzLzVdPCyvQvIbJY sUG9MDUYHtmnObY/fdQl+WNHncuSGVlUM1jXVT55oTws4Aq1hzCAwUAtN4/M6DzjpTT2 Kx2p+m6dKhqQ3Q6TsKtaCy8stE5aJKBGUgf/a0V5UYhVA0Ij0kdaI7EzPFKlIoFf692B Tceg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7/z5IhOIPXlG5Tpw7qq8tOb5ZzZF8eAXGh4FcWVVGQ4=; b=DVbThsJwPIibX7lrrzFLyDLdTLdbT+Y2GAm2xqnMLSx+zFFDaMFOeIParJ4S5PfeYW fKIPl5g5fppa1zQoUb3mJxIfH4EFLVaETtlIA1JXngvc9gSFuEIJiQl5CC95oLQ8fv3T 48k2kbcbEEvKcfsv7a186liekSseJfP7d6zBzG72MHRBLMqoXhFlbGeHNRE82WxigaPx JbywT5Jx1iAj5AEpj0H7W0lSbho5zFMdlEVM5QrBpqLIU5fhB2AAsUMtWTDROrdFJKSe APfTUTZBJemjRW3FSVF5jol96gukgTbzb3gqM/r3kN9EA7kAyjZdA2W6VLnamNmVO45Y wBrw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Yebh6Bti; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cx26-20020a05640222ba00b0048c7e8f3dcasi24538812edb.483.2023.01.15.02.33.12; Sun, 15 Jan 2023 02:33:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Yebh6Bti; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbjAOKca (ORCPT + 99 others); Sun, 15 Jan 2023 05:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230433AbjAOKcX (ORCPT ); Sun, 15 Jan 2023 05:32:23 -0500 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2097.outbound.protection.outlook.com [40.92.98.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A496BC16B; Sun, 15 Jan 2023 02:32:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kUtS0bepUHxrIe1SpVHrepYAa7FqTmblJvfkgtKN5NOHF4ibbakk0hcnar+jY8hm+EmjQSeo5rarkK74wGMjFalE5cMpBGLs9OyAA+L31UQC6gcGObKPBv4jAOkjz+2HfLeJchE9k/bvHIcBmJum9ZONvWEpFLYMLvOOYtcjOwDL0dkdML800rVYn02zqyZxpcRDtfH6XltFZKd4xW2hS5LL5Fx+8vu0sFCKPvhl8pB8PgDG06k9QZcYMt75yGkuhXzshuZ3aa4u+y6+N7yvMTSEtpcgPN3uZBgLnIXsRnZdrn9J1V+2SfU7cPNT2KnZfKlZF32jZyRJV547a5r89Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7/z5IhOIPXlG5Tpw7qq8tOb5ZzZF8eAXGh4FcWVVGQ4=; b=Tx6RApHgBfFrXbgDlPqUVELVdRgF1fGNr5r6JWyImYRT/oT5LDZiSZMLJwyfDBda7FQK+gLuZG2DkziOXsBzQQ5enZw25OcSdyTMYPGzCmNyDw8AXd/eslyNp5Eaot3J5crVpnIO+wpWPjvs77sWSpPgB7XuTDJ9P5PBrzsgVKJHD4zoY7mLHQyo/1hT6r0g427qHZmcV0uqH0+72elKDpH58PZ7ALb9zLx2iUSdpPgQhrbjTJ4rd9ugUwAzAvRAvXiBbAGyhk2Pc8DBlpI/veFFTy+BU1SGY8rfKPYEZBsK8E8Rs7mDbBJseduATYQ6PwZTEg4YNva0APYN+OrbRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7/z5IhOIPXlG5Tpw7qq8tOb5ZzZF8eAXGh4FcWVVGQ4=; b=Yebh6Bti0XrLK8+ydDTxuR7gaqi3TnhyYHC2KS3/uPE2Kgxm0brmagf2lywJOoUz0RrTRgo1VxueeddAdJ//pV3LD7stQtsUdRtsqIIom8hgFoPNwYpzrLttrn0692+vhndM5unr/1OKzmieYby/ytT0UJBC+6ONDCDfg6wRq/hVO6w6LMdP2LzbieRyUVcWnFSN/UY6y+/N04KAqFe82UzaoYpb13WKsIwlskzQxVop05R8R/8c/PVNbnY/5R88fg0BaXvTFhtN0efUWbtpqXk4PpdUOoF1q7Puw5E+my80YwpjP4wmq6u0RNT3VA5YyeOhEj8KuOXTiSgamwqnLw== Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) by OS3P286MB2025.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Sun, 15 Jan 2023 10:32:20 +0000 Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605]) by TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605%4]) with mapi id 15.20.6002.012; Sun, 15 Jan 2023 10:32:20 +0000 From: Dawei Li To: linkinjeon@kernel.org, sfrench@samba.org Cc: senozhatsky@chromium.org, tom@talpey.com, hyc.lee@gmail.com, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] ksmbd: Implements sess->rpc_handle_list as xarray Date: Sun, 15 Jan 2023 18:32:05 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230115103209.146002-1-set_pte_at@outlook.com> References: <20230115103209.146002-1-set_pte_at@outlook.com> X-TMN: [EdmPNEYwTS/yCGMCV7L4MtMVsF/Kc7EzOaVbGLojHmk=] X-ClientProxiedBy: TYAPR01CA0210.jpnprd01.prod.outlook.com (2603:1096:404:29::30) To TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) X-Microsoft-Original-Message-ID: <20230115103209.146002-3-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2323:EE_|OS3P286MB2025:EE_ X-MS-Office365-Filtering-Correlation-Id: 4db69377-ec9a-4aad-d839-08daf6e3c7ec X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MD3OLuawmpKAwR2XgCiNISZTQoldvNp+SMKSMjLYDW5VnGJv9Ify+ZU+8zJ7EXxXV4VWkPDqHCMguDKOYOHHpAdf/twcqeFsVYZ79/vfvOU170kb9qQLp0jXFXORkEK8UytuHnnJ3OCNCAVRJTwpDWygdWEWNzsi+6ntRAzVkJOJGyi7LDPfjeSBFfhFjCzePpaiK60r2hzOmFGEMiSZ0U4RKFTTJRKj8xxsW9e4ETmXKbJo6xDE8ul7r+KzhsZH1pZTmnuSmmiUbhK1o1ldOfuFEpAKucJMQyfPZIGkYtWucrVxRJiCy/raGHRIyh2pH7C+5Xwqe8bGPTm46CGBSKyL46qsjnw0FnMwdsYBk53cUAXePWd5ChUh2VSWBZg0RmBFnwTF1suSzIx9wvY5dnpwt2swlFLwaPbJRzeoueYcB+MgLGI0H5SRRkzptXd5dEfyz6P3f/V7LR3+Qt/9qZe68x/DwvQqzfEX/AS32P8Y1kVexlbCqdZchLKYkoqczV4e+PVts4jMIwhsMu03rBVW0xF0KkLnb43i7m40iSSuElpYkZMkzI98BB3pv5LpOTA83QNnwrzTmvSD8rYkROERTDsdct/KIJc93KvuLww= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2BAy2MlV7RiR/TQSzCJNSBWisuD8G98ZNDpLcNEVpaO6ipcIc9KDlz/Diw8nCQq+AunXj7OhSMXdTjH6qMUwon860I5PqTS3bRCNa1PdnUXGCjMFRXQHI+5EMAKJGXhn5bn4+DJ6KsXzOrMqnBdRcJEQ2Jn58XcM05GTtB5KNs28cyrgZD+DRyeAtGHETLQik5pld/7yD1KvS+/3MI6ECbrzXy0TX2yt1mYK2sDA0uhkXJ4il4IzZDX+MFPY2zABJha+8x68chFKWwmQBEpTa3onvXUT9kyGOlkX45SJHAmB6X0GAbmz4WEX61dEskTVrGP/2XDmKKDVy4g09KQpNMefzBVKXqAXNl/UTux3O1KU905ulqtoqQjoUD9+VyegHB6AncqxH2YtEQUsHFLbfya9BkchfHP1qQvUisrw78prazzMkCTG6vYbUEAe6MkBrkZQqVQMHeVETS2/y6qzfOHb1EpzK3cUA+Gk8RD0u8oJ/QrurEkc0On0a0irBBD61zfqND5e9VrHkE/AHPG+Xsip8s8ruuPsOxqbaYRi4EshovOHpXGQRB7Wcch8PpwLKKPDfJnIsdTlgG1VSep0+2a6TwllSBlP9c1M6p5LA14sL0ailefVwUwVL/FzPqYVckqWx37DFRiLnA74MC1UkeXrgFPKKDOHiwrg5q96fsb3H6B04RWgHTcyNQyRJgE0cW3jMSCOYbJEUnjCQXztqqDQuiZQtECvYaUoPSh1rUMUq4uAFDIyzIKsoGCDPSpchP81ycn0o6md+NlJkUjXqmAPCSphFNoEdk8FyuGSqpcbaV2F6oak/C65NCmKNCmrXmYXWthL+yrQ3TKjUr8oIB7A25uXtIPNdh18YYoiBPzCCiFGI0MlOEWL0yLDmmaJpM8OO8DSFG466f3bdlFgM8Z052nBke73sOOl9G7atMgOVoKmngAg/sUwpJE1Q3tBfYdePphJQYi567ZwVgiaQ66C4vJgUHxre7WIWRwkBS2gInKwFZGW1XtfEG2r6p5oieQevXNpu/U1AD3OXxmmpKIAefO5XxhF4SIBNdulCDi9boCDDMyEQN850WS2cmXpG/fEOgRTq2CARwZ+QooqCZZaI7mR5c9NnRLfZzIYcSsX993ew9t/vkscGTcSdZcFnm+b0mPW5C6kz0WvMBskFCK78f0cPxucuo4x8HwlTNAPLpf5imLogvFh6n5kYbdyHiMlS9gFhJFNFn0tbOVJk/MjUe+3FPA6avd251HjzduHhuQ1DnbroR5gd1o9Rb+P2Ki+cumHMzBotzK1KKAITO0Mittb7uJt4epGQlrGlZg= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4db69377-ec9a-4aad-d839-08daf6e3c7ec X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 10:32:20.1511 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2025 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755084294983884686?= X-GMAIL-MSGID: =?utf-8?q?1755084294983884686?= For some ops on rpc handle: 1. ksmbd_session_rpc_method(), possibly on high frequency. 2. ksmbd_session_rpc_close(). id is used as indexing key to lookup channel, in that case, linear search based on list may suffer a bit for performance. Implements sess->rpc_handle_list as xarray. Signed-off-by: Dawei Li --- fs/ksmbd/mgmt/user_session.c | 37 ++++++++++++++---------------------- fs/ksmbd/mgmt/user_session.h | 2 +- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/fs/ksmbd/mgmt/user_session.c b/fs/ksmbd/mgmt/user_session.c index a2b128dedcfc..1ca2aae4c299 100644 --- a/fs/ksmbd/mgmt/user_session.c +++ b/fs/ksmbd/mgmt/user_session.c @@ -25,7 +25,6 @@ static DECLARE_RWSEM(sessions_table_lock); struct ksmbd_session_rpc { int id; unsigned int method; - struct list_head list; }; static void free_channel_list(struct ksmbd_session *sess) @@ -58,15 +57,14 @@ static void __session_rpc_close(struct ksmbd_session *sess, static void ksmbd_session_rpc_clear_list(struct ksmbd_session *sess) { struct ksmbd_session_rpc *entry; + long index; - while (!list_empty(&sess->rpc_handle_list)) { - entry = list_entry(sess->rpc_handle_list.next, - struct ksmbd_session_rpc, - list); - - list_del(&entry->list); + xa_for_each(&sess->rpc_handle_list, index, entry) { + xa_erase(&sess->rpc_handle_list, index); __session_rpc_close(sess, entry); } + + xa_destroy(&sess->rpc_handle_list); } static int __rpc_method(char *rpc_name) @@ -102,13 +100,13 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name) entry = kzalloc(sizeof(struct ksmbd_session_rpc), GFP_KERNEL); if (!entry) - return -EINVAL; + return -ENOMEM; - list_add(&entry->list, &sess->rpc_handle_list); entry->method = method; entry->id = ksmbd_ipc_id_alloc(); if (entry->id < 0) goto free_entry; + xa_store(&sess->rpc_handle_list, entry->id, entry, GFP_KERNEL); resp = ksmbd_rpc_open(sess, entry->id); if (!resp) @@ -117,9 +115,9 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name) kvfree(resp); return entry->id; free_id: + xa_erase(&sess->rpc_handle_list, entry->id); ksmbd_rpc_id_free(entry->id); free_entry: - list_del(&entry->list); kfree(entry); return -EINVAL; } @@ -128,24 +126,17 @@ void ksmbd_session_rpc_close(struct ksmbd_session *sess, int id) { struct ksmbd_session_rpc *entry; - list_for_each_entry(entry, &sess->rpc_handle_list, list) { - if (entry->id == id) { - list_del(&entry->list); - __session_rpc_close(sess, entry); - break; - } - } + entry = xa_erase(&sess->rpc_handle_list, id); + if (entry) + __session_rpc_close(sess, entry); } int ksmbd_session_rpc_method(struct ksmbd_session *sess, int id) { struct ksmbd_session_rpc *entry; - list_for_each_entry(entry, &sess->rpc_handle_list, list) { - if (entry->id == id) - return entry->method; - } - return 0; + entry = xa_load(&sess->rpc_handle_list, id); + return entry ? entry->method : 0; } void ksmbd_session_destroy(struct ksmbd_session *sess) @@ -327,7 +318,7 @@ static struct ksmbd_session *__session_create(int protocol) set_session_flag(sess, protocol); xa_init(&sess->tree_conns); xa_init(&sess->ksmbd_chann_list); - INIT_LIST_HEAD(&sess->rpc_handle_list); + xa_init(&sess->rpc_handle_list); sess->sequence_number = 1; ret = __init_smb2_session(sess); diff --git a/fs/ksmbd/mgmt/user_session.h b/fs/ksmbd/mgmt/user_session.h index 44a3c67b2bd9..b6a9e7a6aae4 100644 --- a/fs/ksmbd/mgmt/user_session.h +++ b/fs/ksmbd/mgmt/user_session.h @@ -52,7 +52,7 @@ struct ksmbd_session { struct xarray ksmbd_chann_list; struct xarray tree_conns; struct ida tree_conn_ida; - struct list_head rpc_handle_list; + struct xarray rpc_handle_list; __u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE]; __u8 smb3decryptionkey[SMB3_ENC_DEC_KEY_SIZE]; From patchwork Sun Jan 15 10:32:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawei Li X-Patchwork-Id: 43828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp678612wrn; Sun, 15 Jan 2023 02:33:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQ1fFlGYtt05Hy9t7CXaLKKpDyaM1PV/kzH+y/OP4ulT4wbUaE0yHeiJMJoeV/x/0TK+SB X-Received: by 2002:a17:907:b682:b0:86d:e1ce:5c9c with SMTP id vm2-20020a170907b68200b0086de1ce5c9cmr3951347ejc.76.1673778828200; Sun, 15 Jan 2023 02:33:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673778828; cv=pass; d=google.com; s=arc-20160816; b=OJTJVNHDnvHOBc4P6mdCke5vA2ID0orxby//05vN/zboPB/xuK6OdNKum2fn/Ue3j+ qVrU/vz/y5WatBvdvcw/gevhKCTi+AHFvCtCpySJ4fpOaW0wkZre+qdnLOMKjOCTUmfI dVhPv5UmutxxdAa2gAdiaFCkymT6cM1vasewX6BvQx7Wv2VjsYtl7kzTHHhvdSIGelxB E/u+t0bR7Pb+8MBUIqlVkQMVXcidZjAjepr446glt+/nQugOjnyHARgWNYLJ6P2m1qI2 ZFh2vxOp2nlQm0GI6e2KG7MPhg2x2kWrol3hyRdoQY/7qbPci1veZLDwZEjW5AJ9cbWB kf0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tLVW6cpIN92RszWQGZf+N4nrJfbYAPQMEODlCfdC350=; b=wOe9mefpBrgO5Z98kASnPyWtSzv4X8AEpgKKNOFp+4VEnfbaFrztorLz0Y74HInfB4 xG4CYUIUVg23ToqpM0NKhZ9Ry9oiVEbpqNCGVnksBn/GymhD+UgCLsJ6dubwrjRHible U0g+JwFgzViWwNPkyzoXG3vCGpGsQxHiOU6JQreO38tKOzFlA2gKyWuTLSGibOUZ6y+N 783KnzCyqHmGIBeen9GOlo9BbNqzB39tgtgjNRQBCuV/nBz/1OXDAUKOBWwLEsrsSUil ueZYWE/pR74QYOIHp9GwLmklqxdoVPLeO05ptroxG/uFGimqW1tuUJV510mQZu2NSKtJ 06WQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=XB6O5oay; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js22-20020a17090797d600b00860c51f7df4si13786721ejc.769.2023.01.15.02.33.25; Sun, 15 Jan 2023 02:33:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=XB6O5oay; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231197AbjAOKcf (ORCPT + 99 others); Sun, 15 Jan 2023 05:32:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230456AbjAOKcY (ORCPT ); Sun, 15 Jan 2023 05:32:24 -0500 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2097.outbound.protection.outlook.com [40.92.98.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98580CDC2; Sun, 15 Jan 2023 02:32:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZZ8HtHvdENvKMc5J2uIOfj4Kp6Y9foBxjCSsnlC+z5YkiZM474EfhC4ynpDqOfwt6LoxEtaMfgVN4foiwMLkR8ABS9xuZK2mIkEIpvhHIJl3N94/E66CHB6rp/ykaI4DFcbrYopML/eBt8bEAezOXg9fmviGBI4j5BHcjKYaC0EH8F/VH+cXtIMDHGuOGUtHbBxfqE1+iZfYMFrEdJm2nUTRyj1+YDd7yyDs3sJjEAeh64AzFtR1qglUpve4Fgp7k5A+ibRUjrAiktLnvxgV5LMF0eHXKwkkexksaJ2yUjUYtIOch3GCScFtJFW2HFS3G6gzqhv9vOUXblcaTFrZUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tLVW6cpIN92RszWQGZf+N4nrJfbYAPQMEODlCfdC350=; b=LjxVsH0SpBJqfAMMHL59vCXKJk3432EvrjPZXM6v80cIVJj5BnqySzsDsuDeN98CtyI+a0DgK82z1xZx741FMU2C0MfAmLly5cGWv7bF51LtCPb75yc9JLgkTpwiqnJWVfMhwhqXvWCW4LneXWY01GUwwj0+XteXSTmpyJZSLFs6PFEwsZ4IsNWU5GpjaudyZklUBzlg9tS7xewXbRz6Yta0TkDiOnHCVCuK7MLT9Ru8qR8vKLpqGHw/4iWsJ8pOgDJRBBRvqPvYPm/2qA+9OfQLsu9AhBxSQ/ReGzJOeYrRrPuTNKz4zxlRzQ8BVvfyP/AUWJCWCOIyZfbZNGtf7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tLVW6cpIN92RszWQGZf+N4nrJfbYAPQMEODlCfdC350=; b=XB6O5oayfLt/aCyhfvENUfXRRs5UXjrQhNIOoPIl2Ve771LGme7axgopdlHe+b7GcidylXFFuiHNgIuk+KyUaqLwx23U66ef4pJSttngh6J03L9kVgpf8DMWVF6vS3g123ugZn4cY9/hEa3LQLa1fgri7fIAUtc20KLwMX+pd0ZJGvvwUzckegoSHB7hRBghycr00mAMy5jsryus/WQXaiGOKT+mut+i5LWzS8k7NH4ZbiyltGhKk237CKW2JKEpSNS86sYwFMbqjcq7jvOmeGYBV1URn8kRPrFFbFWqK3GEOh1FOmdIzjOzrn92AxQuhnzcxLBRqqzcbdJG/nielQ== Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) by OS3P286MB2025.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Sun, 15 Jan 2023 10:32:21 +0000 Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605]) by TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605%4]) with mapi id 15.20.6002.012; Sun, 15 Jan 2023 10:32:21 +0000 From: Dawei Li To: linkinjeon@kernel.org, sfrench@samba.org Cc: senozhatsky@chromium.org, tom@talpey.com, hyc.lee@gmail.com, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] ksmbd: replace rwlock with rcu for concurrenct access on conn list Date: Sun, 15 Jan 2023 18:32:06 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230115103209.146002-1-set_pte_at@outlook.com> References: <20230115103209.146002-1-set_pte_at@outlook.com> X-TMN: [Ra10at4WNJIhZRyiO61Rfjy0xkteVbPIxa/XrE9qXao=] X-ClientProxiedBy: TYAPR01CA0210.jpnprd01.prod.outlook.com (2603:1096:404:29::30) To TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) X-Microsoft-Original-Message-ID: <20230115103209.146002-4-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2323:EE_|OS3P286MB2025:EE_ X-MS-Office365-Filtering-Correlation-Id: b32847a3-374f-40b3-3b1c-08daf6e3c8bc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mth2RSi214nePp7p+aChpl0eZQuO7BbteM2cExknauR0Ff27xfg8RHoRF3rc9Wza1H7Cerp1DK71TKlWOowM9vm4KX7kTDvlpzxJaFJd8wtk6ZBKk28M4397dNs2SVJPidGWnpD4QR9sjmO3SchxlX/OWFtejsNqjW0vo5uGVZrsARSbYr+sNCkHe1q2wQpO/VA4870587HNs03agII+ku/WVUv38XsoyrGclsOL+FkQ6C8Yv2GvHzZNHTRrlq53IIEIb4Y6aZj2l+NPIEfzoqY2jUDMgShGZRJCtEIJWNOVQKIK6Keji+FD4olZfyQocz56g6UhBO+e6o0Q3pQLvS7FDvStdFp979WK7h76oJMQ4cd45Yt60QTyN5GkBXWHGomtqUh39E/JNrF4Pcocq2JnGuznk85Vunu6s58Ce16+0soIomdd/42RX58ioLXX49NrcfPP2ogUEccTQZNPEcjstyUa61ehKErcV9zi2dO042NH9KM57PI1v0WcmsAKV+gA1a2Azl4zcUH8sMcd0SizhTw9irl1Lo5iQBDWHMZZqwxefOahLgfMaHiG4ehcWMRSS9eZYGs86OAg/8pSCdnN42j45/WojbX1UAJYLhk= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SIY1ldUY1Fpn35roPD/jBPhD9BjxbpTGS8nSLe2pEbNRCU3K3wq6C0k2/D0kVFs2kJadCoT5cU4tR2LovnwMa4PjFMiODYArfNcQr6xyJ7kFVZwm0RxYCqvFSCY5foqjL92ZcIilBOk9RcXggB7szJu8HZw0HN+QMi6x3aFUvelA4+tSaPZUty/axLFv7FVbxT5H95xh1jefsBHKAERsUPEnFLCOBjgL9tN8j+4GAIUDJ9tdM3geHJGgxs6WagPCkq06bM6kAv6cDGvXPWQGmM+4FbZDikCOqwdd4SBwPhoD6pnRyFBh+Ta0E3j3xt0H++63t18n+qE/gVD5LC7DquNjGDP11GuvhJmm+gm0bhvXnBFzM31RTgl3/DsR8GCNBjQ6HLO+CL/wwlUHnd6v22dZiN9sxTFpNbKJxq5Lep31GBUVlvmzapHc5FivW+3XKQGO6W4J4YirSi45uge3EOmh9wOjqpMA10tH8ABXenol0oEWtvgRH/iSkEqb0PFHle8CmK0FjYlyJlUrsGqTQ+i0USBlS1higiY/UUDdJPaQcZBp5bcSfu2Sn8SXadjuF0Rn1nmq8IOfKlC0k3+E3hjdIzaJgSBChqzPp3+W/ZIpXma8tjAjrieXT4tuwh3VCs45UB7+i455X6fFgVdqzTehzTxAh3zx48ryyrK0nwW+31THh5rceFKssqQ5Ukyndn5AeK6czLI6CmUkdtghu8iY1Ek3vKT/56FNyC91d9NSJXWIlClBOds54s3LAk1+RtBbdskj6TWKuBJBmEmarrYRme5y0ZBoN9/FJ0u2ke7yVeO8TQQaNo5DsjetsI5yYW5iUnr0dVKs7YA6tgnYwBmk4jt+yCT2El85dbgftkh5EFDjKgU68/3XObfZ+q6ju/lrHC/wd1AzwM6hx/OJog/Dzxre678B8ojphupyM8M+8n4N/sv7VPihydGRvMRjiKT8F7x5kQW591B0YiUViN+ZUlODJKZp3r+zql8XYcPQmwGk45A87RUyI7LpndTBav31jEbvsyRwZ8t/dMOOwCS8v1XIdhRZ5X5lm8LSaNmhuXmxrXwQsA4TyDuyGxpx3aVlkPPUm7ISKlC9+57LUQfccG/peMbEnsjy/LdKofFmWoYhfwRo44WipRd0wCl/v9CsBOg+fJAIOxUMC2JvLAKx0wsgkLNqndZ9aiz8fFz6epE2JqKRmC9SclVK0ZQag1qiapVDb857y9U+GXSR7nPi3ufJxGF4copogKoIsSSFAjEHLtOPcVAX1+ErcnKt1V2qsgnMXRB4BKU48gn7tkpTsVlk1zEmFZiFlbYTPT4= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b32847a3-374f-40b3-3b1c-08daf6e3c8bc X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 10:32:21.4490 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2025 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755084308337109200?= X-GMAIL-MSGID: =?utf-8?q?1755084308337109200?= Currently, racing protection on conn list is implemented as rwlock, improve it by rcu primitive for its better performance. Signed-off-by: Dawei Li --- fs/ksmbd/connection.c | 30 +++++++++++++++--------------- fs/ksmbd/connection.h | 1 - fs/ksmbd/smb2pdu.c | 14 +++++++------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/fs/ksmbd/connection.c b/fs/ksmbd/connection.c index fd0a288af299..36d1da273edd 100644 --- a/fs/ksmbd/connection.c +++ b/fs/ksmbd/connection.c @@ -20,7 +20,7 @@ static DEFINE_MUTEX(init_lock); static struct ksmbd_conn_ops default_conn_ops; LIST_HEAD(conn_list); -DEFINE_RWLOCK(conn_list_lock); +DEFINE_SPINLOCK(conn_list_lock); /** * ksmbd_conn_free() - free resources of the connection instance @@ -32,9 +32,9 @@ DEFINE_RWLOCK(conn_list_lock); */ void ksmbd_conn_free(struct ksmbd_conn *conn) { - write_lock(&conn_list_lock); - list_del(&conn->conns_list); - write_unlock(&conn_list_lock); + spin_lock(&conn_list_lock); + list_del_rcu(&conn->conns_list); + spin_unlock(&conn_list_lock); xa_destroy(&conn->sessions); kvfree(conn->request_buf); @@ -84,9 +84,9 @@ struct ksmbd_conn *ksmbd_conn_alloc(void) spin_lock_init(&conn->llist_lock); INIT_LIST_HEAD(&conn->lock_list); - write_lock(&conn_list_lock); - list_add(&conn->conns_list, &conn_list); - write_unlock(&conn_list_lock); + spin_lock(&conn_list_lock); + list_add_rcu(&conn->conns_list, &conn_list); + spin_unlock(&conn_list_lock); return conn; } @@ -95,15 +95,15 @@ bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c) struct ksmbd_conn *t; bool ret = false; - read_lock(&conn_list_lock); - list_for_each_entry(t, &conn_list, conns_list) { + rcu_read_lock(); + list_for_each_entry_rcu(t, &conn_list, conns_list) { if (memcmp(t->ClientGUID, c->ClientGUID, SMB2_CLIENT_GUID_SIZE)) continue; ret = true; break; } - read_unlock(&conn_list_lock); + rcu_read_unlock(); return ret; } @@ -402,8 +402,8 @@ static void stop_sessions(void) struct ksmbd_transport *t; again: - read_lock(&conn_list_lock); - list_for_each_entry(conn, &conn_list, conns_list) { + rcu_read_lock(); + list_for_each_entry_rcu(conn, &conn_list, conns_list) { struct task_struct *task; t = conn->transport; @@ -413,12 +413,12 @@ static void stop_sessions(void) task->comm, task_pid_nr(task)); conn->status = KSMBD_SESS_EXITING; if (t->ops->shutdown) { - read_unlock(&conn_list_lock); + rcu_read_unlock(); t->ops->shutdown(t); - read_lock(&conn_list_lock); + rcu_read_lock(); } } - read_unlock(&conn_list_lock); + rcu_read_unlock(); if (!list_empty(&conn_list)) { schedule_timeout_interruptible(HZ / 10); /* 100ms */ diff --git a/fs/ksmbd/connection.h b/fs/ksmbd/connection.h index 3643354a3fa7..e41f33a2da7c 100644 --- a/fs/ksmbd/connection.h +++ b/fs/ksmbd/connection.h @@ -139,7 +139,6 @@ struct ksmbd_transport { #define KSMBD_TCP_PEER_SOCKADDR(c) ((struct sockaddr *)&((c)->peer_addr)) extern struct list_head conn_list; -extern rwlock_t conn_list_lock; bool ksmbd_conn_alive(struct ksmbd_conn *conn); void ksmbd_conn_wait_idle(struct ksmbd_conn *conn); diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index 771e045c8d4a..c60cfb360f42 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -6915,8 +6915,8 @@ int smb2_lock(struct ksmbd_work *work) nolock = 1; /* check locks in connection list */ - read_lock(&conn_list_lock); - list_for_each_entry(conn, &conn_list, conns_list) { + rcu_read_lock(); + list_for_each_entry_rcu(conn, &conn_list, conns_list) { spin_lock(&conn->llist_lock); list_for_each_entry_safe(cmp_lock, tmp2, &conn->lock_list, clist) { if (file_inode(cmp_lock->fl->fl_file) != @@ -6932,7 +6932,7 @@ int smb2_lock(struct ksmbd_work *work) list_del(&cmp_lock->flist); list_del(&cmp_lock->clist); spin_unlock(&conn->llist_lock); - read_unlock(&conn_list_lock); + rcu_read_unlock(); locks_free_lock(cmp_lock->fl); kfree(cmp_lock); @@ -6954,7 +6954,7 @@ int smb2_lock(struct ksmbd_work *work) cmp_lock->start > smb_lock->start && cmp_lock->start < smb_lock->end) { spin_unlock(&conn->llist_lock); - read_unlock(&conn_list_lock); + rcu_read_unlock(); pr_err("previous lock conflict with zero byte lock range\n"); goto out; } @@ -6963,7 +6963,7 @@ int smb2_lock(struct ksmbd_work *work) smb_lock->start > cmp_lock->start && smb_lock->start < cmp_lock->end) { spin_unlock(&conn->llist_lock); - read_unlock(&conn_list_lock); + rcu_read_unlock(); pr_err("current lock conflict with zero byte lock range\n"); goto out; } @@ -6974,14 +6974,14 @@ int smb2_lock(struct ksmbd_work *work) cmp_lock->end >= smb_lock->end)) && !cmp_lock->zero_len && !smb_lock->zero_len) { spin_unlock(&conn->llist_lock); - read_unlock(&conn_list_lock); + rcu_read_unlock(); pr_err("Not allow lock operation on exclusive lock range\n"); goto out; } } spin_unlock(&conn->llist_lock); } - read_unlock(&conn_list_lock); + rcu_read_unlock(); out_check_cl: if (smb_lock->fl->fl_type == F_UNLCK && nolock) { pr_err("Try to unlock nolocked range\n"); From patchwork Sun Jan 15 10:32:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawei Li X-Patchwork-Id: 43830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp679202wrn; Sun, 15 Jan 2023 02:35:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXuqCSzY0LP5Cz/wZtY0NkWNrT4NoAn4B6xpJtenh2TgwrwwgAyJyCX0UGfeK/dF9+xDd+uh X-Received: by 2002:a05:6402:528d:b0:48e:f679:e733 with SMTP id en13-20020a056402528d00b0048ef679e733mr38603714edb.36.1673778943076; Sun, 15 Jan 2023 02:35:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673778943; cv=pass; d=google.com; s=arc-20160816; b=MwdbcM2bZPSAGYUthPdVyzV3UeZxZ/vnS5wPPrhDri/Cnf9gYbH1g3FObEjy+y1QZx PnJeu3jKHryf3jwAEzPA37PRSRY/KYEwrWG6R1H+UP9NfsK1k0fGkcoZxNfglaPkzJWC FlE5Gn6KO+GAcVVbGe1w8FYM9DCkEE8zyk0GiaTl5swyAOOjoY1MCrHqwJMXUfG6tcy+ QeDdQaGG67psq38qpWTZMBne2YjwlrzfG228p7PPbqqKcotR/lvF61TSX42eC0Jshnc6 /dgsoCMyLOttKJPCyozNZfb2tt72B3/Yj4kQfRonztFFTVcOg2Ongrn4xSdPxSv/KaS+ ItPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sTIGXCvlKOe9Ar9BRp9PW662OZnjc2ADZMiM18JhV9c=; b=oSxEFqMzGZJYsNZob0m6Hujrw1TRP3aisDLotZid/S84g9kKmAdwts8I53jLbLPQQE VgZG8kmnvtUUJ8kGW0x3+3kRUpN9b14wrum/l5rVjJcrhogyUv1NkE0u6du6y+Pq4isF WGcQtqK7Bh8VW6uk1jsARnDwaNJ0FkbnMHvehPwygYK8lZgTZa2OsJGyrqQ0nB+YHdZL O7h/iu1gEDKBakVu4i0OeCe6hpycmhGUBrxd3+Q+Pz1lWxiCJQV3vAQiq1QhrU66Xh/9 T6mvBjUpH+nin72AQgFaf5NgOoGvJ7fsmFUUwZuzNygHjRWYWMlh6jPsl1isd8o893+5 6iyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=iWtLCxWK; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz8-20020a0564021d4800b0049e150b7e04si797236edb.386.2023.01.15.02.35.17; Sun, 15 Jan 2023 02:35:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=iWtLCxWK; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbjAOKcr (ORCPT + 99 others); Sun, 15 Jan 2023 05:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbjAOKcZ (ORCPT ); Sun, 15 Jan 2023 05:32:25 -0500 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2097.outbound.protection.outlook.com [40.92.98.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C61CDE4; Sun, 15 Jan 2023 02:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CGPuEChIgIOsu1A0JppAh4q4MsNXJncr0U+UUNG0vhANtI6tzyOyN1EUmltiHFbMvmFh31MMfkTlz0RmijJlYhdrcv90AVP4f8xA59WuFjLQwJaLWlwo+0ljsSOwWcZe9k2wRVo+YPLaPrDljh4IVBKoZofr57z2G+0SFHN4gQezz0Md/6EUU+soWX0DmK6auI1tgPAoApSOq6tdPKGtsEoWXJnIpuxZ63FLLFAMP89vOjIC/bnc+K0222zpt0lEz8umywRasolJEOE/o2Ws6QxWKlpEnkyHoGSpC4Y6ApxIUuhZYaiBXJj6J46eWkUPIpcpMKxSI3kAN1MgOYYiBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sTIGXCvlKOe9Ar9BRp9PW662OZnjc2ADZMiM18JhV9c=; b=VlKuLk0NFlFTW58tTaNyopu1EP81cF0kJaVnjjqLA8h+ymgidRuM58BfMY/s61YVhcXlwRgWPyAvHYYtyey3NDIu+bunukSzfdwAN871p0luRKf5pS3HA7ULgm59I1OpN36t6YlSzEOiSc0k9gltK38u0mYaiz4awiW1RQCMHHVgUwCkfByTu8M6BgCSyJg3ClEljt4w6TYO9WKh1zO/FYM0vfXP4wj2Vrx7oRXDBGG7f8WuJP7e7D0m/F26lxA2flXe3ZCDkKFd7ws/XvCm+PjezhuTPBFPrjTPRiSDgHHK3NS0ZGMcZ/3B0M4bF3S+zhYsu5UzWv36brAk+qPIBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sTIGXCvlKOe9Ar9BRp9PW662OZnjc2ADZMiM18JhV9c=; b=iWtLCxWKk0RB80/OY6xvlj0YrPqxGNb4CBB3Xw2iAF2h4Bul8T2mCtK6Y9eSOTryL15Ckc0yA4TAIRjXO2OWtA+CwZcoZIMbxfP+h3qFh19L/BeOsuGXyIgsB8/gagnBzeIK9zGkGZFEg/ILFxkKKWCVFq+6bZJth3WuqrISP/M5Y1N00T1MEdvRGMzff00CpYfrrqaww30k6fxAmyh2Gg9aROEoMIdyW79haJLwQGA3NpX4VYLxv8BN5azPoLgq19LRhJmqYkz1lBJKQA0z9Nlw3ZAjmwT/6EGxZVyOstRzKWk8syg9zsvSF1zhFW9s1NH6HhqsTyAisMswJQyirA== Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) by OS3P286MB2025.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Sun, 15 Jan 2023 10:32:22 +0000 Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605]) by TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605%4]) with mapi id 15.20.6002.012; Sun, 15 Jan 2023 10:32:22 +0000 From: Dawei Li To: linkinjeon@kernel.org, sfrench@samba.org Cc: senozhatsky@chromium.org, tom@talpey.com, hyc.lee@gmail.com, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] ksmbd: Remove duplicated codes Date: Sun, 15 Jan 2023 18:32:07 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230115103209.146002-1-set_pte_at@outlook.com> References: <20230115103209.146002-1-set_pte_at@outlook.com> X-TMN: [jzePy8Ke2U269eFgH6xnfJaRWrsiHvp+UnjAOdp2zZY=] X-ClientProxiedBy: TYAPR01CA0210.jpnprd01.prod.outlook.com (2603:1096:404:29::30) To TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) X-Microsoft-Original-Message-ID: <20230115103209.146002-5-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2323:EE_|OS3P286MB2025:EE_ X-MS-Office365-Filtering-Correlation-Id: 5cf5694e-7be6-42aa-7f8d-08daf6e3c98b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NH503JeqDN27RdbYT32y4CUPrkl4oFh2iLiET9ymAjPK+wSrMyyY2KnYlv4HCd/1rWRNU0WkwZ6/lSRQFzD0Q2XpgIcRC+UTu5kRM1OnfSdHGDhi5+thWHYQPFQ+NehZppDsGIek+sz8tm5YGG3zg5WGKF9czBX/kRoQ8IknyKgpqMLgGUHTdOl2a2zjZ4ET4foj6f2t92kPALpAIOgPKMsvje5MPX5UuYqz+Em4IU0OFzj9+VbdpN07MncpUg/IoI/fWB+jmvHJWRZlTvsq8kt0Ro4BHzA7pD5NC0VsJFmqBWGlX+CQKinccWhvJJcpmaWHN9FHDwcRK13NSrDgk8pCMNsCMwvEyVITvAL+yg+hb3WyvHLUon8wSsRQuZAkIr1mfCLFaAgr0EWI74CtlEyuWxY10LMwxdhFWDanUYn2kOFmiZq1WoGJdK8Y/iXvGL5J0qW2QER74csAZnII42CWC2lzixt0g/mmRn6HIJNv24KK75F98cwqCHDe/D/mffkCxMvhxYKYyY/ZUbLwXUEabPNhDv+CLJkHQVt7FBGMhI8flYak8Mr+SCY750bXrfjvCi4+lIIjQ7UN46+6Ci9YBJEHefkZ9FGKsE0QhGw= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EptRm/ylxG1AzPhVnMfV3Xl4pHxAYbi8F2rrFy8U11FQu5vCTUK2Lgt9NTqpGXveJ3PBZKLdY+T9q5kUwThqLiOy2yvCk3B6nRdTbIGFKkEx7FCoutoB6anfF1MkrxBFsSrG9OlPpR4vN3XZV1phh05xP8ZJaJ/hstDzaxv44Z26gPgFSDAJ4pWW+jcYMoOG05MBiKZUc3hTaAx6d4Y28NsA+YbPocovyVb8CPgW5IkSySRiK1Cb8j5aXOi7ulN5ClR0zGsvorBnP6dyo2XKDZwEksSq32MP9WEKDY3geKJ8AlVSRDQK39A+NTAT/+2EWqakm2IuPpDv+9yt4Fw1LNEu25xE6r0DPIimw0t9JrtBGDeLwRViL4ahN0tttxZyRdSwXkGYxYmPGc5KoAFhIaS6Sx5kD/T5tdLqSt4YZeG4ro4j0cZwt7ue3gF08KBKjj5hka2Z25KFQ+s6ISUknLuoxqKpmYo6kx/88kOCMeMFS1hEG2dyoazUr8+QPayN1IqQ7zOHoi/pDbzDNm74q2xdK/tSFd1/zfTvqDSddKNqpGJgsyVB0m1AS2vqz2f25mvPUuZmw9WQhBEL0EIELOw4Dp/og9qp+Fh/oM/pgp0Mu0b8aZrdT61I1MCDQDyfohjK820gMwuWG4wEkoYbvPpmW+a25oMX8KRO2jzmlXtwOdtp4lZJMafVB8tV5zWs+P6OUYlFB2cJ8axTinmvshUJkTqXwPbLhx5VFnP+L9M1KDYNCsgoMvVIMnNkEoshdf0IBWV0Q5mkJrIAgR1U63eDh0JDfZba8hZgt0IWdt2AS2LyR8Lan/y2UnoB+AtP/Q4IWbj8/AKVILwg6q5XijbILBcJoMYNFcZoxKjNk6O98biw5+51JFvCy9WqNIWQG+r99U1Xv9FuSSG84Da0XSncWdv2HSUqnd6YPjHMrsBHNLVOO4D9ybP+nPw1zW1/XK/hB2KhtLnU4/DOaW5bqJOZO3ETcwPfcsRc1rgrmYTIEZPi634EAXoULCaFy6BNI+yUdxvG+wEwj8ChBw9EnjzMW4UNO4X6lkxK8ceLLemI+FBQXXCy7bc+8apUL2LCB8Uls/Z1hITMRiw5+vz4BNiChagjTsM8SJgZHrdbYF3iMx7Blg5+LE5TOplFi38BG0CQPb4Aassqde9OpUROv78PhgCYFk6/hou94Zal0/pQmmAlynWDppe4iaxdhe7P4uvZlrf9UXspdz+H50eHM/M3qnFhx9taG+CNPDksCxFblUymvv7mVuKT8idrSMd9yt9hF5pgEqzCQbCG6nX5/otI+2IghN6NbUTtEiE9urc= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cf5694e-7be6-42aa-7f8d-08daf6e3c98b X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 10:32:22.8061 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2025 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755084429425049027?= X-GMAIL-MSGID: =?utf-8?q?1755084429425049027?= ksmbd_neg_token_init_mech_token() and ksmbd_neg_token_targ_resp_token() share same implementation, unify them. Signed-off-by: Dawei Li --- fs/ksmbd/asn1.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/ksmbd/asn1.c b/fs/ksmbd/asn1.c index c03eba090368..c85e74fa78e5 100644 --- a/fs/ksmbd/asn1.c +++ b/fs/ksmbd/asn1.c @@ -208,7 +208,7 @@ int ksmbd_neg_token_init_mech_type(void *context, size_t hdrlen, return 0; } -int ksmbd_neg_token_init_mech_token(void *context, size_t hdrlen, +static int ksmbd_neg_token_alloc(void *context, size_t hdrlen, unsigned char tag, const void *value, size_t vlen) { @@ -223,17 +223,16 @@ int ksmbd_neg_token_init_mech_token(void *context, size_t hdrlen, return 0; } -int ksmbd_neg_token_targ_resp_token(void *context, size_t hdrlen, +int ksmbd_neg_token_init_mech_token(void *context, size_t hdrlen, unsigned char tag, const void *value, size_t vlen) { - struct ksmbd_conn *conn = context; - - conn->mechToken = kmalloc(vlen + 1, GFP_KERNEL); - if (!conn->mechToken) - return -ENOMEM; + return ksmbd_neg_token_alloc(context, hdrlen, tag, value, vlen); +} - memcpy(conn->mechToken, value, vlen); - conn->mechToken[vlen] = '\0'; - return 0; +int ksmbd_neg_token_targ_resp_token(void *context, size_t hdrlen, + unsigned char tag, const void *value, + size_t vlen) +{ + return ksmbd_neg_token_alloc(context, hdrlen, tag, value, vlen); } From patchwork Sun Jan 15 10:32:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawei Li X-Patchwork-Id: 43831 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp679221wrn; Sun, 15 Jan 2023 02:35:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXvnV7HlpMIhQO/JFWnCWZDz/UFHZAYYEyWSEkPXKlZg4La1ByeFnXDjQ2gXx2FqGYrHoRM3 X-Received: by 2002:a17:906:3544:b0:84d:3fa7:12e5 with SMTP id s4-20020a170906354400b0084d3fa712e5mr21316254eja.32.1673778946482; Sun, 15 Jan 2023 02:35:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673778946; cv=pass; d=google.com; s=arc-20160816; b=XBNS2V1DInoXQBJeEO5OcRjrMVZFzKIely7tLbG8cRcgEoEjc6j2Ku9fXyqlWJF7mJ MriAgxH+y5aqrOIY2WjphOSOD78NRLISZZs4yOCNmoJ8fLKBVm1upYESGsj3ckFl4je/ zmKzWlEGrbGTAy4Ro8HmdmA5YbkTxwqupgcvovFrFaaXx4HsP+yttQ2wRo9tgRLlXRJp uB/2+zLJgxCi6sx4x/KyGahZzTuSatI28TMEI7U+OhzqXP3dkOnO61hR/RSWGv4uZKvK O0wlpS/5NA6Mzr4Lkzw6WOONvsFtRRbFhIAFa1DvEA4bPPhd2uf4X+zYwhsbSimM8r/b Rkeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yBv7BL9Uf6cXj9khn04VzCBRpFusMoYQVfaaytM5MVY=; b=RtUdzaXGf6Hhv5kwiha6iahdmQj5YM9NFC8+5y2RfFS7Sq4lhgG16wgD5sSxoyWMTR suGTk79/YxyS4NU4N7AfJUl5sPHlzpIVcBu1IM6Np6hrGM0NsMXWDiHoDUSN1oxd07yg gp8VqArlC0D8v+p504wIaNkOP8yqJKSNTkNgUvr5VsGh00Lf2uvZ+YQSpC3XMYgAfTaH N3jK8G42CvjBl1m8+nXqgz99iKc44bhikPsXFplKHtZVJNbS8A4Bm6pNFOpS22pkdptI I2Vh7vfi6+NC13uDYS5uRhbgt/mheKMAgxR7keMXUuyS0T5kFbkImKNjOaa2aIFurRMR eOfA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=HtRWhX87; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm3-20020a170907948300b007c0ce331e13si28131935ejc.703.2023.01.15.02.35.23; Sun, 15 Jan 2023 02:35:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=HtRWhX87; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbjAOKcv (ORCPT + 99 others); Sun, 15 Jan 2023 05:32:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbjAOKc1 (ORCPT ); Sun, 15 Jan 2023 05:32:27 -0500 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2045.outbound.protection.outlook.com [40.92.98.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBAC1CDF4; Sun, 15 Jan 2023 02:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jgBx+uSFDs3IRKmTXkP822He34PEHT84/IOiMSGekMG0kKmjweShw3scks6P8dv6yG4zax0jzIjThC4CBzjm2a9hom9YPTTcWTmVnWP0vI/haTUutme55YVNPeQFy3hM6262FiH5aLD1hq6oIhZxBSdVOxDtkvTGygeUZxw0axmkVsjaAQUxif+QQ89/5OqgNsmk+EZVZLOcuZ7LgOv836+9lJoHV6641t3e992X4vB3Obc3l98RYD+1eDB5wI+vbWBTl+NxoGHhpumhMerg940F8wQi+4krBauMV1tfqYtbMeq2szv0v6BLOZkKqaWE+op7UH6cbDw4HpuaUgzeug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yBv7BL9Uf6cXj9khn04VzCBRpFusMoYQVfaaytM5MVY=; b=DezYgFGylCN+WWPi8yreaLdjNh3uvO+MV2m7EoOrVfNZ3tBKHQatbO3hLVvG/WFqehbDx4Q1csDoxTz3gzGTzVx8Tyeqnchc7XyYTfB8xvNaWj/oPoYGXowf9utWLf8IRNNpqwZEe+v1rg9bkwGSBw1Rf82yGeYzrPPG/sde8XcqvmpQxORYWWoVCCMs5xMoyT1LLejIICtojP1Cbp4DUmevW50qLvRHA/DJ35jZ2kjkRsVknmVgt1Ch6BosdEfo8gLHnOGoYYabk7cSAuCp720K89M3EHJJUm57PK+L0DpvI/oMmQN7YliK6vXu+aamv5o4HYEClyZfhckhSomMVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yBv7BL9Uf6cXj9khn04VzCBRpFusMoYQVfaaytM5MVY=; b=HtRWhX87r/IiFjroNNQQTkq7uROq4LkixilqMwVib7Z5hRLSW9+fNVvM9HZIdHo6F5lNr++teX20VOcgPBLoGwsGEc3uPMjLSWky3SWDnMvCTTL2FBuI5sMbGxdw4yPsTSmsVQ9G3BSUTontwmn8+ZYEgMSoaFB88CMrzyXfAowTjGXAaAkR0T5wW0pect+fGe39J815n+/u6NiIKJZYCqEWa4LHNbdu0hx/1IxCw1w9/ryEUSismo0aQ4kkEqvWSwCDDvtTagpPTMAYEcLMm2bg9XthUzTDk1U3oq67kZe+J89iuJhZk4Xxyg3ux7lP2d64SD3SUAeevrTCxmIThA== Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) by OS3P286MB2025.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Sun, 15 Jan 2023 10:32:24 +0000 Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605]) by TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605%4]) with mapi id 15.20.6002.012; Sun, 15 Jan 2023 10:32:24 +0000 From: Dawei Li To: linkinjeon@kernel.org, sfrench@samba.org Cc: senozhatsky@chromium.org, tom@talpey.com, hyc.lee@gmail.com, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] ksmbd: improve exception handling and avoid redundant sanity check in loop Date: Sun, 15 Jan 2023 18:32:08 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230115103209.146002-1-set_pte_at@outlook.com> References: <20230115103209.146002-1-set_pte_at@outlook.com> X-TMN: [TLUMQ9VmFG2iXlqBs9WdQk1N+GaLwOZxb/cH16lS/eA=] X-ClientProxiedBy: TYAPR01CA0210.jpnprd01.prod.outlook.com (2603:1096:404:29::30) To TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) X-Microsoft-Original-Message-ID: <20230115103209.146002-6-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2323:EE_|OS3P286MB2025:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a957baa-ecf4-4f4a-86f3-08daf6e3ca51 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VmSD1IAij1wTEhBFvMyP6VgzZg+Kzd0P5HQpsMkes71SiOF6BOk+cSxen4/T40okNhVcSqBXpyvG/6NK0thvVn/xDCZan7HdKCPoODYPa7qMqEMdB/liFkJRcuAm5x1buYy52ZlCfr8i9ocpkBZXezuUsYiXvst7mUWJG7yYZbK8e40AfRkJjj+BTRXAv0D93QGGpuiPbaetI4ycWsjo2yJR2PvrLMgLOkQQXmKIbomM4xHs1NCful9Z3DchPxgr+KMkoGOfhRFnfCkivLqi/yiuVEnm5jvtSSgGioGjdlgfGq2wFEcyL1XX1PurJ8PToeo5ldMuc10Jotd+winhf7URRPPxvSjjPm6OAYbWvLv7NsWSHCYF9RKDmIdiFet1v5p7PNErpEyLPq7EdeTf4OG205tRKN+gvrtrIXE52Erfg0meIrOHi9fwNbJ8kYcTnRRv1TMP5yZKPTh+IDI6yRngdaqQpj/rVICHzIYOHwn6EDNrrn8VV7PNOwdmKFzCiaEqU7ZNIFVSuS74sXJDP7F1WVAGZOd65B2riGI5UB2n53Rrbv/SgCJ6sYHzhgAwvbnKiNqfI8xtGDzWKcjaYYmfd02Ahe67LURpJqAn0HQ= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DKlU+EVUHF653wYuNemROsio4rKomrRwmGlW3nLdjJZ9HbL7ZtlE1Rz/VoTCssjhI8DQTEL9uDsvBGzPHxd6y4Beg+p6Xo6E5tbsKJzjAJmUbo+W7nO6xlwblzpsJ5gkawkKxxc4BWyw8fmAcXh7Q5vf6mqPsQA5wTaOHqxpmNRZ2K/bIj1T9lFvAjN+Qmr/9170VbwEnKHZqhGsjAJ5JLnzfbarx1hbr5LnN34jzOzdeXiw+PFDWsn6eeky/C8WTGu3VCMEigaXXvP/JfEZRfbz6TSQd5Co28Q4Vopyb/HI/1VVqj5XmH0TBhPqWWcwWjc6jChvrL+N4EoeHOnNoq/zZitI8Bblvra+I9HfRVb29RggH0dvkN546g5ih/RPrG1mmLSfwq26easq/K3BqzsuUgOkb35QgSiODnq6zS7OJizCvc/UWF4Z8/6hTvnz1/SNm/X7WslJEvP6h4S0SQopLHqhnbKZpErwSoPetWqUG6mLSvmOlKMvSmy9O4bapfISAk7eQb8UdtZmdAwJcCS76sbbLqAN1Qdes4zO5hmJGv2Fyz/TuYQgn4MsDe76Pqx5JSXvvYcRnq/V0YMbio1St/Q7HLkjCv+Kjoo8t81XGA5MIsEpKloXMWGrJJBNlB/cBEUQ11tjUdgXZw6AF9SsR0ZYt+MeDprjK2u6iOWfrEXyPPyPUJzvq4EDd6A+E9mGQeXZhrO+e09pHhqMwhOjYMs/1BR/Ow2GWouWSXOkPMoCy1L0tjSLvmEP9NxZHD3jY1mY1R4hwQSv417nF+6yeg1N8pHROUxG/okCIepdSuqc9MGrH8yQMX/qPCcOXbbwRTZC8xDKYt1FEtzpbhyy/LChNMjSOQ0G90DjF/Ij6AIBNfbrbpMJUd826kek0VvoYQtRqPnPuSJrGmOGt/ziT6hYOKyVp5ruJ3vKUgjsP5puPrH6d1tPAYnttXxuta8PutpxfyT+gocGTtEWVQOwQxwjLT/0rXow5tQYQ+y3kf1DsHbW8lhwcEDCY6/G6oY7DxhWjbC4KqhHs57u0+MRadtNhBh1UkpwzcpNX+nWSIHccFNyZ/Sm/T4eVCFf8pU0zvQwcg2MCPNfkIn7uDr+fm7eha/6l9JvoHD32nOzW/2loRYFS77FYuM3pzA9vu8/zA5Eu205yMX0yhe/3BOmpWH9vAP5CbztNszhWsnkUNARmizIhVj2Z+ee7mVnL/6rprdb8TJ5DDahcPo3lmp5PGwhxaBvWg1m35atRCeVas9y17bHAEDvam7XzWGcvp3qIA5KSmZiXOngeHW8AgztfFukE0tAAjHrZeruGEY= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a957baa-ecf4-4f4a-86f3-08daf6e3ca51 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 10:32:24.0883 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2025 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755084432142565356?= X-GMAIL-MSGID: =?utf-8?q?1755084432142565356?= 1. Sanity check on validity of hook is supposed to be static, move it from looping. 2. If exception occurs after kvmalloc(), kvfree() is supposed to reclaim memory to avoid mem leak. Signed-off-by: Dawei Li --- fs/ksmbd/connection.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/ksmbd/connection.c b/fs/ksmbd/connection.c index 36d1da273edd..b302de5db990 100644 --- a/fs/ksmbd/connection.c +++ b/fs/ksmbd/connection.c @@ -287,6 +287,12 @@ int ksmbd_conn_handler_loop(void *p) mutex_init(&conn->srv_mutex); __module_get(THIS_MODULE); + if (unlikely(!default_conn_ops.process_fn)) { + pr_err("No connection request callback\n"); + module_put(THIS_MODULE); + return -EINVAL; + } + if (t->ops->prepare && t->ops->prepare(t)) goto out; @@ -324,8 +330,10 @@ int ksmbd_conn_handler_loop(void *p) break; memcpy(conn->request_buf, hdr_buf, sizeof(hdr_buf)); - if (!ksmbd_smb_request(conn)) + if (!ksmbd_smb_request(conn)) { + pr_err("Invalid smb request\n"); break; + } /* * We already read 4 bytes to find out PDU size, now @@ -343,22 +351,18 @@ int ksmbd_conn_handler_loop(void *p) continue; } - if (!default_conn_ops.process_fn) { - pr_err("No connection request callback\n"); - break; - } - if (default_conn_ops.process_fn(conn)) { pr_err("Cannot handle request\n"); break; } } + kvfree(conn->request_buf); + conn->request_buf = NULL; out: - /* Wait till all reference dropped to the Server object*/ + /* Wait till all reference dropped to the Server object */ wait_event(conn->r_count_q, atomic_read(&conn->r_count) == 0); - if (IS_ENABLED(CONFIG_UNICODE)) utf8_unload(conn->um); unload_nls(conn->local_nls); From patchwork Sun Jan 15 10:32:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawei Li X-Patchwork-Id: 43832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp679236wrn; Sun, 15 Jan 2023 02:35:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXthQm3ZuCQxGoIvFpUu6h8C01TIue6T/1oYbPyT/2LaIL0xvl1uxNelDWPo/YPVHGhZ8Pfg X-Received: by 2002:a17:907:80ca:b0:86e:a013:c26f with SMTP id io10-20020a17090780ca00b0086ea013c26fmr3430826ejc.19.1673778949262; Sun, 15 Jan 2023 02:35:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673778949; cv=pass; d=google.com; s=arc-20160816; b=ddEk3Ggj5PVHvs6iGcxffp1dL8MvRkHFljeAzPl+JtfDfgV1v1NuaAPL79PUKlxX60 UcwNxKdMthN6aBgytu07H87TsYMdac0a2R9ICAh2RVl1zupT3qOH8GNr723wiJmMx5tg qTKTceYlBE/ArqK0Q/lOzql50wMmn9Ho9U3/B9KCmCGbLLQPtgjZ8wN3htolbvY9HVq8 H7ZfI/vDo0/jMSYFo+XKcpVEeWhjXP+n/h+rz+0kJs69hfUcRh6p6x+jwKwxzwXCva7v AzO6gt1sNAOr8AcAsyhjamInwVX6Zlyt/brmL8213ev/Avgj/hbH8SmNVSYb3/JPV+kW ysPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sskbBFcb3YFm14/Jh/anX8frm80C4yL2TYzqKanaQG4=; b=soguMS4VvsQqJwV652bntf2wDZ6Ok9astBSXOUS7xTyRYH7nqi/V+jgtzwJCx7OGhu yljc6Rf8OpiAzNV8QNCornaRlw5cTwF3dPx7O6+WI+gw+tgswJtrmjEf5V6ToWw2gEts OHAnnyTC2wB19pQBZU0Byx5j36bHOS+DXHbVWr1SMGzzOmA/vdtQO5F/RnEMXPH/zlLF teiIl8utmQj/8ouix9DVyVFd6oT9fCtd1Q10udvdxaH0HqofhHpX5zijaJ2MKxIs1yFS qpdTXhvx8qF6Xau42iNvD45GHLODL0+xUYXEVUqGCayGdC66G2qnk2Ib87H/wZy9rmk2 UviQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=EvkFWcF8; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ww2-20020a170907084200b007c0db556798si28195090ejb.994.2023.01.15.02.35.26; Sun, 15 Jan 2023 02:35:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=EvkFWcF8; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231225AbjAOKcz (ORCPT + 99 others); Sun, 15 Jan 2023 05:32:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbjAOKc2 (ORCPT ); Sun, 15 Jan 2023 05:32:28 -0500 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2045.outbound.protection.outlook.com [40.92.98.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C73C16B; Sun, 15 Jan 2023 02:32:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WNvxOQXFMha0J2Yus+H/566VSrKVCG72eYBEim0ZiLu1CCfjt4A6xWMdgYXcc0oXmZfhr+7Fp359oGqBvo2Ow45JcP2gH6FFCNgC9wX8sf6Bv2dW5sJxaqygNcjutOuZhZSjKVOP6+4H8ALIq5Z3AG09SoMj1k/PJ8Y5nhbSDvdb1Y3e8sgqUyjyDDiPgqfUnPRMYFvfLPWIq819+t1Y0jeTUWJlnibq47ayepqULt2X6/jKNUxNyi6c/2CyyOb/vUB5B7fmehNB8F1gBTLXLH1Ca4ybCq1vwW2joWvtalYAhqk4QCpVX0HYSZHFvcfwqRofYIGC2TAPqHIuCAkqfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sskbBFcb3YFm14/Jh/anX8frm80C4yL2TYzqKanaQG4=; b=cLp99XLUNr0MIRuuBTnD+iiYyRi6Ga51SiBRrpDjmqXRQwN61U0y6LgIXuOPuI6/kiP23nZzE3KSMNxrK6x0Dv1yJin5KLQv9MNgqAERrS8S2UIHHEUap+teo3QVue+67FV3LkqTh8G511EckY3hCb6kq6ldzwAg0LEgkvtHkeLWvRrkb5oNAOAvH7VIGCl4D0gpfjCkezJ3BdVlkI4yRhXC2slSqrpbQNQKjTqxvacYYxYffq2+AY0ZXGr/bdSgtGpUxJg/jy7rXmSfjzvgNywEi4IzsGXCu2hwO5/ozajZ2l5KeG8f3jTaYrYMwF6CPLTYr8g+OFNB//OTeNaYjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sskbBFcb3YFm14/Jh/anX8frm80C4yL2TYzqKanaQG4=; b=EvkFWcF8VH+/OtlugYXZcqDyxC3qsGYdKVVn2niQC95KgRlHvEv4qemTZLR/hz1ZRY+YZ2F8jv6KG3HnGhnYCa5oo9IFZMLbFofklCNVHHNgLbgcTFSfp919lUS1x8b8Qc73DFNhIPWO6V7rkz5BnPrgaUKqHUJSc/hkGIg4s2qzCsFODCMxZSe2NGRUbo4nNtmz+qBAUX4mqfcmmh2ohHzyrNzApxxxBLCqKPTPJkfi10GOJRRxYLHfNvsgsiqpV9Es3jmCs3jDnZLGQFavJOh+PrtPX6FdZlacVrYAv2BLUpEyV8Z0eFAK6yTwYWovll+B2qR55UriHnl73NHslQ== Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) by OS3P286MB2025.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Sun, 15 Jan 2023 10:32:25 +0000 Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605]) by TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::ff96:9cb6:e047:c605%4]) with mapi id 15.20.6002.012; Sun, 15 Jan 2023 10:32:25 +0000 From: Dawei Li To: linkinjeon@kernel.org, sfrench@samba.org Cc: senozhatsky@chromium.org, tom@talpey.com, hyc.lee@gmail.com, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] ksmbd: fix typo, syncronous->synchronous Date: Sun, 15 Jan 2023 18:32:09 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230115103209.146002-1-set_pte_at@outlook.com> References: <20230115103209.146002-1-set_pte_at@outlook.com> X-TMN: [BvRQ8v6enCF2LInju5goHaOM1AOCSujnMOrAgMz9Sqk=] X-ClientProxiedBy: TYAPR01CA0210.jpnprd01.prod.outlook.com (2603:1096:404:29::30) To TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) X-Microsoft-Original-Message-ID: <20230115103209.146002-7-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2323:EE_|OS3P286MB2025:EE_ X-MS-Office365-Filtering-Correlation-Id: 10bc98bc-f777-4ae2-9c63-08daf6e3cb12 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +shUgAg6YJVrKILYKvkc6agH7zvfdZdGL99LEBjpSXsj+CiATf4UbEsezuXKQ1Xsu0PIfJoTePqQRZAc/WbcO339L0tKjqo1JpHhTvep9K2YwgjlnBr04AIlcvj+2LUo+jF6+cmPTkPOaMGpsM52MUdFdscfzCVWPBq/HeW7JbUrs97LPWBiRIBqWrl35BpUxFyq+asr1DutrdZFfXwvJKHlWUq5Mr4JL5lqnyDnGXs0tYgIabx3TtY4dQErqI7yj+0D2qZTo25xp+BaaPhjxDEGxUKG8uO3RH0XWnqf1ICDPAZVDoawfpwcEEH9Nwhxv/3RmYOVOL0zinV1qXKVDx/ep6RIIHtE6/kx4S9jCokAdwSb00zB1mWZUYVU+BxFXaq/Bw3CZS4d3FoDce8gOLwdfJXZGbGUel1I+59UkN/owe2gx7bkSyyXtm94uxj0vuukGfuIV6NpwQYtQhgkXiHwy+qDyp0UwVgJp635nfMxQLq9/YVs1f2RVi23zzBmL9ssvLUrZZ9DG2h1U1eibjKjq+XHkldIWx/hGWV6JedpCxjNX/aLjw13fGfJeOHgmWVtqZOipgxVqIVMfkBEaVM+my6mRsJyLjoRLq5QYpc= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eqcFZ16X3EvDI19BqBn0XGyozwdhAI0XpmajfoA+AdBpL2wp/ThJNG5othf5u+lsrWjsuP0c4Qt785nAwDVrJWGYsgq6y0ZwFKhCtEZNNAHI2vlkbj/EFG3/ZGo0BXhgiPt5igBIm1YrbfeylXYxIZwBjZRtoZmhigViHu+Ufo7YRooLzzEiAACMWPQ+0mTYFLJrLFfeoS2pwNV1uuaVyPy8GtV7fuz8JAYGchQwcZIEvBndEZAGWijL1OOQmx0EsnkPIZqgTVb69Yjf07Jo8rnnuwPIpYYOUopIjgYFL7bbL7NVfmgGqq+mmrTVD7t2XuXy1DzveWUmYCNm6Z1nPvEfujBEWU2msFIm2rilrtOwr0rWdoKzzr3Ed2HQScqeeEjB9HQ28INfSzV21rqVXhjzOYrde6p1l9IvwQqhTwGBeoHwNfvJ6IevpYCiOUXBuxlKH7P2iS+0CQBm5jdVHetklLR+So/HcDxbauPfb2CWqsAOFYnLuCOCP0FV36FgBEpiC0lZo2a7cdWi99aWv0A6v11dfbZ5qkVOy6DAELV5zlbbJZaMNhfhN3YK5CcDMXbMjJbyYfIjm73s9JAvBasAz/XBk8XOBAIc414M46fABzSZQkt71XJYUeyo3sP5ETf+RtvVVHI1UndzAONefFtMo6kwEB1cv6gAq1rs57acO7JCWNyWc3yzLvUQJEmy3n70lDnEucdVlIemCNol7DqPGSzHg9UohUOmcIsK3BDsN1AWoF/AUxjrAgBGsP+wC1lUqlycdZhp0rmzARbALHLOhbqBpdP++I/LrSfkRNOfxT4qzcXid9fOmkrPwcPEyhmRsyc8+7UOPApxX5jJlcWAvFgePGOTgZ2vd3WMZ+RFIMY4MfnTYaNyYkN87OmMrcwvR+R1KWOHZJul+GzoXDFjq/kT1asiXUCHe7BnMD0g1C/CaxKEGuy4dkQUX5KrCbz+vMNTSjggyyPk5KsshRV4Zx7Li9PnSPaj4eAFi2amkd5IbyNdaMOudTQ9yMWm0+SY7dpOXsAZse3Kq3JkCXW7Jqtjg4XRRKZDldvikoGqfT2EcTz6WasWcY/C+kf6Tr8tino49n7h1uI9m7x3h3fn8x2DIviOHqSaeV4+6t9H3QMjeGfTXv66he3YV8he+WUmBqxVPJkyExB9Zc2p6yADX30arfgC+EGa5fQ1wBjdHgp4Lp1P2G1Te9KLwBd80iCE7ijiXan6u3J53elVXAA221URmyZBpZHxzdADWKJOOeJxw9nXKbjXRpT3ipDGRUN6wY6ZT6yPDGCtHQHPLX1fUWD2vU7JtJvP955/KD0= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10bc98bc-f777-4ae2-9c63-08daf6e3cb12 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2023 10:32:25.4018 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2025 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755084435599444347?= X-GMAIL-MSGID: =?utf-8?q?1755084435599444347?= syncronous->synchronous Signed-off-by: Dawei Li Reviewed-by: Sergey Senozhatsky --- fs/ksmbd/connection.c | 4 ++-- fs/ksmbd/ksmbd_work.h | 2 +- fs/ksmbd/smb2pdu.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ksmbd/connection.c b/fs/ksmbd/connection.c index b302de5db990..0fcc20ce0852 100644 --- a/fs/ksmbd/connection.c +++ b/fs/ksmbd/connection.c @@ -114,7 +114,7 @@ void ksmbd_conn_enqueue_request(struct ksmbd_work *work) if (conn->ops->get_cmd_val(work) != SMB2_CANCEL_HE) { requests_queue = &conn->requests; - work->syncronous = true; + work->synchronous = true; } if (requests_queue) { @@ -139,7 +139,7 @@ int ksmbd_conn_try_dequeue_request(struct ksmbd_work *work) spin_lock(&conn->request_lock); if (!work->multiRsp) { list_del_init(&work->request_entry); - if (work->syncronous == false) + if (!work->synchronous) list_del_init(&work->async_request_entry); ret = 0; } diff --git a/fs/ksmbd/ksmbd_work.h b/fs/ksmbd/ksmbd_work.h index 5ece58e40c97..3234f2cf6327 100644 --- a/fs/ksmbd/ksmbd_work.h +++ b/fs/ksmbd/ksmbd_work.h @@ -68,7 +68,7 @@ struct ksmbd_work { /* Request is encrypted */ bool encrypted:1; /* Is this SYNC or ASYNC ksmbd_work */ - bool syncronous:1; + bool synchronous:1; bool need_invalidate_rkey:1; unsigned int remote_key; diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index c60cfb360f42..2ae153de4a9c 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -498,7 +498,7 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work) rsp_hdr->SessionId = rcv_hdr->SessionId; memcpy(rsp_hdr->Signature, rcv_hdr->Signature, 16); - work->syncronous = true; + work->synchronous = true; if (work->async_id) { ksmbd_release_id(&conn->async_ida, work->async_id); work->async_id = 0; @@ -644,7 +644,7 @@ int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg) pr_err("Failed to alloc async message id\n"); return id; } - work->syncronous = false; + work->synchronous = false; work->async_id = id; rsp_hdr->Id.AsyncId = cpu_to_le64(id);