1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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 <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
Jeremy Allison 2016-08-10 14:39:52 -07:00
parent de7180151f
commit cb394abe52
2 changed files with 30 additions and 16 deletions

View File

@ -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;

View File

@ -708,6 +708,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,