{"id":2220578,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2220578/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/e562d099bb486b293b4fe4cf9f61b2a5a058fbb7.1775571957.git.metze@samba.org/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.1/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":"<e562d099bb486b293b4fe4cf9f61b2a5a058fbb7.1775571957.git.metze@samba.org>","date":"2026-04-07T14:46:30","name":"[4/8] smb: smbdirect: let smbdirect_connection_deregister_mr_io unlock while waiting","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"496cd1cf882c628ae87c6484ae669a6f1ccecac5","submitter":{"id":8149,"url":"http://patchwork.ozlabs.org/api/1.1/people/8149/?format=json","name":"Stefan Metzmacher","email":"metze@samba.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/e562d099bb486b293b4fe4cf9f61b2a5a058fbb7.1775571957.git.metze@samba.org/mbox/","series":[{"id":498990,"url":"http://patchwork.ozlabs.org/api/1.1/series/498990/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=498990","date":"2026-04-07T14:46:28","name":"smb: add kernel internal IPPROTO_SMBDIRECT","version":1,"mbox":"http://patchwork.ozlabs.org/series/498990/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2220578/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2220578/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-10693-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 (3072-bit key;\n secure) header.d=samba.org header.i=@samba.org header.a=rsa-sha256\n header.s=42 header.b=zHRNS6FW;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10693-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org\n header.b=\"zHRNS6FW\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=144.76.82.148","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=samba.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=samba.org"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\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 4fqq1j4s7wz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 08 Apr 2026 00:52:57 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 489C93072E1C\n\tfor <incoming@patchwork.ozlabs.org>; Tue,  7 Apr 2026 14:47:48 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id F1EFF30E85C;\n\tTue,  7 Apr 2026 14:47:32 +0000 (UTC)","from hr2.samba.org (hr2.samba.org [144.76.82.148])\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 15AB830E0E9\n\tfor <linux-cifs@vger.kernel.org>; Tue,  7 Apr 2026 14:47:30 +0000 (UTC)","from [127.0.0.2] (localhost [127.0.0.1])\n\tby hr2.samba.org with esmtpsa\n (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256)\n\t(Exim)\n\tid 1wA7iC-00000007WPi-0pkD;\n\tTue, 07 Apr 2026 14:47:28 +0000"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775573252; cv=none;\n b=DwydpGub/5YFL+CN46CQKsx9gunX0+6m7kaz6zXcIMujkzNvr1C39X5VygVLJsr3ZDA6/S68P5Op7Q2puY7TQsIWfZcASgqoItysmhcHM+Fihz7hz4tq49u82whUWKQenLxn9Giiqs4Ut25d9D3jam2a+27Ph8fjFmXUtFMlXMg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775573252; c=relaxed/simple;\n\tbh=RqbYLS4KOn7QuJLVKU4yhmX2b15QHwqk/UEVRn0ixnE=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=Ef9Klw+Y18ZYgRMfyekOp93nLz5PuMTBGvlAO55i1oospAJjwu1EUc0ckHNeAInwD6Nl76jr/Vio+f0YRdicP0MrzyzIOgDJwCewYKB7nStzdXrtuTFJk2XHWeMMI9CdELYtceOJRiX5avhrM0bj8EgUMBM9mNolv9VUW4pcm3I=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=samba.org;\n spf=pass smtp.mailfrom=samba.org;\n dkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org\n header.b=zHRNS6FW; arc=none smtp.client-ip=144.76.82.148","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org;\n\ts=42; h=Message-ID:Date:Cc:To:From;\n\tbh=l0krKi8UISL6Klaznu4skUTTUG5mv1iJjgjo7qzhgiM=; b=zHRNS6FWZ1/0BgJN9F88xzff2a\n\ttFvON5ZfgkP9zJSK5nEVQwaDkSjGgPu5HzAduZ8TxsZ7Wuj9J0A5Vos6X2AUXgw48k/fnp8wJ+a9H\n\ttHRX3jL1YNHIHTJQy5mrbI9koR43ui8L/KraL0c6sa8+AnVWdBzqKldFg89/FsxCZwkkEJf+sNkx5\n\tpEgZHMpxbS7HYJrvqEurzou/do0f7sOhVhdnc1gcpXyluwxSomXasdxrSRR1tmE38KVeDivy3uGtX\n\tSz8PxwyGR+HKFoWyoa7fyss7s+nGTe+0wCfys0bHG7ThUI+08qEM3toDMEieY02AZeS1Y4tLbW+w7\n\tnI1wq5Jm8tT3pM0Sa7hBml24yfkmvJf8bke4govf/ISNnVcuJRP8d0inx0ZF+a0+ck8vl3tPrln9K\n\tDgPJ7zwipa1eQQaMnjK5a+dyRarLOV0GMDCnzfTDnbMvVPk3e7dr7QsSH7AJe/4wnvRLzuSCOmocm\n\ttbOTtlnoWqCCkG9uBKHPlCL0;","From":"Stefan Metzmacher <metze@samba.org>","To":"linux-cifs@vger.kernel.org,\n\tsamba-technical@lists.samba.org","Cc":"metze@samba.org,\n\tSteve French <smfrench@gmail.com>,\n\tTom Talpey <tom@talpey.com>,\n\tLong Li <longli@microsoft.com>,\n\tNamjae Jeon <linkinjeon@kernel.org>,\n\tDavid Howells <dhowells@redhat.com>,\n\tHenrique Carvalho <henrique.carvalho@suse.com>","Subject":"[PATCH 4/8] smb: smbdirect: let smbdirect_connection_deregister_mr_io\n unlock while waiting","Date":"Tue,  7 Apr 2026 16:46:30 +0200","Message-ID":"\n <e562d099bb486b293b4fe4cf9f61b2a5a058fbb7.1775571957.git.metze@samba.org>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<cover.1775571957.git.metze@samba.org>","References":"<cover.1775571957.git.metze@samba.org>","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"},"content":"We should not hold a mutex locked during wait_for_completion()\nholding a reference is enough.\n\nCc: Steve French <smfrench@gmail.com>\nCc: Tom Talpey <tom@talpey.com>\nCc: Long Li <longli@microsoft.com>\nCc: Namjae Jeon <linkinjeon@kernel.org>\nCc: David Howells <dhowells@redhat.com>\nCc: Henrique Carvalho <henrique.carvalho@suse.com>\nCc: linux-cifs@vger.kernel.org\nCc: samba-technical@lists.samba.org\nSigned-off-by: Stefan Metzmacher <metze@samba.org>\n---\n fs/smb/common/smbdirect/smbdirect_mr.c | 8 ++++++++\n 1 file changed, 8 insertions(+)","diff":"diff --git a/fs/smb/common/smbdirect/smbdirect_mr.c b/fs/smb/common/smbdirect/smbdirect_mr.c\nindex 4873a2c1066f..fa9be8089925 100644\n--- a/fs/smb/common/smbdirect/smbdirect_mr.c\n+++ b/fs/smb/common/smbdirect/smbdirect_mr.c\n@@ -410,6 +410,7 @@ void smbdirect_connection_deregister_mr_io(struct smbdirect_mr_io *mr)\n \tstruct smbdirect_socket *sc = mr->socket;\n \tint ret = 0;\n \n+lock_again:\n \tmutex_lock(&mr->mutex);\n \tif (mr->state == SMBDIRECT_MR_DISABLED)\n \t\tgoto put_kref;\n@@ -440,8 +441,15 @@ void smbdirect_connection_deregister_mr_io(struct smbdirect_mr_io *mr)\n \t\t\tsmbdirect_socket_schedule_cleanup(sc, ret);\n \t\t\tgoto done;\n \t\t}\n+\n+\t\t/*\n+\t\t * We still hold the reference to mr\n+\t\t * so we can unlock while waiting.\n+\t\t */\n+\t\tmutex_unlock(&mr->mutex);\n \t\twait_for_completion(&mr->invalidate_done);\n \t\tmr->need_invalidate = false;\n+\t\tgoto lock_again;\n \t} else\n \t\t/*\n \t\t * For remote invalidation, just set it to SMBDIRECT_MR_INVALIDATED\n","prefixes":["4/8"]}