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

smbd: Introduce close_file_smb()

This does almost everything that close_file_free() does, but it leaves
the fsp around.

A normal close_file() now calls fsp_unbind_smb() twice. Functionally
this is not a problem, fsp_unbind_smb() is idempotent. The only
potential performance penalty might come from the loops in
remove_smb2_chained_fsp(), but those only are potentially large with
deeply queued smb2 requests. If that turns out to be a problem, we'll
cope with it later. The alternative would be to split up file_free()
into even more routines and make it more difficult to figure out which
of the "rundown/unbind/free" routines to call in any particular
situation.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14975

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit e91b59c4df)
This commit is contained in:
Volker Lendecke 2022-02-09 18:03:33 +01:00 committed by Jule Anger
parent 521178327e
commit d44c45cbdb
2 changed files with 22 additions and 7 deletions

View File

@ -1475,15 +1475,14 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
}
/****************************************************************************
Close a files_struct.
Rundown all SMB-related dependencies of a files struct
****************************************************************************/
NTSTATUS close_file_free(struct smb_request *req,
struct files_struct **_fsp,
enum file_close_type close_type)
NTSTATUS close_file_smb(struct smb_request *req,
struct files_struct *fsp,
enum file_close_type close_type)
{
NTSTATUS status;
struct files_struct *fsp = *_fsp;
/*
* This fsp can never be an internal dirfsp. They must
@ -1541,9 +1540,22 @@ NTSTATUS close_file_free(struct smb_request *req,
close_file_free(req, &fsp->base_fsp, close_type);
}
file_free(req, fsp);
fsp_unbind_smb(req, fsp);
*_fsp = NULL;
return status;
}
NTSTATUS close_file_free(struct smb_request *req,
struct files_struct **_fsp,
enum file_close_type close_type)
{
struct files_struct *fsp = *_fsp;
NTSTATUS status;
status = close_file_smb(req, fsp, close_type);
file_free(req, fsp);
*_fsp = NULL;
return status;
}

View File

@ -130,6 +130,9 @@ bool smbd_smb1_brl_finish_by_mid(
/* The following definitions come from smbd/close.c */
void set_close_write_time(struct files_struct *fsp, struct timespec ts);
NTSTATUS close_file_smb(struct smb_request *req,
struct files_struct *fsp,
enum file_close_type close_type);
NTSTATUS close_file_free(struct smb_request *req,
struct files_struct **_fsp,
enum file_close_type close_type);