From: Jeremy Allison Date: Wed, 10 Aug 2016 21:39:52 +0000 (-0700) Subject: smbd: oplock: Factor out internals of remove_oplock() into new remove_oplock_under_lo... X-Git-Tag: samba-4.3.12~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=508aef7574b0d284c586c9c51986c74332dcc177;p=thirdparty%2Fsamba.git smbd: oplock: Factor out internals of remove_oplock() into new remove_oplock_under_lock(). Allows this to be called elsewhere. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12139 Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke (cherry picked from commit cb394abe5206dd8ad8a68f157427991b259129a7) --- diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index e97a33a733e..b94bc36ebba 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -222,6 +222,34 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck) return true; } +/**************************************************************************** + Remove a file oplock with lock already held. Copes with level II and exclusive. +****************************************************************************/ + +bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck) +{ + bool ret; + + ret = remove_share_oplock(lck, fsp); + if (!ret) { + DBG_ERR("failed to remove share oplock for " + "file %s, %s, %s\n", + fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), + file_id_string_tos(&fsp->file_id)); + } + release_file_oplock(fsp); + + ret = update_num_read_oplocks(fsp, lck); + if (!ret) { + DBG_ERR("update_num_read_oplocks failed for " + "file %s, %s, %s\n", + fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), + file_id_string_tos(&fsp->file_id)); + } + + return ret; +} + /**************************************************************************** Remove a file oplock. Copes with level II and exclusive. Locks then unlocks the share mode lock. Client can decide to go directly @@ -243,22 +271,7 @@ bool remove_oplock(files_struct *fsp) return false; } - ret = remove_share_oplock(lck, fsp); - if (!ret) { - DBG_ERR("failed to remove share oplock for " - "file %s, %s, %s\n", - fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), - file_id_string_tos(&fsp->file_id)); - } - release_file_oplock(fsp); - - ret = update_num_read_oplocks(fsp, lck); - if (!ret) { - DBG_ERR("update_num_read_oplocks failed for " - "file %s, %s, %s\n", - fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), - file_id_string_tos(&fsp->file_id)); - } + ret = remove_oplock_under_lock(fsp, lck); TALLOC_FREE(lck); return ret; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 08cdba991a6..75d8300fe94 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -681,6 +681,7 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck); void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp); NTSTATUS set_file_oplock(files_struct *fsp); +bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck); bool remove_oplock(files_struct *fsp); bool downgrade_oplock(files_struct *fsp); bool fsp_lease_update(struct share_mode_lock *lck,