diff options
author | Volker Lendecke <vl@samba.org> | 2022-02-09 18:03:33 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2022-02-14 17:46:14 +0000 |
commit | d44c45cbdbc7e13047ce127ea7ebcac2810a7891 (patch) | |
tree | 84c7d48819cb6a89bb0cd69d2815e6ea41f77849 | |
parent | 521178327e4ca5581d741966e8c288253be3d8f3 (diff) | |
download | samba-d44c45cbdbc7e13047ce127ea7ebcac2810a7891.tar.gz |
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 e91b59c4dfb2b35661dbecbc5769584109e23571)
-rw-r--r-- | source3/smbd/close.c | 26 | ||||
-rw-r--r-- | source3/smbd/proto.h | 3 |
2 files changed, 22 insertions, 7 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 9e7f89a304f..206515202e0 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -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; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 45519d87ef7..598ca1de2e2 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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); |