From 0f02f68f9f197ee7ec4b24a32a7b5a4b985ebe9b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 13 Sep 2022 01:30:48 +0200 Subject: [PATCH] s3:smbd: avoid remove_oplock() in close_remove_share_mode() This inlines remove_oplock() into close_remove_share_mode() and calls remove_share_oplock() and release_file_oplock() directly. The idea is that we'll soon call remove_share_oplock() under a tdb chainlock, while release_file_oplock() needs to be called outside. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- source3/smbd/close.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index dfb1fa56cbd..fbbfdccf372 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -315,8 +315,19 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp, } /* Remove the oplock before potentially deleting the file. */ - if(fsp->oplock_type) { - remove_oplock(fsp); + if (fsp->oplock_type != NO_OPLOCK) { + bool ok; + + ok = remove_share_oplock(lck, fsp); + if (!ok) { + struct file_id_buf buf; + + DBG_ERR("failed to remove share oplock for " + "file %s, %s, %s\n", + fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), + file_id_str_buf(fsp->file_id, &buf)); + } + release_file_oplock(fsp); } if (fsp->fsp_flags.write_time_forced) {