From: Stefan Metzmacher <metze@samba.org>
To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org
Cc: metze@samba.org, Steve French <smfrench@gmail.com>,
Tom Talpey <tom@talpey.com>, Long Li <longli@microsoft.com>,
Namjae Jeon <linkinjeon@kernel.org>,
David Howells <dhowells@redhat.com>,
Henrique Carvalho <henrique.carvalho@suse.com>
Subject: [PATCH 4/8] smb: smbdirect: let smbdirect_connection_deregister_mr_io unlock while waiting
Date: Tue, 7 Apr 2026 16:46:30 +0200 [thread overview]
Message-ID: <e562d099bb486b293b4fe4cf9f61b2a5a058fbb7.1775571957.git.metze@samba.org> (raw)
In-Reply-To: <cover.1775571957.git.metze@samba.org>
We should not hold a mutex locked during wait_for_completion()
holding a reference is enough.
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Henrique Carvalho <henrique.carvalho@suse.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/common/smbdirect/smbdirect_mr.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/smb/common/smbdirect/smbdirect_mr.c b/fs/smb/common/smbdirect/smbdirect_mr.c
index 4873a2c1066f..fa9be8089925 100644
--- a/fs/smb/common/smbdirect/smbdirect_mr.c
+++ b/fs/smb/common/smbdirect/smbdirect_mr.c
@@ -410,6 +410,7 @@ void smbdirect_connection_deregister_mr_io(struct smbdirect_mr_io *mr)
struct smbdirect_socket *sc = mr->socket;
int ret = 0;
+lock_again:
mutex_lock(&mr->mutex);
if (mr->state == SMBDIRECT_MR_DISABLED)
goto put_kref;
@@ -440,8 +441,15 @@ void smbdirect_connection_deregister_mr_io(struct smbdirect_mr_io *mr)
smbdirect_socket_schedule_cleanup(sc, ret);
goto done;
}
+
+ /*
+ * We still hold the reference to mr
+ * so we can unlock while waiting.
+ */
+ mutex_unlock(&mr->mutex);
wait_for_completion(&mr->invalidate_done);
mr->need_invalidate = false;
+ goto lock_again;
} else
/*
* For remote invalidation, just set it to SMBDIRECT_MR_INVALIDATED
--
2.43.0
next prev parent reply other threads:[~2026-04-07 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 14:46 [PATCH 0/8] smb: add kernel internal IPPROTO_SMBDIRECT Stefan Metzmacher
2026-04-07 14:46 ` [PATCH 1/8] smb: smbdirect: change smbdirect_socket_parameters.{initiator_depth,responder_resources} to __u16 Stefan Metzmacher
2026-04-10 21:02 ` Henrique Carvalho
2026-04-07 14:46 ` [PATCH 2/8] smb: smbdirect: fix copyright header of smbdirect.h Stefan Metzmacher
2026-04-07 14:46 ` [PATCH 3/8] smb: smbdirect: fix the logic in smbdirect_socket_destroy_sync() without an error Stefan Metzmacher
2026-04-07 14:46 ` Stefan Metzmacher [this message]
2026-04-07 14:46 ` [PATCH 5/8] net: define IPPROTO_SMBDIRECT and SOL_SMBDIRECT constants Stefan Metzmacher
2026-04-07 14:46 ` [PATCH 6/8] smb: smbdirect: add in kernel only support for IPPROTO_SMBDIRECT Stefan Metzmacher
2026-04-08 1:04 ` Kuniyuki Iwashima
2026-04-07 14:46 ` [PATCH 7/8] smb: client: make use of IPPROTO_SMBDIRECT sockets Stefan Metzmacher
2026-04-07 14:46 ` [PATCH 8/8] smb: server: " Stefan Metzmacher
2026-04-07 21:18 ` [PATCH 0/8] smb: add kernel internal IPPROTO_SMBDIRECT Steve French
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e562d099bb486b293b4fe4cf9f61b2a5a058fbb7.1775571957.git.metze@samba.org \
--to=metze@samba.org \
--cc=dhowells@redhat.com \
--cc=henrique.carvalho@suse.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=samba-technical@lists.samba.org \
--cc=smfrench@gmail.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).